diff options
Diffstat (limited to 'src/inspector_agent.h')
-rw-r--r-- | src/inspector_agent.h | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/inspector_agent.h b/src/inspector_agent.h index 7295d048b6..dcd6e13aba 100644 --- a/src/inspector_agent.h +++ b/src/inspector_agent.h @@ -20,7 +20,6 @@ class StringView; namespace node { // Forward declaration to break recursive dependency chain with src/env.h. class Environment; -class NodePlatform; struct ContextInfo; namespace inspector { @@ -29,12 +28,8 @@ 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_; + virtual ~InspectorSession() {} + virtual void Dispatch(const v8_inspector::StringView& message) = 0; }; class InspectorSessionDelegate { @@ -50,15 +45,21 @@ class Agent { ~Agent(); // Create client_, may create io_ if option enabled - bool Start(const char* path, const DebugOptions& options); + bool Start(const std::string& path, const DebugOptions& options); // Stop and destroy io_ void Stop(); - bool IsStarted() { return !!client_; } - - // IO thread started, and client connected - bool IsWaitingForConnect(); - + bool IsListening() { return io_ != nullptr; } + // Returns true if the Node inspector is actually in use. It will be true + // if either the user explicitely opted into inspector (e.g. with the + // --inspect command line flag) or if inspector JS API had been used. + bool IsActive(); + + // Option is set to wait for session connection + bool WillWaitForConnect(); + // Blocks till frontend connects and sends "runIfWaitingForDebugger" + void WaitForConnect(); + // Blocks till all the sessions with "WaitForDisconnectOnShutdown" disconnect void WaitForDisconnect(); void FatalException(v8::Local<v8::Value> error, v8::Local<v8::Message> message); @@ -77,22 +78,20 @@ class Agent { void EnableAsyncHook(); void DisableAsyncHook(); - // Called by the WS protocol and JS binding to create inspector sessions. + // Called to create inspector sessions that can be used from the main thread. // The inspector responds by using the delegate to send messages back. std::unique_ptr<InspectorSession> Connect( - std::unique_ptr<InspectorSessionDelegate> delegate); + std::unique_ptr<InspectorSessionDelegate> delegate, + bool prevent_shutdown); 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(); } // Can only be called from the main thread. - bool StartIoThread(bool wait_for_connect); + bool StartIoThread(); // Calls StartIoThread() from off the main thread. void RequestIoThreadStart(); @@ -105,7 +104,9 @@ class Agent { const node::Persistent<v8::Function>& fn); node::Environment* parent_env_; + // Encapsulates majority of the Inspector functionality std::shared_ptr<NodeInspectorClient> client_; + // Interface for transports, e.g. WebSocket server std::unique_ptr<InspectorIo> io_; std::string path_; DebugOptions debug_options_; |