diff options
author | Eugene Ostroukhov <eostroukhov@chromium.org> | 2016-11-18 13:52:22 -0800 |
---|---|---|
committer | Eugene Ostroukhov <eostroukhov@chromium.org> | 2016-12-09 09:07:50 -0800 |
commit | f9aadfbc5adb3b9ee9357636d846dff1556b9acc (patch) | |
tree | 7ec6dded7ce804ac4069d56826cbd55593c9a450 /src/inspector_agent.cc | |
parent | bc335c0a8d68164fd978192409ab6c4986cfe374 (diff) | |
download | android-node-v8-f9aadfbc5adb3b9ee9357636d846dff1556b9acc.tar.gz android-node-v8-f9aadfbc5adb3b9ee9357636d846dff1556b9acc.tar.bz2 android-node-v8-f9aadfbc5adb3b9ee9357636d846dff1556b9acc.zip |
inspector: move options parsing
As inspector functionality expands, more options will need to be added.
Currently this requires changing adding function arguments, etc. This
change packs the veriables into a single class that can be extended
without changing APIs.
PR-URL: https://github.com/nodejs/node/pull/9691
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/inspector_agent.cc')
-rw-r--r-- | src/inspector_agent.cc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index fc478c49a0..aeb8339332 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -132,7 +132,8 @@ class AgentImpl { ~AgentImpl(); // Start the inspector agent thread - bool Start(v8::Platform* platform, const char* path, int port, bool wait); + bool Start(v8::Platform* platform, const char* path, + const DebugOptions& options); // Stop the inspector agent void Stop(); @@ -169,6 +170,7 @@ class AgentImpl { void NotifyMessageReceived(); State ToState(State state); + DebugOptions options_; uv_sem_t start_sem_; ConditionVariable incoming_message_cond_; Mutex state_lock_; @@ -176,8 +178,6 @@ class AgentImpl { uv_loop_t child_loop_; InspectorAgentDelegate* delegate_; - - int port_; bool wait_; bool shutting_down_; State state_; @@ -194,6 +194,8 @@ class AgentImpl { InspectorSocketServer* server_; std::string script_name_; + std::string script_path_; + const std::string id_; friend class ChannelImpl; friend class DispatchOnInspectorBackendTask; @@ -318,7 +320,6 @@ class V8NodeInspector : public v8_inspector::V8InspectorClient { }; AgentImpl::AgentImpl(Environment* env) : delegate_(nullptr), - port_(0), wait_(false), shutting_down_(false), state_(State::kNew), @@ -409,7 +410,10 @@ void InspectorWrapConsoleCall(const v8::FunctionCallbackInfo<v8::Value>& args) { } bool AgentImpl::Start(v8::Platform* platform, const char* path, - int port, bool wait) { + const DebugOptions& options) { + options_ = options; + wait_ = options.wait_for_connect(); + auto env = parent_env_; inspector_ = new V8NodeInspector(this, env, platform); platform_ = platform; @@ -421,9 +425,6 @@ bool AgentImpl::Start(v8::Platform* platform, const char* path, int err = uv_loop_init(&child_loop_); CHECK_EQ(err, 0); - port_ = port; - wait_ = wait; - err = uv_thread_create(&thread_, AgentImpl::ThreadCbIO, this); CHECK_EQ(err, 0); uv_sem_wait(&start_sem_); @@ -433,7 +434,7 @@ bool AgentImpl::Start(v8::Platform* platform, const char* path, return false; } state_ = State::kAccepting; - if (wait) { + if (options_.wait_for_connect()) { DispatchMessages(); } return true; @@ -561,7 +562,7 @@ void AgentImpl::WorkerRunIO() { } InspectorAgentDelegate delegate(this, script_path, script_name_, wait_); delegate_ = &delegate; - InspectorSocketServer server(&delegate, port_); + InspectorSocketServer server(&delegate, options_.port()); if (!server.Start(&child_loop_)) { fprintf(stderr, "Unable to open devtools socket: %s\n", uv_strerror(err)); state_ = State::kError; // Safe, main thread is waiting on semaphore @@ -681,8 +682,8 @@ Agent::~Agent() { } bool Agent::Start(v8::Platform* platform, const char* path, - int port, bool wait) { - return impl->Start(platform, path, port, wait); + const DebugOptions& options) { + return impl->Start(platform, path, options); } void Agent::Stop() { |