diff options
author | Eugene Ostroukhov <eostroukhov@google.com> | 2017-04-24 10:06:17 -0700 |
---|---|---|
committer | Eugene Ostroukhov <eostroukhov@chromium.org> | 2017-08-11 11:25:31 -0700 |
commit | 63fc89a6a05f7ef8475fc509aa278777c297f460 (patch) | |
tree | 27c48ecf48b59c195c4e65bb561b572eb469c077 /src/inspector_agent.cc | |
parent | 73c59bbbf9bd2a53ab322cb822ae718fabef7b6c (diff) | |
download | android-node-v8-63fc89a6a05f7ef8475fc509aa278777c297f460.tar.gz android-node-v8-63fc89a6a05f7ef8475fc509aa278777c297f460.tar.bz2 android-node-v8-63fc89a6a05f7ef8475fc509aa278777c297f460.zip |
inspector: support extra contexts
This enables inspector support for contexts created using the vm module.
PR-URL: https://github.com/nodejs/node/pull/14465
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Diffstat (limited to 'src/inspector_agent.cc')
-rw-r--r-- | src/inspector_agent.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index bedf74f3b0..0f9caa32f2 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -12,6 +12,7 @@ #include "libplatform/libplatform.h" #include <string.h> +#include <sstream> #include <unordered_map> #include <vector> @@ -500,6 +501,7 @@ class NodeInspectorClient : public V8InspectorClient { terminated_(false), running_nested_loop_(false) { client_ = V8Inspector::create(env->isolate(), this); + contextCreated(env->context(), "Node.js Main Context"); } void runMessageLoopOnPause(int context_group_id) override { @@ -627,7 +629,8 @@ class NodeInspectorClient : public V8InspectorClient { Agent::Agent(Environment* env) : parent_env_(env), client_(nullptr), platform_(nullptr), - enabled_(false) {} + enabled_(false), + next_context_number_(1) {} // Destructor needs to be defined here in implementation file as the header // does not have full definition of some classes. @@ -641,7 +644,6 @@ bool Agent::Start(v8::Platform* platform, const char* path, client_ = std::unique_ptr<NodeInspectorClient>( new NodeInspectorClient(parent_env_, platform)); - client_->contextCreated(parent_env_->context(), "Node.js Main Context"); platform_ = platform; CHECK_EQ(0, uv_async_init(uv_default_loop(), &start_io_thread_async, @@ -841,6 +843,14 @@ void Agent::RequestIoThreadStart() { uv_async_send(&start_io_thread_async); } +void Agent::ContextCreated(Local<Context> context) { + if (client_ == nullptr) // This happens for a main context + return; + std::ostringstream name; + name << "VM Context " << next_context_number_++; + client_->contextCreated(context, name.str()); +} + } // namespace inspector } // namespace node |