Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-05-02 15:41:54 +0300
committerRich Trott <rtrott@gmail.com>2019-05-05 20:19:14 +0300
commit0171bab46d6f57cf6b1ba89d4a79a022139937d1 (patch)
tree8ebd754a1aa9fe4dc043d9a4c66b3d1adeb8e9cb /src/inspector_profiler.h
parent3d98051e207324353c462b1f53ee0e8fe262297d (diff)
src: refactor V8ProfilerConnection::DispatchMessage()
- Auto-generate the message id and return it for future use (we can always parse the response to find the message containing the profile instead of relying on the inspector connection being synchornous). - Generate the message from method and parameter strings and create a `StringView` directly to avoid the unnecessary copy in `ToProtocolString()`. PR-URL: https://github.com/nodejs/node/pull/27535 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/inspector_profiler.h')
-rw-r--r--src/inspector_profiler.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/inspector_profiler.h b/src/inspector_profiler.h
index cbe053e578c..219405b8c7f 100644
--- a/src/inspector_profiler.h
+++ b/src/inspector_profiler.h
@@ -34,7 +34,13 @@ class V8ProfilerConnection {
virtual ~V8ProfilerConnection() = default;
Environment* env() const { return env_; }
- void DispatchMessage(v8::Local<v8::String> message);
+
+ // Dispatch a protocol message, and returns the id of the message.
+ // `method` does not need to be surrounded by quotes.
+ // The optional `params` should be formatted in JSON.
+ // The strings should be in one byte characters - which is enough for
+ // the commands we use here.
+ size_t DispatchMessage(const char* method, const char* params = nullptr);
// Use DispatchMessage() to dispatch necessary inspector messages
// to start and end the profiling.
@@ -55,9 +61,11 @@ class V8ProfilerConnection {
v8::Local<v8::Object> result) = 0;
private:
+ size_t next_id() { return id_++; }
void WriteProfile(v8::Local<v8::String> message);
std::unique_ptr<inspector::InspectorSession> session_;
Environment* env_ = nullptr;
+ size_t id_ = 1;
};
class V8CoverageConnection : public V8ProfilerConnection {