diff options
author | Eugene Ostroukhov <eostroukhov@chromium.org> | 2018-04-24 11:16:55 -0700 |
---|---|---|
committer | Eugene Ostroukhov <eostroukhov@google.com> | 2018-04-26 12:48:48 -0700 |
commit | 13001035340d6d3fb173fef4a1db42ba70f61720 (patch) | |
tree | 7333699fc80f90725a00b229dccc5bf718cfea78 /src/inspector_agent.h | |
parent | 5c57cea8049bad5939807e6b849ee303ec8e1526 (diff) | |
download | android-node-v8-13001035340d6d3fb173fef4a1db42ba70f61720.tar.gz android-node-v8-13001035340d6d3fb173fef4a1db42ba70f61720.tar.bz2 android-node-v8-13001035340d6d3fb173fef4a1db42ba70f61720.zip |
inspector: allow concurrent inspector sessions
This change enables concurrent inspector sessions, through WebSocket
interface as well as JS interface, in any combination.
PR-URL: https://github.com/nodejs/node/pull/20137
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/inspector_agent.h')
-rw-r--r-- | src/inspector_agent.h | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/inspector_agent.h b/src/inspector_agent.h index 56fb407930..64e4202ee8 100644 --- a/src/inspector_agent.h +++ b/src/inspector_agent.h @@ -23,18 +23,26 @@ class Environment; struct ContextInfo; namespace inspector { +class InspectorIo; +class NodeInspectorClient; + +class InspectorSession { + public: + InspectorSession(int session_id, std::shared_ptr<NodeInspectorClient> client); + ~InspectorSession(); + void Dispatch(const v8_inspector::StringView& message); + private: + int session_id_; + std::shared_ptr<NodeInspectorClient> client_; +}; class InspectorSessionDelegate { public: virtual ~InspectorSessionDelegate() = default; - virtual bool WaitForFrontendMessageWhilePaused() = 0; virtual void SendMessageToFrontend(const v8_inspector::StringView& message) = 0; }; -class InspectorIo; -class NodeInspectorClient; - class Agent { public: explicit Agent(node::Environment* env); @@ -66,19 +74,19 @@ class Agent { void RegisterAsyncHook(v8::Isolate* isolate, v8::Local<v8::Function> enable_function, v8::Local<v8::Function> disable_function); + void EnableAsyncHook(); + void DisableAsyncHook(); - // These methods are called by the WS protocol and JS binding to create - // inspector sessions. The inspector responds by using the delegate to send - // messages back. - void Connect(InspectorSessionDelegate* delegate); - void Disconnect(); - void Dispatch(const v8_inspector::StringView& message); - InspectorSessionDelegate* delegate(); + // Called by the WS protocol and JS binding to create inspector sessions. + // The inspector responds by using the delegate to send messages back. + std::unique_ptr<InspectorSession> Connect( + std::unique_ptr<InspectorSessionDelegate> delegate); - void RunMessageLoop(); - bool enabled() { return enabled_; } void PauseOnNextJavascriptStatement(const std::string& reason); + // Returns true as long as there is at least one connected session. + bool HasConnectedSessions(); + InspectorIo* io() { return io_.get(); } @@ -92,18 +100,14 @@ class Agent { DebugOptions& options() { return debug_options_; } void ContextCreated(v8::Local<v8::Context> context, const ContextInfo& info); - void EnableAsyncHook(); - void DisableAsyncHook(); - private: void ToggleAsyncHook(v8::Isolate* isolate, const Persistent<v8::Function>& fn); node::Environment* parent_env_; - std::unique_ptr<NodeInspectorClient> client_; + std::shared_ptr<NodeInspectorClient> client_; std::unique_ptr<InspectorIo> io_; v8::Platform* platform_; - bool enabled_; std::string path_; DebugOptions debug_options_; |