summaryrefslogtreecommitdiff
path: root/tools/inspector_protocol/lib/ValueConversions_h.template
diff options
context:
space:
mode:
Diffstat (limited to 'tools/inspector_protocol/lib/ValueConversions_h.template')
-rw-r--r--tools/inspector_protocol/lib/ValueConversions_h.template29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/inspector_protocol/lib/ValueConversions_h.template b/tools/inspector_protocol/lib/ValueConversions_h.template
index 4d64ec9091..2ee5b72454 100644
--- a/tools/inspector_protocol/lib/ValueConversions_h.template
+++ b/tools/inspector_protocol/lib/ValueConversions_h.template
@@ -1,3 +1,5 @@
+// This file is generated by ValueConversions_h.template.
+
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -100,6 +102,33 @@ struct ValueConversions<String> {
};
template<>
+struct ValueConversions<Binary> {
+ static Binary fromValue(protocol::Value* value, ErrorSupport* errors)
+ {
+ if (!value ||
+ (value->type() != Value::TypeBinary && value->type() != Value::TypeString)) {
+ errors->addError("Either string base64 or binary value expected");
+ return Binary();
+ }
+ Binary binary;
+ if (value->asBinary(&binary))
+ return binary;
+ String result;
+ value->asString(&result);
+ bool success;
+ Binary out = Binary::fromBase64(result, &success);
+ if (!success)
+ errors->addError("base64 decoding error");
+ return out;
+ }
+
+ static std::unique_ptr<protocol::Value> toValue(const Binary& value)
+ {
+ return BinaryValue::create(value);
+ }
+};
+
+template<>
struct ValueConversions<Value> {
static std::unique_ptr<Value> fromValue(protocol::Value* value, ErrorSupport* errors)
{