@@ -132,7 +132,8 @@ class AgentImpl {
132
132
~AgentImpl ();
133
133
134
134
// 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);
136
137
// Stop the inspector agent
137
138
void Stop ();
138
139
@@ -169,15 +170,14 @@ class AgentImpl {
169
170
void NotifyMessageReceived ();
170
171
State ToState (State state);
171
172
173
+ DebugOptions options_;
172
174
uv_sem_t start_sem_;
173
175
ConditionVariable incoming_message_cond_;
174
176
Mutex state_lock_;
175
177
uv_thread_t thread_;
176
178
uv_loop_t child_loop_;
177
179
178
180
InspectorAgentDelegate* delegate_;
179
-
180
- int port_;
181
181
bool wait_;
182
182
bool shutting_down_;
183
183
State state_;
@@ -194,6 +194,8 @@ class AgentImpl {
194
194
InspectorSocketServer* server_;
195
195
196
196
std::string script_name_;
197
+ std::string script_path_;
198
+ const std::string id_;
197
199
198
200
friend class ChannelImpl ;
199
201
friend class DispatchOnInspectorBackendTask ;
@@ -318,7 +320,6 @@ class V8NodeInspector : public v8_inspector::V8InspectorClient {
318
320
};
319
321
320
322
AgentImpl::AgentImpl (Environment* env) : delegate_(nullptr ),
321
- port_(0 ),
322
323
wait_(false ),
323
324
shutting_down_(false ),
324
325
state_(State::kNew ),
@@ -409,7 +410,10 @@ void InspectorWrapConsoleCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
409
410
}
410
411
411
412
bool 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
+
413
417
auto env = parent_env_;
414
418
inspector_ = new V8NodeInspector (this , env, platform);
415
419
platform_ = platform;
@@ -421,9 +425,6 @@ bool AgentImpl::Start(v8::Platform* platform, const char* path,
421
425
int err = uv_loop_init (&child_loop_);
422
426
CHECK_EQ (err, 0 );
423
427
424
- port_ = port;
425
- wait_ = wait;
426
-
427
428
err = uv_thread_create (&thread_, AgentImpl::ThreadCbIO, this );
428
429
CHECK_EQ (err, 0 );
429
430
uv_sem_wait (&start_sem_);
@@ -433,7 +434,7 @@ bool AgentImpl::Start(v8::Platform* platform, const char* path,
433
434
return false ;
434
435
}
435
436
state_ = State::kAccepting ;
436
- if (wait ) {
437
+ if (options_. wait_for_connect () ) {
437
438
DispatchMessages ();
438
439
}
439
440
return true ;
@@ -561,7 +562,7 @@ void AgentImpl::WorkerRunIO() {
561
562
}
562
563
InspectorAgentDelegate delegate (this , script_path, script_name_, wait_);
563
564
delegate_ = &delegate;
564
- InspectorSocketServer server (&delegate, port_ );
565
+ InspectorSocketServer server (&delegate, options_. port () );
565
566
if (!server.Start (&child_loop_)) {
566
567
fprintf (stderr, " Unable to open devtools socket: %s\n " , uv_strerror (err));
567
568
state_ = State::kError ; // Safe, main thread is waiting on semaphore
@@ -681,8 +682,8 @@ Agent::~Agent() {
681
682
}
682
683
683
684
bool 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 );
686
687
}
687
688
688
689
void Agent::Stop () {
0 commit comments