Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(647)

Side by Side Diff: mojo/dart/embedder/dart_controller.cc

Issue 1480243004: Dart: Lazy observatory asset loading. Option to disable the observatory. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/dart/embedder/dart_controller.h ('k') | mojo/dart/embedder/vmservice/main.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 result = PrepareBuiltinLibraries(package_root, script_uri); 345 result = PrepareBuiltinLibraries(package_root, script_uri);
346 DART_CHECK_VALID(result); 346 DART_CHECK_VALID(result);
347 347
348 // Set the handle watcher's control handle in the spawning isolate. 348 // Set the handle watcher's control handle in the spawning isolate.
349 result = SetHandleWatcherControlHandle(); 349 result = SetHandleWatcherControlHandle();
350 DART_CHECK_VALID(result); 350 DART_CHECK_VALID(result);
351 351
352 // The VM is creating the service isolate. 352 // The VM is creating the service isolate.
353 if (Dart_IsServiceIsolate(isolate)) { 353 if (Dart_IsServiceIsolate(isolate)) {
354 service_isolate_spawned_ = true; 354 service_isolate_spawned_ = true;
355 const intptr_t port = SupportDartMojoIo() ? 0 : -1; 355 const intptr_t port =
356 (SupportDartMojoIo() && observatory_enabled_) ? 0 : -1;
356 InitializeDartMojoIo(); 357 InitializeDartMojoIo();
357 if (!VmService::Setup("127.0.0.1", port)) { 358 if (!VmService::Setup("127.0.0.1", port)) {
358 *error = strdup(VmService::GetErrorMessage()); 359 *error = strdup(VmService::GetErrorMessage());
359 return nullptr; 360 return nullptr;
360 } 361 }
361 return isolate; 362 return isolate;
362 } 363 }
363 364
364 if ((script_uri == kHandleWatcherIsolateUri) || 365 if ((script_uri == kHandleWatcherIsolateUri) ||
365 (script_uri == kStopHandleWatcherIsolateUri)) { 366 (script_uri == kStopHandleWatcherIsolateUri)) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 } 498 }
498 } 499 }
499 500
500 501
501 bool DartController::initialized_ = false; 502 bool DartController::initialized_ = false;
502 MojoHandle DartController::handle_watcher_producer_handle_ = 503 MojoHandle DartController::handle_watcher_producer_handle_ =
503 MOJO_HANDLE_INVALID; 504 MOJO_HANDLE_INVALID;
504 bool DartController::service_isolate_running_ = false; 505 bool DartController::service_isolate_running_ = false;
505 bool DartController::service_isolate_spawned_ = false; 506 bool DartController::service_isolate_spawned_ = false;
506 bool DartController::strict_compilation_ = false; 507 bool DartController::strict_compilation_ = false;
508 bool DartController::observatory_enabled_ = true;
507 DartControllerServiceConnector* DartController::service_connector_ = nullptr; 509 DartControllerServiceConnector* DartController::service_connector_ = nullptr;
508 base::Lock DartController::lock_; 510 base::Lock DartController::lock_;
509 511
510 bool DartController::SupportDartMojoIo() { 512 bool DartController::SupportDartMojoIo() {
511 return service_connector_ != nullptr; 513 return service_connector_ != nullptr;
512 } 514 }
513 515
514 void DartController::InitializeDartMojoIo() { 516 void DartController::InitializeDartMojoIo() {
515 Dart_Isolate current_isolate = Dart_CurrentIsolate(); 517 Dart_Isolate current_isolate = Dart_CurrentIsolate();
516 CHECK(current_isolate != nullptr); 518 CHECK(current_isolate != nullptr);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 } 704 }
703 705
704 static bool generateEntropy(uint8_t* buffer, intptr_t length) { 706 static bool generateEntropy(uint8_t* buffer, intptr_t length) {
705 base::RandBytes(reinterpret_cast<void*>(buffer), length); 707 base::RandBytes(reinterpret_cast<void*>(buffer), length);
706 return true; 708 return true;
707 } 709 }
708 710
709 bool DartController::Initialize( 711 bool DartController::Initialize(
710 DartControllerServiceConnector* service_connector, 712 DartControllerServiceConnector* service_connector,
711 bool strict_compilation, 713 bool strict_compilation,
714 bool observatory_enabled,
712 const char** extra_args, 715 const char** extra_args,
713 int extra_args_count) { 716 int extra_args_count) {
714 service_connector_ = service_connector; 717 service_connector_ = service_connector;
718 observatory_enabled_ = observatory_enabled;
715 strict_compilation_ = strict_compilation; 719 strict_compilation_ = strict_compilation;
716 InitVmIfNeeded(generateEntropy, extra_args, extra_args_count); 720 InitVmIfNeeded(generateEntropy, extra_args, extra_args_count);
717 return true; 721 return true;
718 } 722 }
719 723
720 bool DartController::RunDartScript(const DartControllerConfig& config) { 724 bool DartController::RunDartScript(const DartControllerConfig& config) {
721 const bool strict = strict_compilation_ || config.strict_compilation; 725 const bool strict = strict_compilation_ || config.strict_compilation;
722 Dart_Isolate isolate = CreateIsolateHelper(config.application_data, 726 Dart_Isolate isolate = CreateIsolateHelper(config.application_data,
723 strict, 727 strict,
724 config.callbacks, 728 config.callbacks,
(...skipping 20 matching lines...) Expand all
745 return; 749 return;
746 } 750 }
747 BlockForServiceIsolateLocked(); 751 BlockForServiceIsolateLocked();
748 Dart_Cleanup(); 752 Dart_Cleanup();
749 service_isolate_running_ = false; 753 service_isolate_running_ = false;
750 initialized_ = false; 754 initialized_ = false;
751 } 755 }
752 756
753 } // namespace apps 757 } // namespace apps
754 } // namespace mojo 758 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/dart/embedder/dart_controller.h ('k') | mojo/dart/embedder/vmservice/main.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698