diff options
author | Sam Roberts <vieuxtech@gmail.com> | 2017-05-31 02:34:59 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-06-02 01:54:34 +0300 |
commit | 26ab769940e59646386bd15bbafb9378b8b56aed (patch) | |
tree | b2f6ff05c598326b065bc46cea59d71aca21dcd9 /src/inspector_agent.h | |
parent | ce5745bf92f586c58366e9f738441d69118f2c18 (diff) |
inspector: refactor to rename and comment methods
Pure refactor, makes no functional changes but the renaming helped me
see more clearly what the relationship was between methods and
variables.
* Renamed methods to reduce number of slightly different names for the
same thing ("thread" vs "io thread", etc.).
* Added comments where it was useful to me.
PR-URL: https://github.com/nodejs/node/pull/13321
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/inspector_agent.h')
-rw-r--r-- | src/inspector_agent.h | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/inspector_agent.h b/src/inspector_agent.h index 2bc65f76640..9966c02adfe 100644 --- a/src/inspector_agent.h +++ b/src/inspector_agent.h @@ -39,7 +39,8 @@ class InspectorSessionDelegate { public: virtual ~InspectorSessionDelegate() = default; virtual bool WaitForFrontendMessage() = 0; - virtual void OnMessage(const v8_inspector::StringView& message) = 0; + virtual void SendMessageToFrontend(const v8_inspector::StringView& message) + = 0; }; class InspectorIo; @@ -50,39 +51,53 @@ class Agent { explicit Agent(node::Environment* env); ~Agent(); + // Create client_, may create io_ if option enabled bool Start(v8::Platform* platform, const char* path, const DebugOptions& options); + // Stop and destroy io_ void Stop(); - bool IsStarted(); + bool IsStarted() { return !!client_; } + + // IO thread started, and client connected bool IsConnected(); + + void WaitForDisconnect(); void FatalException(v8::Local<v8::Value> error, v8::Local<v8::Message> message); + + // 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); - InspectorSessionDelegate* delegate(); void Disconnect(); void Dispatch(const v8_inspector::StringView& message); + InspectorSessionDelegate* delegate(); + void RunMessageLoop(); - bool enabled() { - return enabled_; - } + bool enabled() { return enabled_; } void PauseOnNextJavascriptStatement(const std::string& reason); - static void InitJSBindings(v8::Local<v8::Object> target, - v8::Local<v8::Value> unused, - v8::Local<v8::Context> context, - void* priv); - bool StartIoThread(bool wait_for_connect); + // Initialize 'inspector' module bindings + static void InitInspector(v8::Local<v8::Object> target, + v8::Local<v8::Value> unused, + v8::Local<v8::Context> context, + void* priv); + InspectorIo* io() { return io_.get(); } - // Can be called from any thread - void RequestIoStart(); + + // Can only be called from the the main thread. + bool StartIoThread(bool wait_for_connect); + + // Calls StartIoThread() from off the main thread. + void RequestIoThreadStart(); private: node::Environment* parent_env_; - std::unique_ptr<NodeInspectorClient> inspector_; + std::unique_ptr<NodeInspectorClient> client_; std::unique_ptr<InspectorIo> io_; v8::Platform* platform_; bool enabled_; |