summaryrefslogtreecommitdiff
path: root/src/inspector/node_string.cc
diff options
context:
space:
mode:
authorPavel Feldman <pfeldman@chromium.org>2019-02-25 12:43:13 -0800
committerRefael Ackermann <refack@gmail.com>2019-03-04 11:44:49 -0500
commitd775d74698e1b321580b1560fbcee7943750aedc (patch)
treee603e6285066de1e55a25397deef5edd41959887 /src/inspector/node_string.cc
parentb2abda9ba0b7b8bfbbf14e990ea86434f3f20de3 (diff)
downloadnode-new-d775d74698e1b321580b1560fbcee7943750aedc.tar.gz
tools: roll inspector_protocol to f67ec5
Fixes: https://github.com/nodejs/node/issues/25808 PR-URL: https://github.com/nodejs/node/pull/26303 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'src/inspector/node_string.cc')
-rw-r--r--src/inspector/node_string.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/inspector/node_string.cc b/src/inspector/node_string.cc
index cb9e90c20e..a79df9e817 100644
--- a/src/inspector/node_string.cc
+++ b/src/inspector/node_string.cc
@@ -85,6 +85,28 @@ double toDouble(const char* buffer, size_t length, bool* ok) {
return d;
}
+std::unique_ptr<Value> parseMessage(const std::string& 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;
+}
+
+ProtocolMessage binaryToMessage(std::vector<uint8_t> message) {
+ return std::string(reinterpret_cast<const char*>(message.data()),
+ message.size());
+}
+
+String fromUTF8(const uint8_t* data, size_t length) {
+ return std::string(reinterpret_cast<const char*>(data), length);
+}
+
} // namespace StringUtil
} // namespace protocol
} // namespace inspector