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/services/tracing/public/cpp/tracing_impl.h" | 5 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "base/trace_event/trace_event_impl.h" | 10 #include "base/trace_event/trace_event_impl.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 base::AutoLock lock(g_singleton_lock.Get()); | 44 base::AutoLock lock(g_singleton_lock.Get()); |
45 if (g_tracing_singleton_created) | 45 if (g_tracing_singleton_created) |
46 return; | 46 return; |
47 g_tracing_singleton_created = true; | 47 g_tracing_singleton_created = true; |
48 } | 48 } |
49 | 49 |
50 // This will only set the name for the first app in a loaded mojo file. It's | 50 // This will only set the name for the first app in a loaded mojo file. It's |
51 // up to something like CoreServices to name its own child threads. | 51 // up to something like CoreServices to name its own child threads. |
52 base::PlatformThread::SetName(app->url()); | 52 base::PlatformThread::SetName(app->url()); |
53 | 53 |
54 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 54 connection_ = app->ConnectToApplication("mojo:tracing"); |
55 request->url = mojo::String::From("mojo:tracing"); | |
56 connection_ = app->ConnectToApplication(request.Pass()); | |
57 connection_->AddService(this); | 55 connection_->AddService(this); |
58 | 56 |
59 #ifdef NDEBUG | 57 #ifdef NDEBUG |
60 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 58 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
61 tracing::kEarlyTracing)) { | 59 tracing::kEarlyTracing)) { |
62 provider_impl_.ForceEnableTracing(); | 60 provider_impl_.ForceEnableTracing(); |
63 } | 61 } |
64 #else | 62 #else |
65 provider_impl_.ForceEnableTracing(); | 63 provider_impl_.ForceEnableTracing(); |
66 #endif | 64 #endif |
67 } | 65 } |
68 | 66 |
69 void TracingImpl::Create(ApplicationConnection* connection, | 67 void TracingImpl::Create(ApplicationConnection* connection, |
70 InterfaceRequest<tracing::TraceProvider> request) { | 68 InterfaceRequest<tracing::TraceProvider> request) { |
71 provider_impl_.Bind(request.Pass()); | 69 provider_impl_.Bind(request.Pass()); |
72 } | 70 } |
73 | 71 |
74 } // namespace mojo | 72 } // namespace mojo |
OLD | NEW |