Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inspector: simplify dispatchProtocolMessage
Browse files Browse the repository at this point in the history
PR-URL: nodejs#49780
Reviewed-By: Yagiz Nizipli <[email protected]>
lemire authored and GeoffreyBooth committed Oct 1, 2023
1 parent 12e87a1 commit 64ae340
Showing 5 changed files with 2 additions and 27 deletions.
10 changes: 0 additions & 10 deletions src/inspector/node_string.cc
Original file line number Diff line number Diff line change
@@ -97,16 +97,6 @@ double toDouble(const char* buffer, size_t length, bool* ok) {
return d;
}

std::unique_ptr<Value> parseMessage(const std::string_view message,
bool binary) {
if (binary) {
return Value::parseBinary(
reinterpret_cast<const uint8_t*>(message.data()),
message.length());
}
return parseJSON(message);
}

ProtocolMessage jsonToMessage(String message) {
return message;
}
2 changes: 0 additions & 2 deletions src/inspector/node_string.h
Original file line number Diff line number Diff line change
@@ -68,8 +68,6 @@ void builderAppendQuotedString(StringBuilder& builder, const std::string_view);
std::unique_ptr<Value> parseJSON(const std::string_view);
std::unique_ptr<Value> parseJSON(v8_inspector::StringView view);

std::unique_ptr<Value> parseMessage(const std::string_view message,
bool binary);
ProtocolMessage jsonToMessage(String message);
ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
String fromUTF8(const uint8_t* data, size_t length);
4 changes: 2 additions & 2 deletions src/inspector_agent.cc
Original file line number Diff line number Diff line change
@@ -253,8 +253,8 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
"[inspector received] %s\n",
raw_message);
std::unique_ptr<protocol::DictionaryValue> value =
protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage(
raw_message, false));
protocol::DictionaryValue::cast(
protocol::StringUtil::parseJSON(message));
int call_id;
std::string method;
node_dispatcher_->parseCommand(value.get(), &call_id, &method);
12 changes: 0 additions & 12 deletions tools/inspector_protocol/lib/base_string_adapter_cc.template
Original file line number Diff line number Diff line change
@@ -128,18 +128,6 @@ std::unique_ptr<base::Value> toBaseValue(Value* value, int depth) {
return nullptr;
}

// static
std::unique_ptr<Value> StringUtil::parseMessage(
const std::string& message, bool binary) {
if (binary) {
return Value::parseBinary(
reinterpret_cast<const uint8_t*>(message.data()),
message.length());
}
std::unique_ptr<base::Value> value = base::JSONReader::ReadDeprecated(message);
return toProtocolValue(value.get(), 1000);
}

// static
ProtocolMessage StringUtil::jsonToMessage(String message) {
return message;
Original file line number Diff line number Diff line change
@@ -92,7 +92,6 @@ class {{config.lib.export_macro}} StringUtil {
return builder.toString();
}

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

0 comments on commit 64ae340

Please sign in to comment.