OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if !defined(_WIN32) && !defined(_WIN64) | 5 #if !defined(_WIN32) && !defined(_WIN64) |
6 #include <unistd.h> // NOLINT | 6 #include <unistd.h> // NOLINT |
7 #endif // !defined(_WIN32) && !defined(_WIN64) | 7 #endif // !defined(_WIN32) && !defined(_WIN64) |
8 | 8 |
9 #include <locale.h> | 9 #include <locale.h> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 v8::internal::Vector<uint16_t>::New(str->Length()); | 44 v8::internal::Vector<uint16_t>::New(str->Length()); |
45 str->Write(buffer.start(), 0, str->Length()); | 45 str->Write(buffer.start(), 0, str->Length()); |
46 return buffer; | 46 return buffer; |
47 } | 47 } |
48 | 48 |
49 v8::Local<v8::String> ToV8String(v8::Isolate* isolate, const char* str) { | 49 v8::Local<v8::String> ToV8String(v8::Isolate* isolate, const char* str) { |
50 return v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kNormal) | 50 return v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kNormal) |
51 .ToLocalChecked(); | 51 .ToLocalChecked(); |
52 } | 52 } |
53 | 53 |
54 class UtilsExtension : public TaskRunner::Task { | 54 class UtilsExtension : public TaskRunner::SetupGlobalTask { |
55 public: | 55 public: |
56 ~UtilsExtension() override = default; | 56 ~UtilsExtension() override = default; |
57 bool is_inspector_task() override { return true; } | |
58 void Run(v8::Isolate* isolate, | 57 void Run(v8::Isolate* isolate, |
59 const v8::Global<v8::Context>& context) override { | 58 v8::Local<v8::ObjectTemplate> global) override { |
60 v8::HandleScope handle_scope(isolate); | |
61 v8::Local<v8::Context> local_context = context.Get(isolate); | |
62 v8::Context::Scope context_scope(local_context); | |
63 v8::Local<v8::ObjectTemplate> utils = v8::ObjectTemplate::New(isolate); | 59 v8::Local<v8::ObjectTemplate> utils = v8::ObjectTemplate::New(isolate); |
64 utils->Set(ToV8String(isolate, "print"), | 60 utils->Set(ToV8String(isolate, "print"), |
65 v8::FunctionTemplate::New(isolate, &UtilsExtension::Print)); | 61 v8::FunctionTemplate::New(isolate, &UtilsExtension::Print)); |
66 utils->Set(ToV8String(isolate, "quit"), | 62 utils->Set(ToV8String(isolate, "quit"), |
67 v8::FunctionTemplate::New(isolate, &UtilsExtension::Quit)); | 63 v8::FunctionTemplate::New(isolate, &UtilsExtension::Quit)); |
68 utils->Set(ToV8String(isolate, "setlocale"), | 64 utils->Set(ToV8String(isolate, "setlocale"), |
69 v8::FunctionTemplate::New(isolate, &UtilsExtension::Setlocale)); | 65 v8::FunctionTemplate::New(isolate, &UtilsExtension::Setlocale)); |
70 utils->Set(ToV8String(isolate, "read"), | 66 utils->Set(ToV8String(isolate, "read"), |
71 v8::FunctionTemplate::New(isolate, &UtilsExtension::Read)); | 67 v8::FunctionTemplate::New(isolate, &UtilsExtension::Read)); |
72 utils->Set(ToV8String(isolate, "load"), | 68 utils->Set(ToV8String(isolate, "load"), |
(...skipping 14 matching lines...) Expand all Loading... | |
87 v8::FunctionTemplate::New( | 83 v8::FunctionTemplate::New( |
88 isolate, &UtilsExtension::CancelPauseOnNextStatement)); | 84 isolate, &UtilsExtension::CancelPauseOnNextStatement)); |
89 utils->Set(ToV8String(isolate, "reconnect"), | 85 utils->Set(ToV8String(isolate, "reconnect"), |
90 v8::FunctionTemplate::New(isolate, &UtilsExtension::Reconnect)); | 86 v8::FunctionTemplate::New(isolate, &UtilsExtension::Reconnect)); |
91 utils->Set(ToV8String(isolate, "setLogConsoleApiMessageCalls"), | 87 utils->Set(ToV8String(isolate, "setLogConsoleApiMessageCalls"), |
92 v8::FunctionTemplate::New( | 88 v8::FunctionTemplate::New( |
93 isolate, &UtilsExtension::SetLogConsoleApiMessageCalls)); | 89 isolate, &UtilsExtension::SetLogConsoleApiMessageCalls)); |
94 utils->Set(ToV8String(isolate, "createContextGroup"), | 90 utils->Set(ToV8String(isolate, "createContextGroup"), |
95 v8::FunctionTemplate::New(isolate, | 91 v8::FunctionTemplate::New(isolate, |
96 &UtilsExtension::CreateContextGroup)); | 92 &UtilsExtension::CreateContextGroup)); |
97 local_context->Global() | 93 global->Set(ToV8String(isolate, "utils"), utils); |
98 ->Set(local_context, ToV8String(isolate, "utils"), | |
99 utils->NewInstance(local_context).ToLocalChecked()) | |
100 .ToChecked(); | |
101 } | 94 } |
102 | 95 |
103 static void set_backend_task_runner(TaskRunner* runner) { | 96 static void set_backend_task_runner(TaskRunner* runner) { |
104 backend_runner_ = runner; | 97 backend_runner_ = runner; |
105 } | 98 } |
106 | 99 |
107 static void set_inspector_client(InspectorClientImpl* client) { | 100 static void set_inspector_client(InspectorClientImpl* client) { |
108 inspector_client_ = client; | 101 inspector_client_ = client; |
109 } | 102 } |
110 | 103 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 const v8::FunctionCallbackInfo<v8::Value>& args) { | 268 const v8::FunctionCallbackInfo<v8::Value>& args) { |
276 if (args.Length() != 1 || !args[0]->IsBoolean()) { | 269 if (args.Length() != 1 || !args[0]->IsBoolean()) { |
277 fprintf(stderr, "Internal error: setLogConsoleApiMessageCalls(bool)."); | 270 fprintf(stderr, "Internal error: setLogConsoleApiMessageCalls(bool)."); |
278 Exit(); | 271 Exit(); |
279 } | 272 } |
280 inspector_client_->setLogConsoleApiMessageCalls( | 273 inspector_client_->setLogConsoleApiMessageCalls( |
281 args[0].As<v8::Boolean>()->Value()); | 274 args[0].As<v8::Boolean>()->Value()); |
282 } | 275 } |
283 | 276 |
284 static void CreateContextGroup( | 277 static void CreateContextGroup( |
285 const v8::FunctionCallbackInfo<v8::Value>& args) { | 278 const v8::FunctionCallbackInfo<v8::Value>& args); |
286 if (args.Length() != 0) { | |
287 fprintf(stderr, "Internal error: createContextGroup()."); | |
288 Exit(); | |
289 } | |
290 const char* backend_extensions[] = {"v8_inspector/setTimeout", | |
291 "v8_inspector/inspector"}; | |
292 v8::ExtensionConfiguration backend_configuration( | |
293 arraysize(backend_extensions), backend_extensions); | |
294 v8::base::Semaphore ready_semaphore(0); | |
295 int context_group_id = 0; | |
296 inspector_client_->scheduleCreateContextGroup( | |
297 &backend_configuration, &ready_semaphore, &context_group_id); | |
298 ready_semaphore.Wait(); | |
299 args.GetReturnValue().Set( | |
300 v8::Int32::New(args.GetIsolate(), context_group_id)); | |
301 } | |
302 }; | 279 }; |
303 | 280 |
304 TaskRunner* UtilsExtension::backend_runner_ = nullptr; | 281 TaskRunner* UtilsExtension::backend_runner_ = nullptr; |
305 InspectorClientImpl* UtilsExtension::inspector_client_ = nullptr; | 282 InspectorClientImpl* UtilsExtension::inspector_client_ = nullptr; |
306 | 283 |
307 class SetTimeoutTask : public AsyncTask { | 284 class SetTimeoutTask : public AsyncTask { |
308 public: | 285 public: |
309 SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function, | 286 SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function, |
310 const char* task_name, v8_inspector::V8Inspector* inspector) | 287 const char* task_name, v8_inspector::V8Inspector* inspector) |
311 : AsyncTask(task_name, inspector), function_(isolate, function) {} | 288 : AsyncTask(task_name, inspector), function_(isolate, function) {} |
(...skipping 11 matching lines...) Expand all Loading... | |
323 | 300 |
324 v8::Local<v8::Function> function = function_.Get(isolate); | 301 v8::Local<v8::Function> function = function_.Get(isolate); |
325 v8::MaybeLocal<v8::Value> result; | 302 v8::MaybeLocal<v8::Value> result; |
326 result = function->Call(context, context->Global(), 0, nullptr); | 303 result = function->Call(context, context->Global(), 0, nullptr); |
327 } | 304 } |
328 | 305 |
329 private: | 306 private: |
330 v8::Global<v8::Function> function_; | 307 v8::Global<v8::Function> function_; |
331 }; | 308 }; |
332 | 309 |
333 class SetTimeoutExtension : public v8::Extension { | 310 class SetTimeoutExtension : public TaskRunner::SetupGlobalTask { |
334 public: | 311 public: |
335 SetTimeoutExtension() | 312 void Run(v8::Isolate* isolate, |
336 : v8::Extension("v8_inspector/setTimeout", | 313 v8::Local<v8::ObjectTemplate> global) override { |
337 "native function setTimeout();") {} | 314 global->Set( |
338 | 315 ToV8String(isolate, "setTimeout"), |
339 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 316 v8::FunctionTemplate::New(isolate, &SetTimeoutExtension::SetTimeout)); |
340 v8::Isolate* isolate, v8::Local<v8::String> name) { | |
341 return v8::FunctionTemplate::New(isolate, SetTimeoutExtension::SetTimeout); | |
342 } | 317 } |
343 | 318 |
344 private: | 319 private: |
345 static void SetTimeout(const v8::FunctionCallbackInfo<v8::Value>& args) { | 320 static void SetTimeout(const v8::FunctionCallbackInfo<v8::Value>& args) { |
346 if (args.Length() != 2 || !args[1]->IsNumber() || | 321 if (args.Length() != 2 || !args[1]->IsNumber() || |
347 (!args[0]->IsFunction() && !args[0]->IsString()) || | 322 (!args[0]->IsFunction() && !args[0]->IsString()) || |
348 args[1].As<v8::Number>()->Value() != 0.0) { | 323 args[1].As<v8::Number>()->Value() != 0.0) { |
349 fprintf(stderr, | 324 fprintf(stderr, |
350 "Internal error: only setTimeout(function, 0) is supported."); | 325 "Internal error: only setTimeout(function, 0) is supported."); |
351 Exit(); | 326 Exit(); |
(...skipping 17 matching lines...) Expand all Loading... | |
369 } | 344 } |
370 }; | 345 }; |
371 | 346 |
372 bool StrictAccessCheck(v8::Local<v8::Context> accessing_context, | 347 bool StrictAccessCheck(v8::Local<v8::Context> accessing_context, |
373 v8::Local<v8::Object> accessed_object, | 348 v8::Local<v8::Object> accessed_object, |
374 v8::Local<v8::Value> data) { | 349 v8::Local<v8::Value> data) { |
375 CHECK(accessing_context.IsEmpty()); | 350 CHECK(accessing_context.IsEmpty()); |
376 return accessing_context.IsEmpty(); | 351 return accessing_context.IsEmpty(); |
377 } | 352 } |
378 | 353 |
379 class InspectorExtension : public v8::Extension { | 354 class InspectorExtension : public TaskRunner::SetupGlobalTask { |
380 public: | 355 public: |
381 InspectorExtension() | 356 ~InspectorExtension() override = default; |
382 : v8::Extension("v8_inspector/inspector", | 357 void Run(v8::Isolate* isolate, |
383 "native function attachInspector();" | 358 v8::Local<v8::ObjectTemplate> global) override { |
384 "native function detachInspector();" | 359 v8::Local<v8::ObjectTemplate> inspector = v8::ObjectTemplate::New(isolate); |
385 "native function setMaxAsyncTaskStacks();" | 360 inspector->Set( |
386 "native function dumpAsyncTaskStacksStateForTest();" | 361 ToV8String(isolate, "attachInspector"), |
387 "native function breakProgram();" | 362 v8::FunctionTemplate::New(isolate, &InspectorExtension::Attach)); |
388 "native function createObjectWithStrictCheck();" | 363 inspector->Set( |
389 "native function callWithScheduledBreak();" | 364 ToV8String(isolate, "detachInspector"), |
390 "native function allowAccessorFormatting();") {} | 365 v8::FunctionTemplate::New(isolate, &InspectorExtension::Detach)); |
391 | 366 inspector->Set(ToV8String(isolate, "setMaxAsyncTaskStacks"), |
392 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 367 v8::FunctionTemplate::New( |
393 v8::Isolate* isolate, v8::Local<v8::String> name) { | 368 isolate, &InspectorExtension::SetMaxAsyncTaskStacks)); |
394 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 369 inspector->Set( |
395 if (name->Equals(context, | 370 ToV8String(isolate, "dumpAsyncTaskStacksStateForTest"), |
396 v8::String::NewFromUtf8(isolate, "attachInspector", | 371 v8::FunctionTemplate::New( |
397 v8::NewStringType::kNormal) | 372 isolate, &InspectorExtension::DumpAsyncTaskStacksStateForTest)); |
398 .ToLocalChecked()) | 373 inspector->Set( |
399 .FromJust()) { | 374 ToV8String(isolate, "breakProgram"), |
400 return v8::FunctionTemplate::New(isolate, InspectorExtension::Attach); | 375 v8::FunctionTemplate::New(isolate, &InspectorExtension::BreakProgram)); |
401 } else if (name->Equals(context, | 376 inspector->Set( |
402 v8::String::NewFromUtf8(isolate, "detachInspector", | 377 ToV8String(isolate, "createObjectWithStrictCheck"), |
403 v8::NewStringType::kNormal) | 378 v8::FunctionTemplate::New( |
404 .ToLocalChecked()) | 379 isolate, &InspectorExtension::CreateObjectWithStrictCheck)); |
405 .FromJust()) { | 380 inspector->Set(ToV8String(isolate, "callWithScheduledBreak"), |
406 return v8::FunctionTemplate::New(isolate, InspectorExtension::Detach); | 381 v8::FunctionTemplate::New( |
407 } else if (name->Equals(context, v8::String::NewFromUtf8( | 382 isolate, &InspectorExtension::CallWithScheduledBreak)); |
408 isolate, "setMaxAsyncTaskStacks", | 383 inspector->Set(ToV8String(isolate, "allowAccessorFormatting"), |
409 v8::NewStringType::kNormal) | 384 v8::FunctionTemplate::New( |
410 .ToLocalChecked()) | 385 isolate, &InspectorExtension::AllowAccessorFormatting)); |
411 .FromJust()) { | 386 global->Set(ToV8String(isolate, "inspector"), inspector); |
412 return v8::FunctionTemplate::New( | |
413 isolate, InspectorExtension::SetMaxAsyncTaskStacks); | |
414 } else if (name->Equals(context, | |
415 v8::String::NewFromUtf8( | |
416 isolate, "dumpAsyncTaskStacksStateForTest", | |
417 v8::NewStringType::kNormal) | |
418 .ToLocalChecked()) | |
419 .FromJust()) { | |
420 return v8::FunctionTemplate::New( | |
421 isolate, InspectorExtension::DumpAsyncTaskStacksStateForTest); | |
422 } else if (name->Equals(context, | |
423 v8::String::NewFromUtf8(isolate, "breakProgram", | |
424 v8::NewStringType::kNormal) | |
425 .ToLocalChecked()) | |
426 .FromJust()) { | |
427 return v8::FunctionTemplate::New(isolate, | |
428 InspectorExtension::BreakProgram); | |
429 } else if (name->Equals(context, v8::String::NewFromUtf8( | |
430 isolate, "createObjectWithStrictCheck", | |
431 v8::NewStringType::kNormal) | |
432 .ToLocalChecked()) | |
433 .FromJust()) { | |
434 return v8::FunctionTemplate::New( | |
435 isolate, InspectorExtension::CreateObjectWithStrictCheck); | |
436 } else if (name->Equals(context, v8::String::NewFromUtf8( | |
437 isolate, "callWithScheduledBreak", | |
438 v8::NewStringType::kNormal) | |
439 .ToLocalChecked()) | |
440 .FromJust()) { | |
441 return v8::FunctionTemplate::New( | |
442 isolate, InspectorExtension::CallWithScheduledBreak); | |
443 } else if (name->Equals(context, v8::String::NewFromUtf8( | |
444 isolate, "allowAccessorFormatting", | |
445 v8::NewStringType::kNormal) | |
446 .ToLocalChecked()) | |
447 .FromJust()) { | |
448 return v8::FunctionTemplate::New( | |
449 isolate, InspectorExtension::AllowAccessorFormatting); | |
450 } | |
451 return v8::Local<v8::FunctionTemplate>(); | |
452 } | 387 } |
453 | 388 |
454 private: | 389 private: |
455 static void Attach(const v8::FunctionCallbackInfo<v8::Value>& args) { | 390 static void Attach(const v8::FunctionCallbackInfo<v8::Value>& args) { |
456 v8::Isolate* isolate = args.GetIsolate(); | 391 v8::Isolate* isolate = args.GetIsolate(); |
457 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 392 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
458 v8_inspector::V8Inspector* inspector = | 393 v8_inspector::V8Inspector* inspector = |
459 InspectorClientImpl::InspectorFromContext(context); | 394 InspectorClientImpl::InspectorFromContext(context); |
460 if (!inspector) { | 395 if (!inspector) { |
461 fprintf(stderr, "Inspector client not found - cannot attach!"); | 396 fprintf(stderr, "Inspector client not found - cannot attach!"); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 isolate, v8::String::NewFromUtf8(isolate, "allowAccessorFormatting", | 506 isolate, v8::String::NewFromUtf8(isolate, "allowAccessorFormatting", |
572 v8::NewStringType::kNormal) | 507 v8::NewStringType::kNormal) |
573 .ToLocalChecked()); | 508 .ToLocalChecked()); |
574 object | 509 object |
575 ->SetPrivate(isolate->GetCurrentContext(), shouldFormatAccessorsPrivate, | 510 ->SetPrivate(isolate->GetCurrentContext(), shouldFormatAccessorsPrivate, |
576 v8::Null(isolate)) | 511 v8::Null(isolate)) |
577 .ToChecked(); | 512 .ToChecked(); |
578 } | 513 } |
579 }; | 514 }; |
580 | 515 |
516 void UtilsExtension::CreateContextGroup( | |
dgozman
2017/04/21 23:10:44
Inline this back into place.
kozy
2017/04/21 23:16:54
It uses SetTimeoutExtension and InspectorExtension
| |
517 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
518 if (args.Length() != 0) { | |
519 fprintf(stderr, "Internal error: createContextGroup()."); | |
520 Exit(); | |
521 } | |
522 v8::base::Semaphore ready_semaphore(0); | |
523 int context_group_id = 0; | |
524 TaskRunner::SetupGlobalTasks setup_global; | |
525 setup_global.emplace_back(new SetTimeoutExtension()); | |
526 setup_global.emplace_back(new InspectorExtension()); | |
527 inspector_client_->scheduleCreateContextGroup( | |
528 std::move(setup_global), &ready_semaphore, &context_group_id); | |
529 ready_semaphore.Wait(); | |
530 args.GetReturnValue().Set( | |
531 v8::Int32::New(args.GetIsolate(), context_group_id)); | |
532 } | |
533 | |
581 v8::Local<v8::String> ToString(v8::Isolate* isolate, | 534 v8::Local<v8::String> ToString(v8::Isolate* isolate, |
582 const v8_inspector::StringView& string) { | 535 const v8_inspector::StringView& string) { |
583 if (string.is8Bit()) | 536 if (string.is8Bit()) |
584 return v8::String::NewFromOneByte(isolate, string.characters8(), | 537 return v8::String::NewFromOneByte(isolate, string.characters8(), |
585 v8::NewStringType::kNormal, | 538 v8::NewStringType::kNormal, |
586 static_cast<int>(string.length())) | 539 static_cast<int>(string.length())) |
587 .ToLocalChecked(); | 540 .ToLocalChecked(); |
588 else | 541 else |
589 return v8::String::NewFromTwoByte(isolate, string.characters16(), | 542 return v8::String::NewFromTwoByte(isolate, string.characters16(), |
590 v8::NewStringType::kNormal, | 543 v8::NewStringType::kNormal, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 } // namespace | 580 } // namespace |
628 | 581 |
629 int main(int argc, char* argv[]) { | 582 int main(int argc, char* argv[]) { |
630 v8::V8::InitializeICUDefaultLocation(argv[0]); | 583 v8::V8::InitializeICUDefaultLocation(argv[0]); |
631 v8::Platform* platform = v8::platform::CreateDefaultPlatform(); | 584 v8::Platform* platform = v8::platform::CreateDefaultPlatform(); |
632 v8::V8::InitializePlatform(platform); | 585 v8::V8::InitializePlatform(platform); |
633 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 586 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
634 v8::V8::InitializeExternalStartupData(argv[0]); | 587 v8::V8::InitializeExternalStartupData(argv[0]); |
635 v8::V8::Initialize(); | 588 v8::V8::Initialize(); |
636 | 589 |
637 SetTimeoutExtension set_timeout_extension; | |
638 v8::RegisterExtension(&set_timeout_extension); | |
639 InspectorExtension inspector_extension; | |
640 v8::RegisterExtension(&inspector_extension); | |
641 SendMessageToBackendExtension send_message_to_backend_extension; | |
642 v8::RegisterExtension(&send_message_to_backend_extension); | |
643 | |
644 v8::base::Semaphore ready_semaphore(0); | 590 v8::base::Semaphore ready_semaphore(0); |
645 | 591 |
646 const char* backend_extensions[] = {"v8_inspector/setTimeout", | 592 TaskRunner::SetupGlobalTasks backend_extensions; |
647 "v8_inspector/inspector"}; | 593 backend_extensions.emplace_back(new SetTimeoutExtension()); |
648 v8::ExtensionConfiguration backend_configuration( | 594 backend_extensions.emplace_back(new InspectorExtension()); |
649 arraysize(backend_extensions), backend_extensions); | 595 TaskRunner backend_runner(std::move(backend_extensions), false, |
650 TaskRunner backend_runner(&backend_configuration, false, &ready_semaphore); | 596 &ready_semaphore); |
651 ready_semaphore.Wait(); | 597 ready_semaphore.Wait(); |
652 SendMessageToBackendExtension::set_backend_task_runner(&backend_runner); | 598 SendMessageToBackendExtension::set_backend_task_runner(&backend_runner); |
653 UtilsExtension::set_backend_task_runner(&backend_runner); | 599 UtilsExtension::set_backend_task_runner(&backend_runner); |
654 | 600 |
655 const char* frontend_extensions[] = {"v8_inspector/frontend"}; | 601 TaskRunner::SetupGlobalTasks frontend_extensions; |
656 v8::ExtensionConfiguration frontend_configuration( | 602 frontend_extensions.emplace_back(new UtilsExtension()); |
657 arraysize(frontend_extensions), frontend_extensions); | 603 frontend_extensions.emplace_back(new SendMessageToBackendExtension()); |
658 TaskRunner frontend_runner(&frontend_configuration, true, &ready_semaphore); | 604 TaskRunner frontend_runner(std::move(frontend_extensions), true, |
605 &ready_semaphore); | |
659 ready_semaphore.Wait(); | 606 ready_semaphore.Wait(); |
660 frontend_runner.Append(new UtilsExtension()); | |
661 | 607 |
662 FrontendChannelImpl frontend_channel(&frontend_runner); | 608 FrontendChannelImpl frontend_channel(&frontend_runner); |
663 InspectorClientImpl inspector_client(&backend_runner, &frontend_channel, | 609 InspectorClientImpl inspector_client(&backend_runner, &frontend_channel, |
664 &ready_semaphore); | 610 &ready_semaphore); |
665 ready_semaphore.Wait(); | 611 ready_semaphore.Wait(); |
666 UtilsExtension::set_inspector_client(&inspector_client); | 612 UtilsExtension::set_inspector_client(&inspector_client); |
667 | 613 |
668 task_runners.push_back(&frontend_runner); | 614 task_runners.push_back(&frontend_runner); |
669 task_runners.push_back(&backend_runner); | 615 task_runners.push_back(&backend_runner); |
670 | 616 |
671 for (int i = 1; i < argc; ++i) { | 617 for (int i = 1; i < argc; ++i) { |
672 // Ignore unknown flags. | 618 // Ignore unknown flags. |
673 if (argv[i][0] == '-') continue; | 619 if (argv[i][0] == '-') continue; |
674 | 620 |
675 bool exists = false; | 621 bool exists = false; |
676 v8::internal::Vector<const char> chars = | 622 v8::internal::Vector<const char> chars = |
677 v8::internal::ReadFile(argv[i], &exists, true); | 623 v8::internal::ReadFile(argv[i], &exists, true); |
678 if (!exists) { | 624 if (!exists) { |
679 fprintf(stderr, "Internal error: script file doesn't exists: %s\n", | 625 fprintf(stderr, "Internal error: script file doesn't exists: %s\n", |
680 argv[i]); | 626 argv[i]); |
681 Exit(); | 627 Exit(); |
682 } | 628 } |
683 frontend_runner.Append(new ExecuteStringTask(chars)); | 629 frontend_runner.Append(new ExecuteStringTask(chars)); |
684 } | 630 } |
685 | 631 |
686 frontend_runner.Join(); | 632 frontend_runner.Join(); |
687 backend_runner.Join(); | 633 backend_runner.Join(); |
688 return 0; | 634 return 0; |
689 } | 635 } |
OLD | NEW |