De-client tracing.TraceController interface
The tracing service logically provides one service, TraceCoordinator, which can
start and stop tracing sessions. It also can connect to any number of
TraceControllers each of which can supply tracing information on demand.
Whenever an app connects to the tracing service, the tracing service attempts to
connect to that app's TraceController interface. If the app provides this
interface then tracing data will be requested whenever tracing starts. If the
app doesn't, then the pipe just closes. Thus apps that want to be traced can do
so by creating however many connections to the tracing service they want and
registering a TraceController implementation on each outgoing connection.
The shell connects in a similar fashion by connecting to the tracing service and
providing a TraceController implementation. The code looks a bit different since
the shell is special.
BUG=451319
R=viettrungluu@chromium.org
Review URL: https://codereview.chromium.org/791493006
diff --git a/mojo/common/BUILD.gn b/mojo/common/BUILD.gn
index 5a45242..3fd0786 100644
--- a/mojo/common/BUILD.gn
+++ b/mojo/common/BUILD.gn
@@ -65,6 +65,8 @@
source_set("tracing_impl") {
sources = [
+ "trace_controller_impl.cc",
+ "trace_controller_impl.h",
"tracing_impl.cc",
"tracing_impl.h",
]
diff --git a/mojo/common/trace_controller_impl.cc b/mojo/common/trace_controller_impl.cc
new file mode 100644
index 0000000..098dfb3
--- /dev/null
+++ b/mojo/common/trace_controller_impl.cc
@@ -0,0 +1,49 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/common/trace_controller_impl.h"
+
+#include "base/debug/trace_event.h"
+#include "mojo/public/cpp/application/application_connection.h"
+#include "mojo/public/cpp/application/application_impl.h"
+
+namespace mojo {
+
+TraceControllerImpl::TraceControllerImpl(
+ InterfaceRequest<tracing::TraceController> request)
+ : binding_(this, request.Pass()) {
+}
+
+TraceControllerImpl::~TraceControllerImpl() {
+}
+
+void TraceControllerImpl::StartTracing(
+ const String& categories,
+ tracing::TraceDataCollectorPtr collector) {
+ DCHECK(!collector_.get());
+ collector_ = collector.Pass();
+ std::string categories_str = categories.To<std::string>();
+ base::debug::TraceLog::GetInstance()->SetEnabled(
+ base::debug::CategoryFilter(categories_str),
+ base::debug::TraceLog::RECORDING_MODE,
+ base::debug::TraceOptions(base::debug::RECORD_UNTIL_FULL));
+}
+
+void TraceControllerImpl::StopTracing() {
+ base::debug::TraceLog::GetInstance()->SetDisabled();
+
+ base::debug::TraceLog::GetInstance()->Flush(
+ base::Bind(&TraceControllerImpl::SendChunk, base::Unretained(this)));
+}
+
+void TraceControllerImpl::SendChunk(
+ const scoped_refptr<base::RefCountedString>& events_str,
+ bool has_more_events) {
+ collector_->DataCollected(mojo::String(events_str->data()));
+ if (!has_more_events) {
+ collector_.reset();
+ }
+}
+
+} // namespace mojo
diff --git a/mojo/common/trace_controller_impl.h b/mojo/common/trace_controller_impl.h
new file mode 100644
index 0000000..5d8cf28
--- /dev/null
+++ b/mojo/common/trace_controller_impl.h
@@ -0,0 +1,39 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_COMMON_TRACING_CONTROLLER_IMPL_H_
+#define MOJO_COMMON_TRACING_CONTROLLER_IMPL_H_
+
+#include "base/memory/ref_counted_memory.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "services/tracing/tracing.mojom.h"
+
+namespace mojo {
+
+class TraceControllerImpl : public tracing::TraceController {
+ public:
+ explicit TraceControllerImpl(
+ InterfaceRequest<tracing::TraceController> request);
+
+ ~TraceControllerImpl() override;
+
+ private:
+ // tracing::TraceController implementation:
+ void StartTracing(const String& categories,
+ tracing::TraceDataCollectorPtr collector) override;
+ void StopTracing() override;
+
+ void SendChunk(const scoped_refptr<base::RefCountedString>& events_str,
+ bool has_more_events);
+
+ tracing::TraceDataCollectorPtr collector_;
+ StrongBinding<tracing::TraceController> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(TraceControllerImpl);
+};
+
+} // namespace mojo
+
+#endif // MOJO_COMMON_TRACING_CONTROLLER_IMPL_H_
diff --git a/mojo/common/tracing_impl.cc b/mojo/common/tracing_impl.cc
index bfafcba..9c4c276 100644
--- a/mojo/common/tracing_impl.cc
+++ b/mojo/common/tracing_impl.cc
@@ -5,57 +5,26 @@
#include "mojo/common/tracing_impl.h"
#include "base/debug/trace_event.h"
+#include "mojo/common/trace_controller_impl.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_impl.h"
namespace mojo {
-// static
-void TracingImpl::Create(ApplicationImpl* app) {
- new TracingImpl(app);
-}
-
-// static
-void TracingImpl::Create(tracing::TraceDataCollectorPtr ptr) {
- new TracingImpl(ptr.Pass());
-}
-
-TracingImpl::TracingImpl(ApplicationImpl* app) : binding_(this) {
- ApplicationConnection* connection = app->ConnectToApplication("mojo:tracing");
- tracing::TraceDataCollectorPtr trace_data_collector_ptr;
- connection->ConnectToService(&trace_data_collector_ptr);
- binding_.Bind(trace_data_collector_ptr.PassMessagePipe());
-}
-
-TracingImpl::TracingImpl(tracing::TraceDataCollectorPtr ptr)
- : binding_(this, ptr.PassMessagePipe()) {
+TracingImpl::TracingImpl() {
}
TracingImpl::~TracingImpl() {
}
-void TracingImpl::StartTracing(const String& categories) {
- std::string categories_str = categories.To<std::string>();
- base::debug::TraceLog::GetInstance()->SetEnabled(
- base::debug::CategoryFilter(categories_str),
- base::debug::TraceLog::RECORDING_MODE,
- base::debug::TraceOptions(base::debug::RECORD_UNTIL_FULL));
+void TracingImpl::Initialize(ApplicationImpl* app) {
+ ApplicationConnection* connection = app->ConnectToApplication("mojo:tracing");
+ connection->AddService(this);
}
-void TracingImpl::StopTracing() {
- base::debug::TraceLog::GetInstance()->SetDisabled();
-
- base::debug::TraceLog::GetInstance()->Flush(
- base::Bind(&TracingImpl::SendChunk, base::Unretained(this)));
-}
-
-void TracingImpl::SendChunk(
- const scoped_refptr<base::RefCountedString>& events_str,
- bool has_more_events) {
- binding_.client()->DataCollected(mojo::String(events_str->data()));
- if (!has_more_events) {
- binding_.client()->EndTracing();
- }
+void TracingImpl::Create(ApplicationConnection* connection,
+ InterfaceRequest<tracing::TraceController> request) {
+ new TraceControllerImpl(request.Pass());
}
} // namespace mojo
diff --git a/mojo/common/tracing_impl.h b/mojo/common/tracing_impl.h
index ffc617b..53f6b84 100644
--- a/mojo/common/tracing_impl.h
+++ b/mojo/common/tracing_impl.h
@@ -5,42 +5,27 @@
#ifndef MOJO_COMMON_TRACING_IMPL_H_
#define MOJO_COMMON_TRACING_IMPL_H_
-#include "base/basictypes.h"
-#include "base/files/file_path.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/ref_counted_memory.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "base/macros.h"
+#include "mojo/public/cpp/application/interface_factory.h"
#include "services/tracing/tracing.mojom.h"
namespace mojo {
class ApplicationImpl;
-class TracingImpl : public tracing::TraceController {
+class TracingImpl : public InterfaceFactory<tracing::TraceController> {
public:
- // This constructs a TracingImpl and connects to the tracing service. The
- // lifetime of the TracingImpl is bound to the connection to the tracing
- // service.
- static void Create(ApplicationImpl* app);
+ TracingImpl();
+ ~TracingImpl() override;
- // This constructs a TracingImpl around a tracing::TraceDataCollectorPtr
- // already bound to the service.
- static void Create(tracing::TraceDataCollectorPtr ptr);
-
- virtual ~TracingImpl();
+ // This connects to the tracing service and registers ourselves to provide
+ // tracing data on demand.
+ void Initialize(ApplicationImpl* app);
private:
- explicit TracingImpl(ApplicationImpl* app);
- explicit TracingImpl(tracing::TraceDataCollectorPtr ptr);
-
- // Overridden from tracing::TraceController:
- void StartTracing(const String& categories) override;
- void StopTracing() override;
-
- void SendChunk(const scoped_refptr<base::RefCountedString>& events_str,
- bool has_more_events);
-
- StrongBinding<tracing::TraceController> binding_;
+ // InterfaceFactory<tracing::TraceController> implementation.
+ void Create(ApplicationConnection* connection,
+ InterfaceRequest<tracing::TraceController> request) override;
DISALLOW_COPY_AND_ASSIGN(TracingImpl);
};
diff --git a/mojo/public/cpp/application/lib/service_registry.cc b/mojo/public/cpp/application/lib/service_registry.cc
index d934a16..01c6c70 100644
--- a/mojo/public/cpp/application/lib/service_registry.cc
+++ b/mojo/public/cpp/application/lib/service_registry.cc
@@ -18,8 +18,10 @@
InterfaceRequest<ServiceProvider> local_services)
: application_impl_(application_impl),
url_(url),
- local_binding_(this, local_services.Pass()),
+ local_binding_(this),
remote_service_provider_(remote_services.Pass()) {
+ if (local_services.is_pending())
+ local_binding_.Bind(local_services.Pass());
}
ServiceRegistry::ServiceRegistry()
diff --git a/services/fake_surfaces/fake_surfaces_service_application.cc b/services/fake_surfaces/fake_surfaces_service_application.cc
index 800b8a8..7e0a316 100644
--- a/services/fake_surfaces/fake_surfaces_service_application.cc
+++ b/services/fake_surfaces/fake_surfaces_service_application.cc
@@ -5,9 +5,9 @@
#include "services/fake_surfaces/fake_surfaces_service_application.h"
#include "mojo/application/application_runner_chromium.h"
-#include "mojo/common/tracing_impl.h"
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/application/application_connection.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h"
using mojo::InterfaceRequest;
@@ -77,7 +77,7 @@
}
void FakeSurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) {
- mojo::TracingImpl::Create(app);
+ tracing_.Initialize(app);
}
bool FakeSurfacesServiceApplication::ConfigureIncomingConnection(
diff --git a/services/fake_surfaces/fake_surfaces_service_application.h b/services/fake_surfaces/fake_surfaces_service_application.h
index 64880ff..9058cff 100644
--- a/services/fake_surfaces/fake_surfaces_service_application.h
+++ b/services/fake_surfaces/fake_surfaces_service_application.h
@@ -6,6 +6,7 @@
#define FAKE_SERVICES_SURFACES_SURFACES_SERVICE_APPLICATION_H_
#include "base/macros.h"
+#include "mojo/common/tracing_impl.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h"
@@ -34,6 +35,7 @@
private:
uint32_t next_id_namespace_;
+ mojo::TracingImpl tracing_;
DISALLOW_COPY_AND_ASSIGN(FakeSurfacesServiceApplication);
};
diff --git a/services/native_viewport/main.cc b/services/native_viewport/main.cc
index 44b5411..459b8f5 100644
--- a/services/native_viewport/main.cc
+++ b/services/native_viewport/main.cc
@@ -34,7 +34,7 @@
void Initialize(mojo::ApplicationImpl* application) override {
app_ = application;
- mojo::TracingImpl::Create(application);
+ tracing_.Initialize(app_);
if (app_->HasArg(mojo::kUseTestConfig))
gfx::GLSurface::InitializeOneOffForTests();
@@ -69,6 +69,8 @@
mojo::ApplicationImpl* app_;
scoped_refptr<gles2::GpuImpl::State> gpu_state_;
bool is_headless_;
+ mojo::TracingImpl tracing_;
+
DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate);
};
}
diff --git a/services/surfaces/surfaces_service_application.cc b/services/surfaces/surfaces_service_application.cc
index dfe3db0..1072617 100644
--- a/services/surfaces/surfaces_service_application.cc
+++ b/services/surfaces/surfaces_service_application.cc
@@ -6,7 +6,6 @@
#include "cc/surfaces/display.h"
#include "mojo/application/application_runner_chromium.h"
-#include "mojo/common/tracing_impl.h"
#include "mojo/public/c/system/main.h"
#include "services/surfaces/surfaces_impl.h"
@@ -20,7 +19,7 @@
}
void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) {
- mojo::TracingImpl::Create(app);
+ tracing_.Initialize(app);
scheduler_.reset(new SurfacesScheduler(this));
}
diff --git a/services/surfaces/surfaces_service_application.h b/services/surfaces/surfaces_service_application.h
index f5fa38d..d3d9fa8 100644
--- a/services/surfaces/surfaces_service_application.h
+++ b/services/surfaces/surfaces_service_application.h
@@ -8,6 +8,7 @@
#include "base/macros.h"
#include "base/timer/timer.h"
#include "cc/surfaces/surface_manager.h"
+#include "mojo/common/tracing_impl.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/interface_factory.h"
#include "services/surfaces/surfaces_impl.h"
@@ -52,6 +53,7 @@
uint32_t next_id_namespace_;
cc::Display* display_;
scoped_ptr<SurfacesScheduler> scheduler_;
+ mojo::TracingImpl tracing_;
DISALLOW_COPY_AND_ASSIGN(SurfacesServiceApplication);
};
diff --git a/services/tracing/main.cc b/services/tracing/main.cc
index dc2dec5..c0f9b87 100644
--- a/services/tracing/main.cc
+++ b/services/tracing/main.cc
@@ -3,21 +3,46 @@
// found in the LICENSE file.
#include "base/bind.h"
+#include "base/memory/scoped_vector.h"
#include "mojo/application/application_runner_chromium.h"
#include "mojo/common/weak_binding_set.h"
+#include "mojo/common/weak_interface_ptr_set.h"
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/tracing/trace_data_sink.h"
#include "services/tracing/tracing.mojom.h"
namespace tracing {
+namespace {
+
+class CollectorImpl : public TraceDataCollector {
+ public:
+ CollectorImpl(mojo::InterfaceRequest<TraceDataCollector> request,
+ TraceDataSink* sink)
+ : sink_(sink), binding_(this, request.Pass()) {}
+
+ ~CollectorImpl() override {}
+
+ // tracing::TraceDataCollector implementation.
+ void DataCollected(const mojo::String& json) override {
+ sink_->AddChunk(json.To<std::string>());
+ }
+
+ private:
+ TraceDataSink* sink_;
+ mojo::Binding<TraceDataCollector> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(CollectorImpl);
+};
+
+} // namespace
+
class TracingApp : public mojo::ApplicationDelegate,
public mojo::InterfaceFactory<TraceCoordinator>,
- public tracing::TraceCoordinator,
- public mojo::InterfaceFactory<TraceDataCollector>,
- public tracing::TraceDataCollector {
+ public TraceCoordinator {
public:
TracingApp() {}
~TracingApp() override {}
@@ -27,7 +52,15 @@
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override {
connection->AddService<TraceCoordinator>(this);
- connection->AddService<TraceDataCollector>(this);
+
+ // If someone connects to us they may want to use the TraceCoordinator
+ // interface and/or they may want to expose themselves to be traced. Attempt
+ // to connect to the TraceController interface to see if the application
+ // connecting to us wants to be traced. They can refuse the connection or
+ // close the pipe if not.
+ TraceControllerPtr controller_ptr;
+ connection->ConnectToService(&controller_ptr);
+ controller_ptrs_.AddInterfacePtr(controller_ptr.Pass());
return true;
}
@@ -37,21 +70,20 @@
coordinator_bindings_.AddBinding(this, request.Pass());
}
- // mojo::InterfaceFactory<TraceDataCollector> implementation.
- void Create(mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<TraceDataCollector> request) override {
- collector_bindings_.AddBinding(this, request.Pass());
- }
-
// tracing::TraceCoordinator implementation.
void Start(mojo::ScopedDataPipeProducerHandle stream,
const mojo::String& categories) override {
sink_.reset(new TraceDataSink(stream.Pass()));
- collector_bindings_.ForAllBindings([categories](
- TraceController* controller) { controller->StartTracing(categories); });
+ controller_ptrs_.ForAllPtrs(
+ [categories, this](TraceController* controller) {
+ TraceDataCollectorPtr ptr;
+ collector_impls_.push_back(
+ new CollectorImpl(GetProxy(&ptr), sink_.get()));
+ controller->StartTracing(categories, ptr.Pass());
+ });
}
void StopAndFlush() override {
- collector_bindings_.ForAllBindings(
+ controller_ptrs_.ForAllPtrs(
[](TraceController* controller) { controller->StopTracing(); });
// TODO: We really should keep track of how many connections we have here
@@ -59,20 +91,18 @@
// pipe closure on all pipes.
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
- base::Bind(&TraceDataSink::Flush, base::Unretained(sink_.get())),
+ base::Bind(&TracingApp::AllDataCollected, base::Unretained(this)),
base::TimeDelta::FromSeconds(1));
}
- // tracing::TraceDataCollector implementation.
- void DataCollected(const mojo::String& json) override {
- if (sink_)
- sink_->AddChunk(json.To<std::string>());
+ void AllDataCollected() {
+ collector_impls_.clear();
+ sink_->Flush();
}
- // tracing::TraceDataCollector implementation.
- void EndTracing() override {}
scoped_ptr<TraceDataSink> sink_;
- mojo::WeakBindingSet<TraceDataCollector> collector_bindings_;
+ ScopedVector<CollectorImpl> collector_impls_;
+ mojo::WeakInterfacePtrSet<TraceController> controller_ptrs_;
mojo::WeakBindingSet<TraceCoordinator> coordinator_bindings_;
DISALLOW_COPY_AND_ASSIGN(TracingApp);
diff --git a/services/tracing/tracing.mojom b/services/tracing/tracing.mojom
index 1227988..64bbd20 100644
--- a/services/tracing/tracing.mojom
+++ b/services/tracing/tracing.mojom
@@ -6,19 +6,16 @@
// To particate in the tracing ecosystem, implement the TraceController
// interface and connect to the tracing app. Then, when the controller's Start()
-// function is called collect tracing data and pass it back via the
+// function is called collect tracing data and pass it back via the provided
// TraceDataCollector interface up until Stop() is called.
-[Client=TraceDataCollector]
interface TraceController {
- StartTracing(string categories);
+ StartTracing(string categories, TraceDataCollector collector);
StopTracing();
};
-[Client=TraceController]
interface TraceDataCollector {
DataCollected(string json);
- EndTracing();
};
interface TraceCoordinator {
diff --git a/services/view_manager/view_manager_app.cc b/services/view_manager/view_manager_app.cc
index e3a6989..e107a32 100644
--- a/services/view_manager/view_manager_app.cc
+++ b/services/view_manager/view_manager_app.cc
@@ -4,6 +4,7 @@
#include "services/view_manager/view_manager_app.h"
+#include "mojo/application/application_runner_chromium.h"
#include "mojo/common/tracing_impl.h"
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/application/application_connection.h"
@@ -25,7 +26,7 @@
ViewManagerApp::~ViewManagerApp() {}
void ViewManagerApp::Initialize(ApplicationImpl* app) {
- mojo::TracingImpl::Create(app);
+ tracing_.Initialize(app);
}
bool ViewManagerApp::ConfigureIncomingConnection(
diff --git a/services/view_manager/view_manager_app.h b/services/view_manager/view_manager_app.h
index e4eb943..ece4740 100644
--- a/services/view_manager/view_manager_app.h
+++ b/services/view_manager/view_manager_app.h
@@ -6,6 +6,7 @@
#define SERVICES_VIEW_MANAGER_VIEW_MANAGER_APP_H_
#include "base/memory/scoped_ptr.h"
+#include "mojo/common/tracing_impl.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/public/cpp/bindings/binding.h"
@@ -60,6 +61,7 @@
wm_internal_client_binding_;
mojo::WindowManagerInternalPtr wm_internal_;
scoped_ptr<ConnectionManager> connection_manager_;
+ mojo::TracingImpl tracing_;
DISALLOW_COPY_AND_ASSIGN(ViewManagerApp);
};
diff --git a/services/window_manager/BUILD.gn b/services/window_manager/BUILD.gn
index e84f071..9c77b87 100644
--- a/services/window_manager/BUILD.gn
+++ b/services/window_manager/BUILD.gn
@@ -18,6 +18,7 @@
deps = [
"//base",
"//mojo/application",
+ "//mojo/common:tracing_impl",
"//mojo/services/view_manager/public/cpp",
]
}
diff --git a/services/window_manager/main.cc b/services/window_manager/main.cc
index acb02a8..17143a4 100644
--- a/services/window_manager/main.cc
+++ b/services/window_manager/main.cc
@@ -4,6 +4,7 @@
#include "base/memory/scoped_ptr.h"
#include "mojo/application/application_runner_chromium.h"
+#include "mojo/common/tracing_impl.h"
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/service_provider_impl.h"
@@ -36,6 +37,7 @@
// Overridden from mojo::ApplicationDelegate:
void Initialize(mojo::ApplicationImpl* impl) override {
window_manager_app_->Initialize(impl);
+ tracing_.Initialize(impl);
}
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override {
@@ -73,6 +75,7 @@
View* root_;
int window_offset_;
+ mojo::TracingImpl tracing_;
MOJO_DISALLOW_COPY_AND_ASSIGN(DefaultWindowManager);
};
diff --git a/shell/context.cc b/shell/context.cc
index 4baac09..21caefa 100644
--- a/shell/context.cc
+++ b/shell/context.cc
@@ -18,6 +18,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
+#include "mojo/common/trace_controller_impl.h"
#include "mojo/common/tracing_impl.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/simple_platform_support.h"
@@ -146,6 +147,26 @@
return true;
}
+class TracingServiceProvider : public ServiceProvider {
+ public:
+ explicit TracingServiceProvider(InterfaceRequest<ServiceProvider> request)
+ : binding_(this, request.Pass()) {}
+ ~TracingServiceProvider() override {}
+
+ void ConnectToService(const mojo::String& service_name,
+ ScopedMessagePipeHandle client_handle) override {
+ if (service_name == tracing::TraceController::Name_) {
+ new TraceControllerImpl(
+ MakeRequest<tracing::TraceController>(client_handle.Pass()));
+ }
+ }
+
+ private:
+ StrongBinding<ServiceProvider> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(TracingServiceProvider);
+};
+
} // namespace
Context::Context() : application_manager_(this) {
@@ -229,10 +250,11 @@
application_manager_.set_default_loader(
scoped_ptr<ApplicationLoader>(dynamic_application_loader));
- tracing::TraceDataCollectorPtr trace_data_collector_ptr;
- application_manager_.ConnectToService(GURL("mojo:tracing"),
- &trace_data_collector_ptr);
- TracingImpl::Create(trace_data_collector_ptr.Pass());
+ ServiceProviderPtr tracing_service_provider_ptr;
+ new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr));
+ application_manager_.ConnectToApplication(
+ GURL("mojo:tracing"), GURL(""), nullptr,
+ tracing_service_provider_ptr.Pass());
if (listener_)
listener_->WaitForListening();
diff --git a/sky/tools/debugger/trace_collector.cc b/sky/tools/debugger/trace_collector.cc
index 75345db..6232d7d 100644
--- a/sky/tools/debugger/trace_collector.cc
+++ b/sky/tools/debugger/trace_collector.cc
@@ -15,7 +15,8 @@
}
void TraceCollector::GetTrace(TraceCallback callback) {
- DCHECK(!callback_.is_null());
+ DCHECK(callback_.is_null());
+ DCHECK(!callback.is_null());
if (is_complete_) {
callback.Run(GetTraceAsString());
return;
diff --git a/sky/viewer/viewer.cc b/sky/viewer/viewer.cc
index 5850dec..7ca33ee 100644
--- a/sky/viewer/viewer.cc
+++ b/sky/viewer/viewer.cc
@@ -38,7 +38,7 @@
blink::initialize(platform_impl_.get());
mojo::icu::Initialize(app);
- mojo::TracingImpl::Create(app);
+ tracing_.Initialize(app);
}
virtual bool ConfigureIncomingConnection(
@@ -54,11 +54,12 @@
}
scoped_ptr<PlatformImpl> platform_impl_;
+ mojo::TracingImpl tracing_;
DISALLOW_COPY_AND_ASSIGN(Viewer);
};
-} // namespace mojo
+} // namespace sky
MojoResult MojoMain(MojoHandle shell_handle) {
mojo::ApplicationRunnerChromium runner(new sky::Viewer);