| 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/callback.h" |
| 8 #include "base/time/time.h" |
| 9 #include "base/trace_event/trace_config.h" |
| 10 #include "base/trace_event/trace_event.h" |
| 7 #include "base/trace_event/trace_event_impl.h" | 11 #include "base/trace_event/trace_event_impl.h" |
| 8 #include "mojo/common/trace_provider_impl.h" | |
| 9 #include "mojo/public/cpp/application/application_connection.h" | 12 #include "mojo/public/cpp/application/application_connection.h" |
| 10 #include "mojo/public/cpp/application/application_impl.h" | 13 #include "mojo/public/cpp/application/application_impl.h" |
| 11 | 14 |
| 12 namespace mojo { | 15 namespace mojo { |
| 13 | 16 |
| 14 TracingImpl::TracingImpl() { | 17 TracingImpl::TracingImpl() : binding_(&provider_impl_) {} |
| 15 } | |
| 16 | 18 |
| 17 TracingImpl::~TracingImpl() { | 19 TracingImpl::~TracingImpl() {} |
| 18 } | |
| 19 | 20 |
| 20 void TracingImpl::Initialize(ApplicationImpl* app) { | 21 void TracingImpl::Initialize(ApplicationImpl* app) { |
| 21 ApplicationConnection* connection = app->ConnectToApplication("mojo:tracing"); | 22 ApplicationConnection* connection = app->ConnectToApplication("mojo:tracing"); |
| 22 connection->AddService(this); | 23 connection->AddService(this); |
| 24 |
| 25 #ifdef NDEBUG |
| 26 if (app->HasArg("--early-tracing")) { |
| 27 provider_impl_.EnableTracingNow(); |
| 28 } |
| 29 #else |
| 30 provider_impl_.EnableTracingNow(); |
| 31 #endif |
| 23 } | 32 } |
| 24 | 33 |
| 25 void TracingImpl::Create(ApplicationConnection* connection, | 34 void TracingImpl::Create(ApplicationConnection* connection, |
| 26 InterfaceRequest<tracing::TraceProvider> request) { | 35 InterfaceRequest<tracing::TraceProvider> request) { |
| 27 new TraceProviderImpl(request.Pass()); | 36 if (!binding_.is_bound()) { |
| 37 binding_.Bind(request.Pass()); |
| 38 } else { |
| 39 LOG(ERROR) << "Cannot accept two connections to TraceProvider; " |
| 40 << "last one from " << connection->GetRemoteApplicationURL(); |
| 41 } |
| 28 } | 42 } |
| 29 | 43 |
| 30 } // namespace mojo | 44 } // namespace mojo |
| OLD | NEW |