Skip to content

Commit

Permalink
inspector: simplify dispatchProtocolMessage
Browse files Browse the repository at this point in the history
PR-URL: #49780
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
lemire authored and targos committed Nov 11, 2023
1 parent bc2c041 commit 5c66ec9
Show file tree
Hide file tree
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
Expand Up @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions src/inspector/node_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/inspector_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
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
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5c66ec9

Please sign in to comment.