Commit 40e2bd1a authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

[DevTools] Roll inspector_protocol (V8)

Upstream PR:
"Drop && from Serializable::TakeSerialized() &&."
https://chromium-review.googlesource.com/c/deps/inspector_protocol/+/2029933

New Rev: 75c465e8d425f2e0b5297245c7eb058411af493a

Change-Id: I11dafc589c8f0c5a7e158b9cc5ad5202ba8237e1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2029335Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66189}
parent ddc7e691
......@@ -120,9 +120,9 @@ bool substituteObjectTags(int sessionId, const String16& groupName,
reportError(context, tryCatch, "cannot wrap value");
return false;
}
std::vector<uint8_t> cbor = std::move(*wrapper).TakeSerialized();
std::vector<uint8_t> json;
v8_crdtp::json::ConvertCBORToJSON(v8_crdtp::SpanFrom(cbor), &json);
v8_crdtp::json::ConvertCBORToJSON(v8_crdtp::SpanFrom(wrapper->Serialize()),
&json);
v8::Local<v8::Value> jsonWrapper;
v8_inspector::StringView serialized(json.data(), json.size());
if (!v8::JSON::Parse(context, toV8String(isolate, serialized))
......
......@@ -733,10 +733,10 @@ Response InjectedScript::resolveCallArgument(
if (callArgument->hasValue() || callArgument->hasUnserializableValue()) {
String16 value;
if (callArgument->hasValue()) {
std::vector<uint8_t> cbor =
std::move(*callArgument->getValue(nullptr)).TakeSerialized();
std::vector<uint8_t> json;
v8_crdtp::json::ConvertCBORToJSON(v8_crdtp::SpanFrom(cbor), &json);
v8_crdtp::json::ConvertCBORToJSON(
v8_crdtp::SpanFrom(callArgument->getValue(nullptr)->Serialize()),
&json);
value =
"(" +
String16(reinterpret_cast<const char*>(json.data()), json.size()) +
......
......@@ -167,7 +167,7 @@ protocol::DictionaryValue* V8InspectorSessionImpl::agentState(
std::unique_ptr<StringBuffer> V8InspectorSessionImpl::serializeForFrontend(
std::unique_ptr<protocol::Serializable> message) {
std::vector<uint8_t> cbor = std::move(*message).TakeSerialized();
std::vector<uint8_t> cbor = message->Serialize();
DCHECK(CheckCBORMessage(SpanFrom(cbor)).ok());
if (use_binary_protocol_) return StringBufferFrom(std::move(cbor));
std::vector<uint8_t> json;
......@@ -365,7 +365,7 @@ void V8InspectorSessionImpl::dispatchProtocolMessage(
}
std::vector<uint8_t> V8InspectorSessionImpl::state() {
return std::move(*m_state).TakeSerialized();
return m_state->Serialize();
}
std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
......
......@@ -164,8 +164,8 @@ std::unique_ptr<StringBuffer> V8StackTraceId::ToString() {
dict->setString(kDebuggerId, V8DebuggerId(debugger_id).toString());
dict->setBoolean(kShouldPause, should_pause);
std::vector<uint8_t> json;
std::vector<uint8_t> cbor = std::move(*dict).TakeSerialized();
ConvertCBORToJSON(SpanFrom(cbor), &json);
v8_crdtp::json::ConvertCBORToJSON(v8_crdtp::SpanFrom(dict->Serialize()),
&json);
return StringBufferFrom(std::move(json));
}
......
......@@ -2,7 +2,7 @@ Name: inspector protocol
Short Name: inspector_protocol
URL: https://chromium.googlesource.com/deps/inspector_protocol/
Version: 0
Revision: e4ffb7288a17b2bbe2f7b7cd62abcb1d1e55681a
Revision: 75c465e8d425f2e0b5297245c7eb058411af493a
License: BSD
License File: LICENSE
Security Critical: no
......
......@@ -9,7 +9,7 @@ namespace v8_crdtp {
// Serializable - An object to be emitted as a sequence of bytes.
// =============================================================================
std::vector<uint8_t> Serializable::TakeSerialized() && {
std::vector<uint8_t> Serializable::Serialize() const {
std::vector<uint8_t> out;
AppendSerialized(&out);
return out;
......
......@@ -16,10 +16,8 @@ namespace v8_crdtp {
class Serializable {
public:
// The default implementation invokes AppendSerialized with an empty vector
// and returns it; some subclasses may override and move out internal state
// instead to avoid copying.
virtual std::vector<uint8_t> TakeSerialized() &&;
// Convenience: Invokes |AppendSerialized| on an empty vector.
std::vector<uint8_t> Serialize() const;
virtual void AppendSerialized(std::vector<uint8_t>* out) const = 0;
......
......@@ -14,8 +14,7 @@ namespace v8_crdtp {
// =============================================================================
namespace {
// Tests the default behavior for ::TakeSerialized (to invoke
// ::AppendSerialized).
// Tests ::Serialize (which invokes ::AppendSerialized).
class SimpleExample : public Serializable {
public:
explicit SimpleExample(const std::vector<uint8_t>& contents)
......@@ -36,6 +35,6 @@ TEST(SerializableTest, YieldsContents) {
foo.AppendSerialized(&contents); // Yields contents by appending.
EXPECT_THAT(contents, testing::ElementsAre(1, 2, 3, 1, 2, 3));
// Yields contents by returning.
EXPECT_THAT(std::move(foo).TakeSerialized(), testing::ElementsAre(1, 2, 3));
EXPECT_THAT(foo.Serialize(), testing::ElementsAre(1, 2, 3));
}
} // namespace v8_crdtp
......@@ -146,31 +146,6 @@ private:
std::unique_ptr<Serializable> m_params;
};
class InternalRawNotification : public Serializable {
public:
static std::unique_ptr<InternalRawNotification> fromBinary(std::vector<uint8_t> notification)
{
return std::unique_ptr<InternalRawNotification>(new InternalRawNotification(std::move(notification)));
}
~InternalRawNotification() override {}
std::vector<uint8_t> TakeSerialized() && override {
return std::move(m_binaryNotification);
}
void AppendSerialized(std::vector<uint8_t>* out) const override
{
out->insert(out->end(), m_binaryNotification.begin(), m_binaryNotification.end());
}
private:
explicit InternalRawNotification(std::vector<uint8_t> notification)
: m_binaryNotification(std::move(notification)) { }
std::vector<uint8_t> m_binaryNotification;
};
{% for namespace in config.protocol.namespace %}
} // namespace {{namespace}}
{% endfor %}
......
......@@ -197,9 +197,9 @@ void Frontend::flush()
m_frontendChannel->flushProtocolNotifications();
}
void Frontend::sendRawCBORNotification(std::vector<uint8_t> notification)
void Frontend::sendRawNotification(std::unique_ptr<Serializable> notification)
{
m_frontendChannel->sendProtocolNotification(InternalRawNotification::fromBinary(std::move(notification)));
m_frontendChannel->sendProtocolNotification(std::move(notification));
}
// --------------------- Dispatcher.
......
......@@ -263,7 +263,7 @@ public:
{% endfor %}
void flush();
void sendRawCBORNotification(std::vector<uint8_t>);
void sendRawNotification(std::unique_ptr<Serializable>);
private:
FrontendChannel* m_frontendChannel;
};
......
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