| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,7 +34,7 @@ | |||
| 34 | 34 | '<(protocol_tool_path)/templates/Imported_h.template', | |
| 35 | 35 | '<(protocol_tool_path)/templates/TypeBuilder_cpp.template', | |
| 36 | 36 | '<(protocol_tool_path)/templates/TypeBuilder_h.template', | |
| 37 | - '<(protocol_tool_path)/CodeGenerator.py', | ||
| 37 | + '<(protocol_tool_path)/code_generator.py', | ||
| 38 | 38 | ] | |
| 39 | 39 | }, | |
| 40 | 40 | 'defines': [ | |
@@ -87,7 +87,7 @@ | |||
| 87 | 87 | ], | |
| 88 | 88 | 'action': [ | |
| 89 | 89 | 'python', | |
| 90 | - 'tools/inspector_protocol/ConvertProtocolToJSON.py', | ||
| 90 | + 'tools/inspector_protocol/convert_protocol_to_json.py', | ||
| 91 | 91 | '<@(_inputs)', | |
| 92 | 92 | '<@(_outputs)', | |
| 93 | 93 | ], | |
@@ -105,7 +105,7 @@ | |||
| 105 | 105 | 'process_outputs_as_sources': 1, | |
| 106 | 106 | 'action': [ | |
| 107 | 107 | 'python', | |
| 108 | - 'tools/inspector_protocol/CodeGenerator.py', | ||
| 108 | + 'tools/inspector_protocol/code_generator.py', | ||
| 109 | 109 | '--jinja_dir', '<@(protocol_tool_path)/..', | |
| 110 | 110 | '--output_base', '<(SHARED_INTERMEDIATE_DIR)/src/', | |
| 111 | 111 | '--config', '<(SHARED_INTERMEDIATE_DIR)/node_protocol_config.json', | |
@@ -123,7 +123,7 @@ | |||
| 123 | 123 | ], | |
| 124 | 124 | 'action': [ | |
| 125 | 125 | 'python', | |
| 126 | - 'tools/inspector_protocol/ConcatenateProtocols.py', | ||
| 126 | + 'tools/inspector_protocol/concatenate_protocols.py', | ||
| 127 | 127 | '<@(_inputs)', | |
| 128 | 128 | '<@(_outputs)', | |
| 129 | 129 | ], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,6 +85,28 @@ double toDouble(const char* buffer, size_t length, bool* ok) { | |||
| 85 | 85 | return d; | |
| 86 | 86 | } | |
| 87 | 87 | ||
| 88 | + std::unique_ptr<Value> parseMessage(const std::string& message, bool binary) { | ||
| 89 | + if (binary) { | ||
| 90 | + return Value::parseBinary( | ||
| 91 | + reinterpret_cast<const uint8_t*>(message.data()), | ||
| 92 | + message.length()); | ||
| 93 | + } | ||
| 94 | + return parseJSON(message); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + ProtocolMessage jsonToMessage(String message) { | ||
| 98 | + return message; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + ProtocolMessage binaryToMessage(std::vector<uint8_t> message) { | ||
| 102 | + return std::string(reinterpret_cast<const char*>(message.data()), | ||
| 103 | + message.size()); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + String fromUTF8(const uint8_t* data, size_t length) { | ||
| 107 | + return std::string(reinterpret_cast<const char*>(data), length); | ||
| 108 | + } | ||
| 109 | + | ||
| 88 | 110 | } // namespace StringUtil | |
| 89 | 111 | } // namespace protocol | |
| 90 | 112 | } // namespace inspector | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,17 @@ class Value; | |||
| 18 | 18 | ||
| 19 | 19 | using String = std::string; | |
| 20 | 20 | using StringBuilder = std::ostringstream; | |
| 21 | + using ProtocolMessage = std::string; | ||
| 22 | + | ||
| 23 | + class StringUTF8Adapter { | ||
| 24 | + public: | ||
| 25 | + explicit StringUTF8Adapter(const std::string& string) : string_(string) { } | ||
| 26 | + const char* Data() const { return string_.data(); } | ||
| 27 | + size_t length() const { return string_.length(); } | ||
| 28 | + | ||
| 29 | + private: | ||
| 30 | + const std::string& string_; | ||
| 31 | + }; | ||
| 21 | 32 | ||
| 22 | 33 | namespace StringUtil { | |
| 23 | 34 | // NOLINTNEXTLINE(runtime/references) This is V8 API... | |
@@ -67,8 +78,29 @@ void builderAppendQuotedString(StringBuilder& builder, const String&); | |||
| 67 | 78 | std::unique_ptr<Value> parseJSON(const String&); | |
| 68 | 79 | std::unique_ptr<Value> parseJSON(v8_inspector::StringView view); | |
| 69 | 80 | ||
| 81 | + std::unique_ptr<Value> parseMessage(const std::string& message, bool binary); | ||
| 82 | + ProtocolMessage jsonToMessage(String message); | ||
| 83 | + ProtocolMessage binaryToMessage(std::vector<uint8_t> message); | ||
| 84 | + String fromUTF8(const uint8_t* data, size_t length); | ||
| 85 | + | ||
| 70 | 86 | extern size_t kNotFound; | |
| 71 | 87 | } // namespace StringUtil | |
| 88 | + | ||
| 89 | + // A read-only sequence of uninterpreted bytes with reference-counted storage. | ||
| 90 | + // Though the templates for generating the protocol bindings reference | ||
| 91 | + // this type, js_protocol.pdl doesn't have a field of type 'binary', so | ||
| 92 | + // therefore it's unnecessary to provide an implementation here. | ||
| 93 | + class Binary { | ||
| 94 | + public: | ||
| 95 | + const uint8_t* data() const { UNREACHABLE(); } | ||
| 96 | + size_t size() const { UNREACHABLE(); } | ||
| 97 | + String toBase64() const { UNREACHABLE(); } | ||
| 98 | + static Binary fromBase64(const String& base64, bool* success) { | ||
| 99 | + UNREACHABLE(); | ||
| 100 | + } | ||
| 101 | + static Binary fromSpan(const uint8_t* data, size_t size) { UNREACHABLE(); } | ||
| 102 | + }; | ||
| 103 | + | ||
| 72 | 104 | } // namespace protocol | |
| 73 | 105 | } // namespace inspector | |
| 74 | 106 | } // namespace node | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -236,15 +236,19 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, | |||
| 236 | 236 | } | |
| 237 | 237 | ||
| 238 | 238 | std::string dispatchProtocolMessage(const StringView& message) { | |
| 239 | - std::unique_ptr<protocol::DictionaryValue> parsed; | ||
| 239 | + std::string raw_message = protocol::StringUtil::StringViewToUtf8(message); | ||
| 240 | + std::unique_ptr<protocol::DictionaryValue> value = | ||
| 241 | + protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage( | ||
| 242 | + raw_message, false)); | ||
| 243 | + int call_id; | ||
| 240 | 244 | std::string method; | |
| 241 | - node_dispatcher_->getCommandName( | ||
| 242 | - protocol::StringUtil::StringViewToUtf8(message), &method, &parsed); | ||
| 245 | + node_dispatcher_->parseCommand(value.get(), &call_id, &method); | ||
| 243 | 246 | if (v8_inspector::V8InspectorSession::canDispatchMethod( | |
| 244 | 247 | Utf8ToStringView(method)->string())) { | |
| 245 | 248 | session_->dispatchProtocolMessage(message); | |
| 246 | 249 | } else { | |
| 247 | - node_dispatcher_->dispatch(std::move(parsed)); | ||
| 250 | + node_dispatcher_->dispatch(call_id, method, std::move(value), | ||
| 251 | + raw_message); | ||
| 248 | 252 | } | |
| 249 | 253 | return method; | |
| 250 | 254 | } | |
@@ -284,11 +288,17 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, | |||
| 284 | 288 | ||
| 285 | 289 | void sendProtocolResponse(int callId, | |
| 286 | 290 | std::unique_ptr<Serializable> message) override { | |
| 287 | - sendMessageToFrontend(message->serialize()); | ||
| 291 | + sendMessageToFrontend(message->serializeToJSON()); | ||
| 288 | 292 | } | |
| 289 | 293 | void sendProtocolNotification( | |
| 290 | 294 | std::unique_ptr<Serializable> message) override { | |
| 291 | - sendMessageToFrontend(message->serialize()); | ||
| 295 | + sendMessageToFrontend(message->serializeToJSON()); | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + void fallThrough(int callId, | ||
| 299 | + const std::string& method, | ||
| 300 | + const std::string& message) override { | ||
| 301 | + DCHECK(false); | ||
| 292 | 302 | } | |
| 293 | 303 | ||
| 294 | 304 | std::unique_ptr<protocol::TracingAgent> tracing_agent_; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ Name: inspector protocol | |||
| 2 | 2 | Short Name: inspector_protocol | |
| 3 | 3 | URL: https://chromium.googlesource.com/deps/inspector_protocol/ | |
| 4 | 4 | Version: 0 | |
| 5 | - Revision: 752d4abd13119010cf30e454e8ef9b5fb7ef43a3 | ||
| 5 | + Revision: f67ec5180f476830e839226b5ca948e43070fdab | ||
| 6 | 6 | License: BSD | |
| 7 | 7 | License File: LICENSE | |
| 8 | 8 | Security Critical: no | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,11 +45,14 @@ | |||
| 45 | 45 | # | |
| 46 | 46 | # Adding --show_changes to the command line prints out a list of valid public API changes. | |
| 47 | 47 | ||
| 48 | + from __future__ import print_function | ||
| 48 | 49 | import copy | |
| 49 | 50 | import os.path | |
| 50 | 51 | import optparse | |
| 51 | 52 | import sys | |
| 52 | 53 | ||
| 54 | + import pdl | ||
| 55 | + | ||
| 53 | 56 | try: | |
| 54 | 57 | import json | |
| 55 | 58 | except ImportError: | |
@@ -166,6 +169,11 @@ def compare_types(context, kind, type_1, type_2, types_map_1, types_map_2, depth | |||
| 166 | 169 | base_type_1 = type_1["type"] | |
| 167 | 170 | base_type_2 = type_2["type"] | |
| 168 | 171 | ||
| 172 | + # Binary and string have the same wire representation in JSON. | ||
| 173 | + if ((base_type_1 == "string" and base_type_2 == "binary") or | ||
| 174 | + (base_type_2 == "string" and base_type_1 == "binary")): | ||
| 175 | + return | ||
| 176 | + | ||
| 169 | 177 | if base_type_1 != base_type_2: | |
| 170 | 178 | errors.append("%s: %s base type mismatch, '%s' vs '%s'" % (context, kind, base_type_1, base_type_2)) | |
| 171 | 179 | elif base_type_1 == "object": | |
@@ -228,8 +236,8 @@ def load_schema(file_name, domains): | |||
| 228 | 236 | if not os.path.isfile(file_name): | |
| 229 | 237 | return | |
| 230 | 238 | input_file = open(file_name, "r") | |
| 231 | - json_string = input_file.read() | ||
| 232 | - parsed_json = json.loads(json_string) | ||
| 239 | + parsed_json = pdl.loads(input_file.read(), file_name) | ||
| 240 | + input_file.close() | ||
| 233 | 241 | domains += parsed_json["domains"] | |
| 234 | 242 | return parsed_json["version"] | |
| 235 | 243 | ||
@@ -422,6 +430,7 @@ def load_domains_and_baselines(file_name, domains, baseline_domains): | |||
| 422 | 430 | version = load_schema(os.path.normpath(file_name), domains) | |
| 423 | 431 | suffix = "-%s.%s.json" % (version["major"], version["minor"]) | |
| 424 | 432 | baseline_file = file_name.replace(".json", suffix) | |
| 433 | + baseline_file = file_name.replace(".pdl", suffix) | ||
| 425 | 434 | load_schema(os.path.normpath(baseline_file), baseline_domains) | |
| 426 | 435 | return version | |
| 427 | 436 | ||
@@ -467,9 +476,9 @@ def main(): | |||
| 467 | 476 | if arg_options.show_changes: | |
| 468 | 477 | changes = compare_schemas(domains, baseline_domains, True) | |
| 469 | 478 | if len(changes) > 0: | |
| 470 | - print " Public changes since %s:" % version | ||
| 479 | + print(" Public changes since %s:" % version) | ||
| 471 | 480 | for change in changes: | |
| 472 | - print " %s" % change | ||
| 481 | + print(" %s" % change) | ||
| 473 | 482 | ||
| 474 | 483 | if arg_options.stamp: | |
| 475 | 484 | with open(arg_options.stamp, 'a') as _: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments