Connect mojo:debugger to window_manager only when requested.
This patch makes mojo:debugger automatically connect to window_manager
only when run by skydb, so that running the debugger for tracing and
profiling doesn't bring the side-effect of spawning window_manager.
Note that we might in the future change this to make the connection to
window_manager lazy when load() or reload() is requested, but this would
require a more involved change to skydb. The way taken in this patch
doesn't change the skydb codepath while enabling usage of debugger for
interactive tracing / profiling.
R=abarth@chromium.org
Review URL: https://codereview.chromium.org/1157253007
diff --git a/services/debugger/debugger.cc b/services/debugger/debugger.cc
index 5d1f630..5654cdb 100644
--- a/services/debugger/debugger.cc
+++ b/services/debugger/debugger.cc
@@ -39,7 +39,6 @@
// mojo::ApplicationDelegate:
void Initialize(mojo::ApplicationImpl* app) override {
app_ = app;
- app->ConnectToService("mojo:window_manager", &window_manager_);
// Format: --args-for="app_url command_port"
if (app->args().size() < 2) {
@@ -47,6 +46,11 @@
mojo::ApplicationImpl::Terminate();
return;
}
+ if (app->args().size() == 3 && app->args()[2] == "--wm") {
+ // Connect to window manager only if requested, as the user might want to
+ // run the debugger without spawning one.
+ app_->ConnectToService("mojo:window_manager", &window_manager_);
+ }
base::StringToUint(app->args()[1], &command_port_);
http_server::HttpServerFactoryPtr http_server_factory;
app->ConnectToService("mojo:http_server", &http_server_factory);
@@ -129,6 +133,9 @@
}
void Reload() {
+ if (!window_manager_)
+ return;
+
// SimpleWindowManager will wire up necessary services on our behalf.
window_manager_->Embed(url_, nullptr, nullptr);
}
diff --git a/sky/tools/skydb b/sky/tools/skydb
index dfa45e2..cb33ae7 100755
--- a/sky/tools/skydb
+++ b/sky/tools/skydb
@@ -119,7 +119,7 @@
'--v=1',
'--content-handlers=%s' % ','.join(content_handlers),
'--url-mappings=mojo:window_manager=mojo:kiosk_wm',
- '--args-for=mojo:debugger %d' % remote_command_port,
+ '--args-for=mojo:debugger %d --wm' % remote_command_port,
'mojo:debugger',
]