Commit d18fea5b authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

[DevTools] Roll inspector_protocol (Chromium) (Serializable)

With this roll, tweak the dependency from inspector to a public_deps.
It's needed because Serializable is exported from CRDTP now.

Upstream review (already merged):
https://chromium-review.googlesource.com/c/deps/inspector_protocol/+/1931280

Change-Id: I33c4aee3397ed4e746fc8605ce5911a2efc4c2ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1927577Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719254}
parent db429c9c
...@@ -212,9 +212,12 @@ jumbo_source_set("generated") { ...@@ -212,9 +212,12 @@ jumbo_source_set("generated") {
"//third_party/blink/renderer/core/probe:generated", "//third_party/blink/renderer/core/probe:generated",
"//third_party/blink/renderer/platform:make_platform_generated", "//third_party/blink/renderer/platform:make_platform_generated",
"//third_party/blink/renderer/platform/wtf", "//third_party/blink/renderer/platform/wtf",
"//third_party/inspector_protocol:crdtp",
"//v8", "//v8",
] ]
public_deps = [
"//third_party/inspector_protocol:crdtp",
]
} }
action("protocol_compatibility_check") { action("protocol_compatibility_check") {
......
...@@ -13,6 +13,8 @@ jumbo_component("crdtp") { ...@@ -13,6 +13,8 @@ jumbo_component("crdtp") {
"crdtp/json.cc", "crdtp/json.cc",
"crdtp/json.h", "crdtp/json.h",
"crdtp/parser_handler.h", "crdtp/parser_handler.h",
"crdtp/serializable.cc",
"crdtp/serializable.h",
"crdtp/span.h", "crdtp/span.h",
"crdtp/status.cc", "crdtp/status.cc",
"crdtp/status.h", "crdtp/status.h",
...@@ -48,6 +50,7 @@ source_set("crdtp_test") { ...@@ -48,6 +50,7 @@ source_set("crdtp_test") {
"crdtp/cbor_test.cc", "crdtp/cbor_test.cc",
"crdtp/glue_test.cc", "crdtp/glue_test.cc",
"crdtp/json_test.cc", "crdtp/json_test.cc",
"crdtp/serializable_test.cc",
"crdtp/span_test.cc", "crdtp/span_test.cc",
"crdtp/status_test.cc", "crdtp/status_test.cc",
] ]
......
...@@ -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: 7a44a37f66b58358dd8ab85ccde1998fafa95e53 Revision: 6e549cc623afedea19c7fb7c9511aa2e027fd191
License: BSD License: BSD
License File: LICENSE License File: LICENSE
Security Critical: yes Security Critical: yes
......
// Copyright 2019 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.
#include "serializable.h"
namespace crdtp {
// =============================================================================
// Serializable - An object to be emitted as a sequence of bytes.
// =============================================================================
std::vector<uint8_t> Serializable::TakeSerialized() && {
std::vector<uint8_t> out;
AppendSerialized(&out);
return out;
}
} // namespace crdtp
// Copyright 2019 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.
#ifndef CRDTP_SERIALIZABLE_H_
#define CRDTP_SERIALIZABLE_H_
#include <cstdint>
#include <vector>
#include "export.h"
namespace crdtp {
// =============================================================================
// Serializable - An object to be emitted as a sequence of bytes.
// =============================================================================
class CRDTP_EXPORT 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() &&;
virtual void AppendSerialized(std::vector<uint8_t>* out) const = 0;
virtual ~Serializable() = default;
};
} // namespace crdtp
#endif // CRDTP_SERIALIZABLE_H_
// Copyright 2019 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.
#include <cstdlib>
#include <string>
#include "serializable.h"
#include "test_platform.h"
namespace crdtp {
// =============================================================================
// Serializable - An object to be emitted as a sequence of bytes.
// =============================================================================
namespace {
// Tests the default behavior for ::TakeSerialized (to invoke
// ::AppendSerialized).
class SimpleExample : public Serializable {
public:
explicit SimpleExample(const std::vector<uint8_t>& contents)
: contents_(contents) {}
void AppendSerialized(std::vector<uint8_t>* out) const override {
out->insert(out->end(), contents_.begin(), contents_.end());
}
private:
std::vector<uint8_t> contents_;
};
} // namespace
TEST(SerializableTest, YieldsContents) {
std::vector<uint8_t> contents = {1, 2, 3};
SimpleExample foo(contents);
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));
}
} // namespace crdtp
...@@ -7,20 +7,13 @@ ...@@ -7,20 +7,13 @@
#ifndef {{"_".join(config.protocol.namespace)}}_FrontendChannel_h #ifndef {{"_".join(config.protocol.namespace)}}_FrontendChannel_h
#define {{"_".join(config.protocol.namespace)}}_FrontendChannel_h #define {{"_".join(config.protocol.namespace)}}_FrontendChannel_h
#include "{{config.crdtp.dir}}/serializable.h"
{% for namespace in config.protocol.namespace %} {% for namespace in config.protocol.namespace %}
namespace {{namespace}} { namespace {{namespace}} {
{% endfor %} {% endfor %}
class {{config.lib.export_macro}} Serializable { using {{config.crdtp.namespace}}::Serializable;
public:
virtual std::vector<uint8_t> TakeSerialized() && {
std::vector<uint8_t> out;
AppendSerialized(&out);
return out;
}
virtual void AppendSerialized(std::vector<uint8_t>* out) const = 0;
virtual ~Serializable() = default;
};
class {{config.lib.export_macro}} FrontendChannel { class {{config.lib.export_macro}} FrontendChannel {
public: public:
......
...@@ -29,6 +29,9 @@ FILES_TO_SYNC = [ ...@@ -29,6 +29,9 @@ FILES_TO_SYNC = [
'crdtp/json_platform.h', 'crdtp/json_platform.h',
'crdtp/json_test.cc', 'crdtp/json_test.cc',
'crdtp/parser_handler.h', 'crdtp/parser_handler.h',
'crdtp/serializable.h',
'crdtp/serializable.cc',
'crdtp/serializable_test.cc',
'crdtp/span.h', 'crdtp/span.h',
'crdtp/span_test.cc', 'crdtp/span_test.cc',
'crdtp/status.cc', 'crdtp/status.cc',
......
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