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: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59542}
This commit is contained in:
Pavel Feldman 2019-02-12 15:04:11 -08:00 committed by Commit Bot
parent 5dffb59630
commit 8bf60985da
8 changed files with 26 additions and 6 deletions

View File

@ -67,6 +67,16 @@ class StringUtil {
const ProtocolMessage&);
static ProtocolMessage jsonToMessage(String 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.

View File

@ -329,7 +329,7 @@ void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) {
void V8InspectorSessionImpl::dispatchProtocolMessage(
const StringView& message) {
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;
int callId;
std::unique_ptr<protocol::Value> parsed_message;

View File

@ -2,7 +2,7 @@ Name: inspector protocol
Short Name: inspector_protocol
URL: https://chromium.googlesource.com/deps/inspector_protocol/
Version: 0
Revision: e8a0de7351b5d72aadde777e2ad9b412d1431ffa
Revision: a0abcb6bfbd8d13071bb0d2ac4ee1066703eb60a
License: BSD
License File: LICENSE
Security Critical: no

View File

@ -63,7 +63,7 @@ void escapeStringForJSONInternal(const Char* str, unsigned len,
} // anonymous namespace
// 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;
}

View File

@ -28,7 +28,7 @@ public:
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 {
TypeNull = 0,

View File

@ -54,7 +54,7 @@ public:
virtual std::vector<uint8_t> toBinary() const = 0;
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}}> 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 %}

View File

@ -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;
if (binary_protocol) {
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 {
String json = value->serializeToJSON();
result = {{"::".join(config.imported.namespace)}}::{{domain.domain}}::API::{{type.id}}::fromJSONString({{config.imported.to_imported_string % "json"}});

View File

@ -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);
}
// 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 %}
{% endfor %}