diff options
author | Aleksei Koziatinskii <ak239spb@gmail.com> | 2019-05-06 19:30:44 -0700 |
---|---|---|
committer | Aleksei Koziatinskii <alekseik@netflix.com> | 2019-05-14 16:13:57 -0700 |
commit | 10d7e01ee9618a42cb658a07d692557a03456fe5 (patch) | |
tree | b000e346fe579656d9d32cf2479faceedbb7e04b /src/inspector/runtime_agent.h | |
parent | 23ef3e4cfb8da65b205e6895947375e5284bebdc (diff) | |
download | android-node-v8-10d7e01ee9618a42cb658a07d692557a03456fe5.tar.gz android-node-v8-10d7e01ee9618a42cb658a07d692557a03456fe5.tar.bz2 android-node-v8-10d7e01ee9618a42cb658a07d692557a03456fe5.zip |
inspector: added NodeRuntime domain
Historically Node process sends Runtime.executionContextDestroyed
with main context as argument when it is finished.
This approach has some disadvantages. V8 prevents running some
protocol command on destroyed contexts, e.g. Runtime.evaluate
will return an error or Debugger.enable won't return a list of
scripts.
Both command might be useful for different tools, e.g. tool runs
Profiler.startPreciseCoverage and at the end of node process it
would like to get list of all scripts to match data to source code.
Or some tooling frontend would like to provide capabilities to run
commands in console when node process is finished to allow user to
inspect state of the program at exit.
This PR adds new domain: NodeRuntime. After
NodeRuntime.notifyWhenWaitingForDisconnect is enabled by at least one
client, node will send NodeRuntime.waitingForDebuggerToDisconnect
event instead of Runtime.executionContextDestroyed. Based on this
signal any protocol client can capture all required information and
then disconnect its session.
PR-URL: https://github.com/nodejs/node/pull/27600
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/inspector/runtime_agent.h')
-rw-r--r-- | src/inspector/runtime_agent.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/inspector/runtime_agent.h b/src/inspector/runtime_agent.h new file mode 100644 index 0000000000..63fc2a897c --- /dev/null +++ b/src/inspector/runtime_agent.h @@ -0,0 +1,32 @@ +#ifndef SRC_INSPECTOR_RUNTIME_AGENT_H_ +#define SRC_INSPECTOR_RUNTIME_AGENT_H_ + +#include "node/inspector/protocol/NodeRuntime.h" +#include "v8.h" + +namespace node { +class Environment; + +namespace inspector { +namespace protocol { + +class RuntimeAgent : public NodeRuntime::Backend { + public: + explicit RuntimeAgent(Environment* env); + + void Wire(UberDispatcher* dispatcher); + + DispatchResponse notifyWhenWaitingForDisconnect(bool enabled) override; + + bool notifyWaitingForDisconnect(); + + private: + std::shared_ptr<NodeRuntime::Frontend> frontend_; + bool notify_when_waiting_for_disconnect_; + Environment* env_; +}; +} // namespace protocol +} // namespace inspector +} // namespace node + +#endif // SRC_INSPECTOR_RUNTIME_AGENT_H_ |