inspector: simplify dispatchProtocolMessage
PR-URL: https://github.com/nodejs/node/pull/49780 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
parent
813713f211
commit
2990390359
@ -97,16 +97,6 @@ double toDouble(const char* buffer, size_t length, bool* ok) {
|
|||||||
return d;
|
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) {
|
ProtocolMessage jsonToMessage(String message) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -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(const std::string_view);
|
||||||
std::unique_ptr<Value> parseJSON(v8_inspector::StringView 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 jsonToMessage(String message);
|
||||||
ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
|
ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
|
||||||
String fromUTF8(const uint8_t* data, size_t length);
|
String fromUTF8(const uint8_t* data, size_t length);
|
||||||
|
@ -253,8 +253,8 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
|
|||||||
"[inspector received] %s\n",
|
"[inspector received] %s\n",
|
||||||
raw_message);
|
raw_message);
|
||||||
std::unique_ptr<protocol::DictionaryValue> value =
|
std::unique_ptr<protocol::DictionaryValue> value =
|
||||||
protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage(
|
protocol::DictionaryValue::cast(
|
||||||
raw_message, false));
|
protocol::StringUtil::parseJSON(message));
|
||||||
int call_id;
|
int call_id;
|
||||||
std::string method;
|
std::string method;
|
||||||
node_dispatcher_->parseCommand(value.get(), &call_id, &method);
|
node_dispatcher_->parseCommand(value.get(), &call_id, &method);
|
||||||
|
@ -128,18 +128,6 @@ std::unique_ptr<base::Value> toBaseValue(Value* value, int depth) {
|
|||||||
return nullptr;
|
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
|
// static
|
||||||
ProtocolMessage StringUtil::jsonToMessage(String message) {
|
ProtocolMessage StringUtil::jsonToMessage(String message) {
|
||||||
return message;
|
return message;
|
||||||
|
@ -92,7 +92,6 @@ class {{config.lib.export_macro}} StringUtil {
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<Value> parseMessage(const std::string& message, bool binary);
|
|
||||||
static ProtocolMessage jsonToMessage(String message);
|
static ProtocolMessage jsonToMessage(String message);
|
||||||
static ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
|
static ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user