From a55fa1efb90b83c56004f12ee67673f4836eb33d Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Fri, 9 Sep 2016 15:54:07 -0700 Subject: [PATCH] =?UTF-8?q?Add=20a=20=E2=80=94disable-observatory=20flag?= =?UTF-8?q?=20to=20explicitly=20disable=20observatory=20even=20in=20non-pr?= =?UTF-8?q?oduct=20modes.=20(#3012)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/settings.h | 1 + runtime/dart_init.cc | 17 +++++++++-------- sky/shell/shell.cc | 8 ++++++-- sky/shell/switches.cc | 1 + sky/shell/switches.h | 1 + 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/common/settings.h b/common/settings.h index e3901b92c..7fe3f9b8b 100644 --- a/common/settings.h +++ b/common/settings.h @@ -13,6 +13,7 @@ namespace blink { struct Settings { + bool enable_observatory = false; // Port on target will be auto selected by the OS. A message will be printed // on the target with the port after it has been selected. uint32_t observatory_port = 0; diff --git a/runtime/dart_init.cc b/runtime/dart_init.cc index 2546b37cc..e14970ece 100644 --- a/runtime/dart_init.cc +++ b/runtime/dart_init.cc @@ -203,14 +203,15 @@ Dart_Isolate ServiceIsolateCreateCallback(const char* script_uri, DartMojoInternal::InitForIsolate(); DartRuntimeHooks::Install(DartRuntimeHooks::SecondaryIsolate, script_uri); const Settings& settings = Settings::Get(); - - std::string ip = "127.0.0.1"; - const intptr_t port = settings.observatory_port; - const bool disable_websocket_origin_check = false; - const bool service_isolate_booted = DartServiceIsolate::Startup( - ip, port, tonic::DartState::HandleLibraryTag, - IsRunningPrecompiledCode(), disable_websocket_origin_check, error); - FTL_CHECK(service_isolate_booted) << error; + if (settings.enable_observatory) { + std::string ip = "127.0.0.1"; + const intptr_t port = settings.observatory_port; + const bool disable_websocket_origin_check = false; + const bool service_isolate_booted = DartServiceIsolate::Startup( + ip, port, tonic::DartState::HandleLibraryTag, + IsRunningPrecompiledCode(), disable_websocket_origin_check, error); + FTL_CHECK(service_isolate_booted) << error; + } if (g_service_isolate_hook) g_service_isolate_hook(IsRunningPrecompiledCode()); diff --git a/sky/shell/shell.cc b/sky/shell/shell.cc index 23ae28eb4..a4fd0593d 100644 --- a/sky/shell/shell.cc +++ b/sky/shell/shell.cc @@ -71,7 +71,9 @@ base::LazyInstance g_discardable; void ServiceIsolateHook(bool running_precompiled) { if (!running_precompiled) { - DiagnosticServer::Start(); + const blink::Settings& settings = blink::Settings::Get(); + if (settings.enable_observatory) + DiagnosticServer::Start(); } } @@ -129,7 +131,9 @@ void Shell::InitStandalone(std::string icu_data_path) { base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); blink::Settings settings; - + // Enable Observatory + settings.enable_observatory = + !command_line.HasSwitch(switches::kDisableObservatory); // Set Observatory Port if (command_line.HasSwitch(switches::kDeviceObservatoryPort)) { auto port_string = diff --git a/sky/shell/switches.cc b/sky/shell/switches.cc index 9794da1c9..b648a9c4d 100644 --- a/sky/shell/switches.cc +++ b/sky/shell/switches.cc @@ -18,6 +18,7 @@ const char kAotVmIsolateSnapshot[] = "vm-isolate-snapshot"; const char kCacheDirPath[] = "cache-dir-path"; const char kDartFlags[] = "dart-flags"; const char kDeviceObservatoryPort[] = "observatory-port"; +const char kDisableObservatory[] = "disable-observatory"; const char kEndlessTraceBuffer[] = "endless-trace-buffer"; const char kFLX[] = "flx"; const char kHelp[] = "help"; diff --git a/sky/shell/switches.h b/sky/shell/switches.h index 9c9d03a57..74628139c 100644 --- a/sky/shell/switches.h +++ b/sky/shell/switches.h @@ -19,6 +19,7 @@ extern const char kAotVmIsolateSnapshot[]; extern const char kCacheDirPath[]; extern const char kDartFlags[]; extern const char kDeviceObservatoryPort[]; +extern const char kDisableObservatory[]; extern const char kEndlessTraceBuffer[]; extern const char kFLX[]; extern const char kHelp[]; -- GitLab