Commit 8bf60985 authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

Roll third_party/inspector_protocol to a0abcb6bfbd8d13071bb0d2ac4ee1066703eb60a.

Drive-by utf8 serialization exposed on StringUtil for inspector protocol.

Bug: chromium:929862
Change-Id: I930cd43fef9038471908280f15e65a4edec5c6d1
Reviewed-on: https://chromium-review.googlesource.com/c/1468702
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Reviewed-by: 's avatarAlexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59542}
parent 5dffb596
...@@ -67,6 +67,16 @@ class StringUtil { ...@@ -67,6 +67,16 @@ class StringUtil {
const ProtocolMessage&); const ProtocolMessage&);
static ProtocolMessage jsonToMessage(String message); static ProtocolMessage jsonToMessage(String message);
static ProtocolMessage binaryToMessage(std::vector<uint8_t> message); static ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
static String fromUTF8(const uint8_t* data, size_t length) {
return String16::fromUTF8(reinterpret_cast<const char*>(data), length);
}
static void writeUTF8(const String& string, std::vector<uint8_t>* out) {
// TODO(pfeldman): get rid of the copy here.
std::string utf8 = string.utf8();
const uint8_t* data = reinterpret_cast<const uint8_t*>(utf8.data());
out->insert(out->end(), data, data + utf8.length());
}
}; };
// A read-only sequence of uninterpreted bytes with reference-counted storage. // A read-only sequence of uninterpreted bytes with reference-counted storage.
......
...@@ -329,7 +329,7 @@ void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) { ...@@ -329,7 +329,7 @@ void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) {
void V8InspectorSessionImpl::dispatchProtocolMessage( void V8InspectorSessionImpl::dispatchProtocolMessage(
const StringView& message) { const StringView& message) {
bool binary_protocol = bool binary_protocol =
message.is8Bit() && message.length() && message.characters8()[0] == 0xDA; message.is8Bit() && message.length() && message.characters8()[0] == 0xD8;
if (binary_protocol) use_binary_protocol_ = true; if (binary_protocol) use_binary_protocol_ = true;
int callId; int callId;
std::unique_ptr<protocol::Value> parsed_message; std::unique_ptr<protocol::Value> parsed_message;
......
...@@ -2,7 +2,7 @@ Name: inspector protocol ...@@ -2,7 +2,7 @@ Name: inspector protocol
Short Name: inspector_protocol Short Name: inspector_protocol
URL: https://chromium.googlesource.com/deps/inspector_protocol/ URL: https://chromium.googlesource.com/deps/inspector_protocol/
Version: 0 Version: 0
Revision: e8a0de7351b5d72aadde777e2ad9b412d1431ffa Revision: a0abcb6bfbd8d13071bb0d2ac4ee1066703eb60a
License: BSD License: BSD
License File: LICENSE License File: LICENSE
Security Critical: no Security Critical: no
......
...@@ -63,7 +63,7 @@ void escapeStringForJSONInternal(const Char* str, unsigned len, ...@@ -63,7 +63,7 @@ void escapeStringForJSONInternal(const Char* str, unsigned len,
} // anonymous namespace } // anonymous namespace
// static // static
std::unique_ptr<Value> Value::parseBinary(const uint8_t* data, unsigned size) { std::unique_ptr<Value> Value::parseBinary(const uint8_t* data, size_t size) {
return nullptr; return nullptr;
} }
......
...@@ -28,7 +28,7 @@ public: ...@@ -28,7 +28,7 @@ public:
return std::unique_ptr<Value>(new Value()); return std::unique_ptr<Value>(new Value());
} }
static std::unique_ptr<Value> parseBinary(const uint8_t*data, unsigned size); static std::unique_ptr<Value> parseBinary(const uint8_t* data, size_t size);
enum ValueType { enum ValueType {
TypeNull = 0, TypeNull = 0,
......
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
virtual std::vector<uint8_t> toBinary() const = 0; virtual std::vector<uint8_t> toBinary() const = 0;
virtual ~{{type.id}}() { } virtual ~{{type.id}}() { }
static std::unique_ptr<protocol::{{domain.domain}}::API::{{type.id}}> fromJSONString(const {{config.exported.string_in}}& json); static std::unique_ptr<protocol::{{domain.domain}}::API::{{type.id}}> fromJSONString(const {{config.exported.string_in}}& json);
static std::unique_ptr<protocol::{{domain.domain}}::API::{{type.id}}> fromBinary(std::vector<uint8_t> binary); static std::unique_ptr<protocol::{{domain.domain}}::API::{{type.id}}> fromBinary(const uint8_t* data, size_t length);
}; };
{% endfor %} {% endfor %}
......
...@@ -34,7 +34,7 @@ struct ValueConversions<{{"::".join(config.imported.namespace)}}::{{domain.domai ...@@ -34,7 +34,7 @@ struct ValueConversions<{{"::".join(config.imported.namespace)}}::{{domain.domai
std::unique_ptr<{{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}> result; std::unique_ptr<{{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}> result;
if (binary_protocol) { if (binary_protocol) {
std::vector<uint8_t> binary = value->serializeToBinary(); std::vector<uint8_t> binary = value->serializeToBinary();
result = {{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}::fromBinary(std::move(binary)); result = {{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}::fromBinary(binary.data(), binary.size());
} else { } else {
String json = value->serializeToJSON(); String json = value->serializeToJSON();
result = {{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}::fromJSONString({{config.imported.to_imported_string % "json"}}); result = {{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}::fromJSONString({{config.imported.to_imported_string % "json"}});
......
...@@ -120,6 +120,16 @@ std::unique_ptr<API::{{type.id}}> API::{{type.id}}::fromJSONString(const {{confi ...@@ -120,6 +120,16 @@ std::unique_ptr<API::{{type.id}}> API::{{type.id}}::fromJSONString(const {{confi
return protocol::{{domain.domain}}::{{type.id}}::fromValue(value.get(), &errors); return protocol::{{domain.domain}}::{{type.id}}::fromValue(value.get(), &errors);
} }
// static
std::unique_ptr<API::{{type.id}}> API::{{type.id}}::fromBinary(const uint8_t* data, size_t length)
{
ErrorSupport errors;
std::unique_ptr<Value> value = Value::parseBinary(data, length);
if (!value)
return nullptr;
return protocol::{{domain.domain}}::{{type.id}}::fromValue(value.get(), &errors);
}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment