OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/common/tracing_impl.h" | 5 #include "mojo/common/tracing_impl.h" |
6 | 6 |
7 #include "base/trace_event/trace_event_impl.h" | 7 #include "base/trace_event/trace_event_impl.h" |
8 #include "mojo/public/cpp/application/application_impl.h" | 8 #include "mojo/public/cpp/application/application_impl.h" |
| 9 #include "mojo/public/cpp/application/connect.h" |
9 #include "mojo/public/cpp/bindings/interface_handle.h" | 10 #include "mojo/public/cpp/bindings/interface_handle.h" |
10 #include "mojo/public/cpp/bindings/interface_request.h" | 11 #include "mojo/public/cpp/bindings/interface_request.h" |
11 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 12 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 13 #include "mojo/services/tracing/interfaces/trace_provider_registry.mojom.h" |
| 14 #include "mojo/services/tracing/interfaces/tracing.mojom.h" |
12 | 15 |
13 namespace mojo { | 16 namespace mojo { |
14 | 17 |
15 TracingImpl::TracingImpl() {} | 18 TracingImpl::TracingImpl() {} |
16 | 19 |
17 TracingImpl::~TracingImpl() {} | 20 TracingImpl::~TracingImpl() {} |
18 | 21 |
19 void TracingImpl::Initialize(ApplicationImpl* app) { | 22 void TracingImpl::Initialize(ApplicationImpl* app) { |
20 InterfaceHandle<ServiceProvider> outgoing_sp_handle; | 23 tracing::TraceProviderRegistryPtr registry; |
21 InterfaceRequest<ServiceProvider> outgoing_sp_request = | 24 ConnectToService(app->shell(), "mojo:tracing", GetProxy(®istry)); |
22 GetProxy(&outgoing_sp_handle); | 25 |
23 app->shell()->ConnectToApplication("mojo:tracing", nullptr, | 26 mojo::InterfaceHandle<tracing::TraceProvider> provider; |
24 outgoing_sp_handle.Pass()); | 27 provider_impl_.Bind(GetProxy(&provider)); |
25 outgoing_sp_for_tracing_service_.Bind(outgoing_sp_request.Pass()); | 28 registry->RegisterTraceProvider(provider.Pass()); |
26 outgoing_sp_for_tracing_service_.AddService(this); | |
27 | 29 |
28 #ifdef NDEBUG | 30 #ifdef NDEBUG |
29 if (app->HasArg("--early-tracing")) { | 31 if (app->HasArg("--early-tracing")) { |
30 provider_impl_.ForceEnableTracing(); | 32 provider_impl_.ForceEnableTracing(); |
31 } | 33 } |
32 #else | 34 #else |
33 provider_impl_.ForceEnableTracing(); | 35 provider_impl_.ForceEnableTracing(); |
34 #endif | 36 #endif |
35 } | 37 } |
36 | 38 |
37 void TracingImpl::Create(ApplicationConnection* connection, | |
38 InterfaceRequest<tracing::TraceProvider> request) { | |
39 provider_impl_.Bind(request.Pass()); | |
40 } | |
41 | |
42 } // namespace mojo | 39 } // namespace mojo |
OLD | NEW |