From a3de4df656b4347eb95da14e072bb9f77466b597 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Fri, 1 May 2015 11:03:09 -0700 Subject: [PATCH] Teach the mojo_shell --trace-startup flag to gather data from services This makes passing --trace-startup to mojo_shell (or MojoShell.apk) collect and save data from all apps/services that support tracing, not just the shell itself. R=viettrungluu@chromium.org Review URL: https://codereview.chromium.org/1105773002 --- tools/debugger/debugger.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/debugger/debugger.cc b/tools/debugger/debugger.cc index c8d78348191..04a92474a3e 100644 --- a/tools/debugger/debugger.cc +++ b/tools/debugger/debugger.cc @@ -28,13 +28,13 @@ namespace debugger { class SkyDebugger : public mojo::ApplicationDelegate, public http_server::HttpHandler { public: - SkyDebugger() : is_tracing_(false), handler_binding_(this) {} + SkyDebugger() : is_tracing_(false), app_(nullptr), handler_binding_(this) {} ~SkyDebugger() override {} private: // mojo::ApplicationDelegate: void Initialize(mojo::ApplicationImpl* app) override { - app->ConnectToService("mojo:tracing", &tracing_); + app_ = app; app->ConnectToService("mojo:window_manager", &window_manager_); // Format: --args-for="app_url command_port" @@ -140,6 +140,8 @@ class SkyDebugger : public mojo::ApplicationDelegate, return; } + if (!tracing_) + app_->ConnectToService("mojo:tracing", &tracing_); is_tracing_ = true; mojo::DataPipe pipe; tracing_->Start(pipe.producer_handle.Pass(), mojo::String("*")); @@ -185,6 +187,7 @@ class SkyDebugger : public mojo::ApplicationDelegate, } bool is_tracing_; + mojo::ApplicationImpl* app_; mojo::WindowManagerPtr window_manager_; tracing::TraceCoordinatorPtr tracing_; std::string url_;