Skip to content

Commit a75a59d

Browse files
targosbnoordhuis
andcommitted
tools: update inspector_protocol to 0aafd2
Co-authored-by: Ben Noordhuis <[email protected]> PR-URL: #27770 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent e72d4aa commit a75a59d

29 files changed

+7733
-1459
lines changed

src/inspector/node_inspector.gypi

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
'node_protocol_files': [
1616
'<(protocol_tool_path)/lib/Allocator_h.template',
1717
'<(protocol_tool_path)/lib/Array_h.template',
18-
'<(protocol_tool_path)/lib/Collections_h.template',
18+
'<(protocol_tool_path)/lib/base_string_adapter_cc.template',
19+
'<(protocol_tool_path)/lib/base_string_adapter_h.template',
1920
'<(protocol_tool_path)/lib/DispatcherBase_cpp.template',
2021
'<(protocol_tool_path)/lib/DispatcherBase_h.template',
22+
'<(protocol_tool_path)/lib/encoding_cpp.template',
23+
'<(protocol_tool_path)/lib/encoding_h.template',
2124
'<(protocol_tool_path)/lib/ErrorSupport_cpp.template',
2225
'<(protocol_tool_path)/lib/ErrorSupport_h.template',
2326
'<(protocol_tool_path)/lib/Forward_h.template',

src/inspector/node_string.cc

+16
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@ String fromUTF8(const uint8_t* data, size_t length) {
107107
return std::string(reinterpret_cast<const char*>(data), length);
108108
}
109109

110+
String fromUTF16(const uint16_t* data, size_t length) {
111+
icu::UnicodeString utf16(reinterpret_cast<const char16_t*>(data), length);
112+
std::string result;
113+
return utf16.toUTF8String(result);
114+
}
115+
116+
const uint8_t* CharactersUTF8(const String& s) {
117+
return reinterpret_cast<const uint8_t*>(s.data());
118+
}
119+
120+
size_t CharacterCount(const String& s) {
121+
icu::UnicodeString utf16 =
122+
icu::UnicodeString::fromUTF8(icu::StringPiece(s.data(), s.length()));
123+
return utf16.countChar32();
124+
}
125+
110126
} // namespace StringUtil
111127
} // namespace protocol
112128
} // namespace inspector

src/inspector/node_string.h

+7-10
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ using String = std::string;
2020
using StringBuilder = std::ostringstream;
2121
using ProtocolMessage = std::string;
2222

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-
};
32-
3323
namespace StringUtil {
3424
// NOLINTNEXTLINE(runtime/references) This is V8 API...
3525
inline void builderAppend(StringBuilder& builder, char c) {
@@ -82,6 +72,13 @@ std::unique_ptr<Value> parseMessage(const std::string& message, bool binary);
8272
ProtocolMessage jsonToMessage(String message);
8373
ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
8474
String fromUTF8(const uint8_t* data, size_t length);
75+
String fromUTF16(const uint16_t* data, size_t length);
76+
const uint8_t* CharactersUTF8(const String& s);
77+
size_t CharacterCount(const String& s);
78+
79+
// Unimplemented. The generated code will fall back to CharactersUTF8().
80+
inline uint8_t* CharactersLatin1(const String& s) { return nullptr; }
81+
inline const uint16_t* CharactersUTF16(const String& s) { return nullptr; }
8582

8683
extern size_t kNotFound;
8784
} // namespace StringUtil

src/inspector/tracing_agent.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SendMessageRequest : public Request {
7070
if (frontend_wrapper == nullptr) return;
7171
auto frontend = frontend_wrapper->get();
7272
if (frontend != nullptr) {
73-
frontend->sendRawNotification(message_);
73+
frontend->sendRawJSONNotification(message_);
7474
}
7575
}
7676

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Defines the Chromium style for automatic reformatting.
2+
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
3+
BasedOnStyle: Chromium
4+
# This defaults to 'Auto'. Explicitly set it for a while, so that
5+
# 'vector<vector<int> >' in existing files gets formatted to
6+
# 'vector<vector<int>>'. ('Auto' means that clang-format will only use
7+
# 'int>>' if the file already contains at least one such instance.)
8+
Standard: Cpp11
9+
10+
# Make sure code like:
11+
# IPC_BEGIN_MESSAGE_MAP()
12+
# IPC_MESSAGE_HANDLER(WidgetHostViewHost_Update, OnUpdate)
13+
# IPC_END_MESSAGE_MAP()
14+
# gets correctly indented.
15+
MacroBlockBegin: "^\
16+
BEGIN_MSG_MAP|\
17+
BEGIN_MSG_MAP_EX|\
18+
BEGIN_SAFE_MSG_MAP_EX|\
19+
CR_BEGIN_MSG_MAP_EX|\
20+
IPC_BEGIN_MESSAGE_MAP|\
21+
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM|\
22+
IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN|\
23+
IPC_STRUCT_BEGIN|\
24+
IPC_STRUCT_BEGIN_WITH_PARENT|\
25+
IPC_STRUCT_TRAITS_BEGIN|\
26+
POLPARAMS_BEGIN|\
27+
PPAPI_BEGIN_MESSAGE_MAP$"
28+
MacroBlockEnd: "^\
29+
CR_END_MSG_MAP|\
30+
END_MSG_MAP|\
31+
IPC_END_MESSAGE_MAP|\
32+
IPC_PROTOBUF_MESSAGE_TRAITS_END|\
33+
IPC_STRUCT_END|\
34+
IPC_STRUCT_TRAITS_END|\
35+
POLPARAMS_END|\
36+
PPAPI_END_MESSAGE_MAP$"

tools/inspector_protocol/BUILD.gn

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2019 the V8 project authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
static_library("encoding") {
6+
sources = [
7+
"encoding/encoding.cc",
8+
"encoding/encoding.h",
9+
]
10+
}
11+
12+
# encoding_test is part of the unittests, defined in
13+
# test/unittests/BUILD.gn.
14+
15+
import("../../gni/v8.gni")
16+
17+
v8_source_set("encoding_test") {
18+
sources = [
19+
"encoding/encoding_test.cc",
20+
"encoding/encoding_test_helper.h",
21+
]
22+
configs = [
23+
"../..:external_config",
24+
"../..:internal_config_base",
25+
]
26+
deps = [
27+
":encoding",
28+
"../..:v8_libbase",
29+
"../../src/inspector:inspector_string_conversions",
30+
"//testing/gmock",
31+
"//testing/gtest",
32+
]
33+
testonly = true
34+
}

tools/inspector_protocol/README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Chromium inspector (devtools) protocol
2+
3+
This package contains code generators and templates for the Chromium
4+
inspector protocol.
5+
6+
The canonical location of this package is at
7+
https://chromium.googlesource.com/deps/inspector_protocol/
8+
9+
In the Chromium tree, it's rolled into
10+
https://cs.chromium.org/chromium/src/third_party/inspector_protocol/
11+
12+
In the V8 tree, it's rolled into
13+
https://cs.chromium.org/chromium/src/v8/third_party/inspector_protocol/
14+
15+
See also [Contributing to Chrome Devtools Protocol](https://docs.google.com/document/d/1c-COD2kaK__5iMM5SEx-PzNA7HFmgttcYfOHHX0HaOM/edit).
16+
17+
We're working on enabling standalone builds for parts of this package for
18+
testing and development, please feel free to ignore this for now.
19+
But, if you're familiar with
20+
[Chromium's development process](https://www.chromium.org/developers/contributing-code)
21+
and have the depot_tools installed, you may use these commands
22+
to fetch the package (and dependencies) and build and run the tests:
23+
24+
fetch inspector_protocol
25+
cd src
26+
gn gen out/Release
27+
ninja -C out/Release json_parser_test
28+
out/Release/json_parser_test
29+
30+
You'll probably also need to install g++, since Clang uses this to find the
31+
standard C++ headers. E.g.,
32+
33+
sudo apt-get install g++-8

tools/inspector_protocol/README.node

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Name: inspector protocol
22
Short Name: inspector_protocol
33
URL: https://chromium.googlesource.com/deps/inspector_protocol/
44
Version: 0
5-
Revision: f67ec5180f476830e839226b5ca948e43070fdab
5+
Revision: 0aafd2876f7485db7b07c513c0457b7cbbbe3304
66
License: BSD
77
License File: LICENSE
88
Security Critical: no

tools/inspector_protocol/code_generator.py

+16-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import os.path
77
import sys
8-
import optparse
8+
import argparse
99
import collections
1010
import functools
1111
import re
@@ -17,6 +17,13 @@
1717

1818
import pdl
1919

20+
try:
21+
unicode
22+
except NameError:
23+
# Define unicode for Py3
24+
def unicode(s, *_):
25+
return s
26+
2027
# Path handling for libraries and templates
2128
# Paths have to be normalized because Jinja uses the exact template path to
2229
# determine the hash used in the cache filename, and we need a pre-caching step
@@ -53,27 +60,16 @@ def init_defaults(config_tuple, path, defaults):
5360
return collections.namedtuple('X', keys)(*values)
5461

5562
try:
56-
cmdline_parser = optparse.OptionParser()
57-
cmdline_parser.add_option("--output_base")
58-
cmdline_parser.add_option("--jinja_dir")
59-
cmdline_parser.add_option("--config")
60-
cmdline_parser.add_option("--config_value", action="append", type="string")
61-
arg_options, _ = cmdline_parser.parse_args()
63+
cmdline_parser = argparse.ArgumentParser()
64+
cmdline_parser.add_argument("--output_base", type=unicode, required=True)
65+
cmdline_parser.add_argument("--jinja_dir", type=unicode, required=True)
66+
cmdline_parser.add_argument("--config", type=unicode, required=True)
67+
cmdline_parser.add_argument("--config_value", default=[], action="append")
68+
arg_options = cmdline_parser.parse_args()
6269
jinja_dir = arg_options.jinja_dir
63-
if not jinja_dir:
64-
raise Exception("jinja directory must be specified")
65-
jinja_dir = jinja_dir.decode('utf8')
6670
output_base = arg_options.output_base
67-
if not output_base:
68-
raise Exception("Base output directory must be specified")
69-
output_base = output_base.decode('utf8')
7071
config_file = arg_options.config
71-
if not config_file:
72-
raise Exception("Config file name must be specified")
73-
config_file = config_file.decode('utf8')
7472
config_values = arg_options.config_value
75-
if not config_values:
76-
config_values = []
7773
except Exception:
7874
# Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html
7975
exc = sys.exc_info()[1]
@@ -631,7 +627,7 @@ def main():
631627
"Array_h.template",
632628
"DispatcherBase_h.template",
633629
"Parser_h.template",
634-
"CBOR_h.template",
630+
"encoding_h.template",
635631
]
636632

637633
protocol_cpp_templates = [
@@ -641,7 +637,7 @@ def main():
641637
"Object_cpp.template",
642638
"DispatcherBase_cpp.template",
643639
"Parser_cpp.template",
644-
"CBOR_cpp.template",
640+
"encoding_cpp.template",
645641
]
646642

647643
forward_h_templates = [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This file is used by git-cl to get repository specific information.
2+
3+
CODE_REVIEW_SERVER: codereview.chromium.org
4+
GERRIT_HOST: True
5+
PROJECT: inspector_protocol
6+
VIEW_VC: https://chromium.googlesource.com/deps/inspector_protocol/+/

tools/inspector_protocol/convert_protocol_to_json.py

-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
# found in the LICENSE file.
55

66
import argparse
7-
import collections
87
import json
98
import os.path
10-
import re
119
import sys
1210

1311
import pdl

0 commit comments

Comments
 (0)