Make TracingImpl take a Shell* and args, instead of an ApplicationImpl*.
R=vardhan@google.com
Review URL: https://codereview.chromium.org/2014043002 .
diff --git a/examples/echo/echo_benchmark.cc b/examples/echo/echo_benchmark.cc
index e8da193..30e8044 100644
--- a/examples/echo/echo_benchmark.cc
+++ b/examples/echo/echo_benchmark.cc
@@ -50,7 +50,7 @@
benchmark_duration_(base::TimeDelta::FromSeconds(10)) {}
void Initialize(ApplicationImpl* app) override {
- tracing_.Initialize(app);
+ tracing_.Initialize(app->shell(), &app->args());
ParseArguments(app);
diff --git a/examples/trace_me/trace_me_app.cc b/examples/trace_me/trace_me_app.cc
index b26b004..81887cf 100644
--- a/examples/trace_me/trace_me_app.cc
+++ b/examples/trace_me/trace_me_app.cc
@@ -53,7 +53,7 @@
void Initialize(mojo::ApplicationImpl* app) override {
// Allow TracingImpl to connect to the central tracing service, advertising
// its ability to provide trace events.
- tracing_.Initialize(app);
+ tracing_.Initialize(app->shell(), &app->args());
TRACE_EVENT0("trace_me", "initialized");
diff --git a/mojo/common/tracing_impl.cc b/mojo/common/tracing_impl.cc
index 93f6e55..827ac17 100644
--- a/mojo/common/tracing_impl.cc
+++ b/mojo/common/tracing_impl.cc
@@ -4,6 +4,8 @@
#include "mojo/common/tracing_impl.h"
+#include <algorithm>
+
#include "base/trace_event/trace_event_impl.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/application/connect.h"
@@ -18,17 +20,19 @@
TracingImpl::~TracingImpl() {}
-void TracingImpl::Initialize(ApplicationImpl* app) {
+void TracingImpl::Initialize(Shell* shell,
+ const std::vector<std::string>* args) {
tracing::TraceProviderRegistryPtr registry;
- ConnectToService(app->shell(), "mojo:tracing", GetProxy(®istry));
+ ConnectToService(shell, "mojo:tracing", GetProxy(®istry));
mojo::InterfaceHandle<tracing::TraceProvider> provider;
provider_impl_.Bind(GetProxy(&provider));
registry->RegisterTraceProvider(provider.Pass());
#ifdef NDEBUG
- if (app->HasArg("--early-tracing")) {
- provider_impl_.ForceEnableTracing();
+ if (args) {
+ if (std::find(args->begin(), args->end(), "--early-tracing") != args->end())
+ provider_impl_.ForceEnableTracing();
}
#else
provider_impl_.ForceEnableTracing();
diff --git a/mojo/common/tracing_impl.h b/mojo/common/tracing_impl.h
index d3f93c6..95c44ea 100644
--- a/mojo/common/tracing_impl.h
+++ b/mojo/common/tracing_impl.h
@@ -5,12 +5,15 @@
#ifndef MOJO_COMMON_TRACING_IMPL_H_
#define MOJO_COMMON_TRACING_IMPL_H_
+#include <string>
+#include <vector>
+
#include "base/macros.h"
#include "mojo/common/trace_provider_impl.h"
namespace mojo {
-class ApplicationImpl;
+class Shell;
class TracingImpl {
public:
@@ -18,8 +21,10 @@
~TracingImpl();
// This connects to the tracing service and registers ourselves to provide
- // tracing data on demand.
- void Initialize(ApplicationImpl* app);
+ // tracing data on demand. |shell| will not be stored (so it need only be
+ // valid for this call). |args| may be null, but if not should typically point
+ // to the applications "command line".
+ void Initialize(Shell* shell, const std::vector<std::string>* args);
private:
TraceProviderImpl provider_impl_;
diff --git a/services/dart/content_handler_app.cc b/services/dart/content_handler_app.cc
index 5db8dac..380cd92 100644
--- a/services/dart/content_handler_app.cc
+++ b/services/dart/content_handler_app.cc
@@ -132,9 +132,9 @@
void DartContentHandlerApp::Initialize(mojo::ApplicationImpl* app) {
// Tracing of content handler and controller.
- tracing_.Initialize(app);
+ tracing_.Initialize(app->shell(), &app->args());
// Tracing of isolates and VM.
- dart_tracing_.Initialize(app);
+ dart_tracing_.Initialize(app->shell());
// TODO(qsr): This has no effect for now, as the tracing infrastructure
// doesn't allow to trace anything before the tracing app connects to the
diff --git a/services/dart/dart_tracing.cc b/services/dart/dart_tracing.cc
index 45104c6..bf5b9a7 100644
--- a/services/dart/dart_tracing.cc
+++ b/services/dart/dart_tracing.cc
@@ -133,9 +133,9 @@
DartTracingImpl::~DartTracingImpl() {
}
-void DartTracingImpl::Initialize(mojo::ApplicationImpl* app) {
+void DartTracingImpl::Initialize(mojo::Shell* shell) {
tracing::TraceProviderRegistryPtr registry;
- ConnectToService(app->shell(), "mojo:tracing", GetProxy(®istry));
+ ConnectToService(shell, "mojo:tracing", GetProxy(®istry));
mojo::InterfaceHandle<tracing::TraceProvider> provider;
provider_impl_.Bind(GetProxy(&provider));
diff --git a/services/dart/dart_tracing.h b/services/dart/dart_tracing.h
index d9a669c..8e5fb54 100644
--- a/services/dart/dart_tracing.h
+++ b/services/dart/dart_tracing.h
@@ -48,7 +48,7 @@
// This connects to the tracing service and registers ourselves to provide
// tracing data on demand.
- void Initialize(mojo::ApplicationImpl* app);
+ void Initialize(mojo::Shell* shell);
private:
DartTraceProvider provider_impl_;
diff --git a/services/gfx/compositor/compositor_app.cc b/services/gfx/compositor/compositor_app.cc
index 8c28965..bd05c8a 100644
--- a/services/gfx/compositor/compositor_app.cc
+++ b/services/gfx/compositor/compositor_app.cc
@@ -29,7 +29,7 @@
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);
- tracing_.Initialize(app_impl_);
+ tracing_.Initialize(app_impl_->shell(), &app_impl_->args());
engine_.reset(new CompositorEngine());
}
diff --git a/services/java_handler/java_handler.cc b/services/java_handler/java_handler.cc
index b7949de..177eee1 100644
--- a/services/java_handler/java_handler.cc
+++ b/services/java_handler/java_handler.cc
@@ -90,7 +90,7 @@
}
void JavaHandler::Initialize(mojo::ApplicationImpl* app) {
- tracing_.Initialize(app);
+ tracing_.Initialize(app->shell(), &app->args());
handler_task_runner_ = base::MessageLoop::current()->task_runner();
mojo::ConnectToService(app->shell(), "mojo:url_response_disk_cache",
GetProxy(&url_response_disk_cache_));
diff --git a/services/native_viewport/app_delegate.cc b/services/native_viewport/app_delegate.cc
index 0848298..f1f53fc 100644
--- a/services/native_viewport/app_delegate.cc
+++ b/services/native_viewport/app_delegate.cc
@@ -33,7 +33,7 @@
application_ = application;
InitLogging(application);
- tracing_.Initialize(application);
+ tracing_.Initialize(application->shell(), &application->args());
// Apply the switch for kTouchEvents to CommandLine (if set). This allows
// redirecting the mouse to a touch device on X for testing.
diff --git a/services/ui/input_manager/input_manager_app.cc b/services/ui/input_manager/input_manager_app.cc
index 4d47940..d75969c 100644
--- a/services/ui/input_manager/input_manager_app.cc
+++ b/services/ui/input_manager/input_manager_app.cc
@@ -29,7 +29,7 @@
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);
- tracing_.Initialize(app_impl);
+ tracing_.Initialize(app_impl->shell(), &app_impl->args());
}
bool InputManagerApp::ConfigureIncomingConnection(
diff --git a/services/ui/launcher/launcher_app.cc b/services/ui/launcher/launcher_app.cc
index d301cc1..c231ce6 100644
--- a/services/ui/launcher/launcher_app.cc
+++ b/services/ui/launcher/launcher_app.cc
@@ -30,7 +30,7 @@
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);
- tracing_.Initialize(app_impl_);
+ tracing_.Initialize(app_impl_->shell(), &app_impl_->args());
TRACE_EVENT0("launcher", __func__);
InitCompositor();
diff --git a/services/ui/view_manager/view_manager_app.cc b/services/ui/view_manager/view_manager_app.cc
index 3ea2d69..7a80178 100644
--- a/services/ui/view_manager/view_manager_app.cc
+++ b/services/ui/view_manager/view_manager_app.cc
@@ -33,7 +33,7 @@
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);
- tracing_.Initialize(app_impl_);
+ tracing_.Initialize(app_impl_->shell(), &app_impl_->args());
// Connect to compositor.
mojo::gfx::composition::CompositorPtr compositor;