@@ -132,7 +132,8 @@ class AgentImpl {
132132 ~AgentImpl ();
133133
134134 // Start the inspector agent thread
135- bool Start (v8::Platform* platform, const char * path, int port, bool wait);
135+ bool Start (v8::Platform* platform, const char * path,
136+ const DebugOptions& options);
136137 // Stop the inspector agent
137138 void Stop ();
138139
@@ -169,15 +170,14 @@ class AgentImpl {
169170 void NotifyMessageReceived ();
170171 State ToState (State state);
171172
173+ DebugOptions options_;
172174 uv_sem_t start_sem_;
173175 ConditionVariable incoming_message_cond_;
174176 Mutex state_lock_;
175177 uv_thread_t thread_;
176178 uv_loop_t child_loop_;
177179
178180 InspectorAgentDelegate* delegate_;
179-
180- int port_;
181181 bool wait_;
182182 bool shutting_down_;
183183 State state_;
@@ -194,6 +194,8 @@ class AgentImpl {
194194 InspectorSocketServer* server_;
195195
196196 std::string script_name_;
197+ std::string script_path_;
198+ const std::string id_;
197199
198200 friend class ChannelImpl ;
199201 friend class DispatchOnInspectorBackendTask ;
@@ -318,7 +320,6 @@ class V8NodeInspector : public v8_inspector::V8InspectorClient {
318320};
319321
320322AgentImpl::AgentImpl (Environment* env) : delegate_(nullptr ),
321- port_(0 ),
322323 wait_(false ),
323324 shutting_down_(false ),
324325 state_(State::kNew ),
@@ -409,7 +410,10 @@ void InspectorWrapConsoleCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
409410}
410411
411412bool AgentImpl::Start (v8::Platform* platform, const char * path,
412- int port, bool wait) {
413+ const DebugOptions& options) {
414+ options_ = options;
415+ wait_ = options.wait_for_connect ();
416+
413417 auto env = parent_env_;
414418 inspector_ = new V8NodeInspector (this , env, platform);
415419 platform_ = platform;
@@ -421,9 +425,6 @@ bool AgentImpl::Start(v8::Platform* platform, const char* path,
421425 int err = uv_loop_init (&child_loop_);
422426 CHECK_EQ (err, 0 );
423427
424- port_ = port;
425- wait_ = wait;
426-
427428 err = uv_thread_create (&thread_, AgentImpl::ThreadCbIO, this );
428429 CHECK_EQ (err, 0 );
429430 uv_sem_wait (&start_sem_);
@@ -433,7 +434,7 @@ bool AgentImpl::Start(v8::Platform* platform, const char* path,
433434 return false ;
434435 }
435436 state_ = State::kAccepting ;
436- if (wait ) {
437+ if (options_. wait_for_connect () ) {
437438 DispatchMessages ();
438439 }
439440 return true ;
@@ -561,7 +562,7 @@ void AgentImpl::WorkerRunIO() {
561562 }
562563 InspectorAgentDelegate delegate (this , script_path, script_name_, wait_);
563564 delegate_ = &delegate;
564- InspectorSocketServer server (&delegate, port_ );
565+ InspectorSocketServer server (&delegate, options_. port () );
565566 if (!server.Start (&child_loop_)) {
566567 fprintf (stderr, " Unable to open devtools socket: %s\n " , uv_strerror (err));
567568 state_ = State::kError ; // Safe, main thread is waiting on semaphore
@@ -681,8 +682,8 @@ Agent::~Agent() {
681682}
682683
683684bool Agent::Start (v8::Platform* platform, const char * path,
684- int port, bool wait ) {
685- return impl->Start (platform, path, port, wait );
685+ const DebugOptions& options ) {
686+ return impl->Start (platform, path, options );
686687}
687688
688689void Agent::Stop () {
0 commit comments