Commit db4096fb authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

[DevTools] Avoid parsing JSON twice in DispatchProtocolMessage.

Change-Id: I5ace88b383d1ba94a75e8990fde5bfeb0a357f97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1566026Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#650480}
parent 82051ed5
...@@ -155,7 +155,11 @@ bool DevToolsSession::DispatchProtocolMessage(const std::string& message) { ...@@ -155,7 +155,11 @@ bool DevToolsSession::DispatchProtocolMessage(const std::string& message) {
} }
std::string converted_cbor_message; std::string converted_cbor_message;
const std::string* message_to_send = &message; const std::string* message_to_send = &message;
if (EnableInternalDevToolsBinaryProtocol()) { std::unique_ptr<protocol::DictionaryValue> value;
if (!EnableInternalDevToolsBinaryProtocol()) {
value = protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage(
message, client_->UsesBinaryProtocol()));
} else {
if (client_->UsesBinaryProtocol()) { if (client_->UsesBinaryProtocol()) {
// If the client uses the binary protocol, then |message| is already // If the client uses the binary protocol, then |message| is already
// CBOR (it comes from the client). // CBOR (it comes from the client).
...@@ -164,10 +168,9 @@ bool DevToolsSession::DispatchProtocolMessage(const std::string& message) { ...@@ -164,10 +168,9 @@ bool DevToolsSession::DispatchProtocolMessage(const std::string& message) {
converted_cbor_message = ConvertJSONToCBOR(message); converted_cbor_message = ConvertJSONToCBOR(message);
message_to_send = &converted_cbor_message; message_to_send = &converted_cbor_message;
} }
value = protocol::DictionaryValue::cast(
protocol::StringUtil::parseMessage(*message_to_send, true));
} }
std::unique_ptr<protocol::DictionaryValue> value =
protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage(
message, client_->UsesBinaryProtocol()));
std::string session_id; std::string session_id;
if (!value || !value->getString(kSessionId, &session_id)) if (!value || !value->getString(kSessionId, &session_id))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment