Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspector: simplify dispatchProtocolMessage #49780

Merged
merged 2 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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