Skip to content

Commit 64ae340

Browse files
lemireGeoffreyBooth
authored andcommitted
inspector: simplify dispatchProtocolMessage
PR-URL: nodejs#49780 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 12e87a1 commit 64ae340

File tree

5 files changed

+2
-27
lines changed

5 files changed

+2
-27
lines changed

src/inspector/node_string.cc

-10
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ double toDouble(const char* buffer, size_t length, bool* ok) {
9797
return d;
9898
}
9999

100-
std::unique_ptr<Value> parseMessage(const std::string_view message,
101-
bool binary) {
102-
if (binary) {
103-
return Value::parseBinary(
104-
reinterpret_cast<const uint8_t*>(message.data()),
105-
message.length());
106-
}
107-
return parseJSON(message);
108-
}
109-
110100
ProtocolMessage jsonToMessage(String message) {
111101
return message;
112102
}

src/inspector/node_string.h

-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ void builderAppendQuotedString(StringBuilder& builder, const std::string_view);
6868
std::unique_ptr<Value> parseJSON(const std::string_view);
6969
std::unique_ptr<Value> parseJSON(v8_inspector::StringView view);
7070

71-
std::unique_ptr<Value> parseMessage(const std::string_view message,
72-
bool binary);
7371
ProtocolMessage jsonToMessage(String message);
7472
ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
7573
String fromUTF8(const uint8_t* data, size_t length);

src/inspector_agent.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
253253
"[inspector received] %s\n",
254254
raw_message);
255255
std::unique_ptr<protocol::DictionaryValue> value =
256-
protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage(
257-
raw_message, false));
256+
protocol::DictionaryValue::cast(
257+
protocol::StringUtil::parseJSON(message));
258258
int call_id;
259259
std::string method;
260260
node_dispatcher_->parseCommand(value.get(), &call_id, &method);

tools/inspector_protocol/lib/base_string_adapter_cc.template

-12
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,6 @@ std::unique_ptr<base::Value> toBaseValue(Value* value, int depth) {
128128
return nullptr;
129129
}
130130

131-
// static
132-
std::unique_ptr<Value> StringUtil::parseMessage(
133-
const std::string& message, bool binary) {
134-
if (binary) {
135-
return Value::parseBinary(
136-
reinterpret_cast<const uint8_t*>(message.data()),
137-
message.length());
138-
}
139-
std::unique_ptr<base::Value> value = base::JSONReader::ReadDeprecated(message);
140-
return toProtocolValue(value.get(), 1000);
141-
}
142-
143131
// static
144132
ProtocolMessage StringUtil::jsonToMessage(String message) {
145133
return message;

tools/inspector_protocol/lib/base_string_adapter_h.template

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class {{config.lib.export_macro}} StringUtil {
9292
return builder.toString();
9393
}
9494

95-
static std::unique_ptr<Value> parseMessage(const std::string& message, bool binary);
9695
static ProtocolMessage jsonToMessage(String message);
9796
static ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
9897

0 commit comments

Comments
 (0)