Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: services/tracing/public/cpp/tracing_impl.cc

Issue 2208783002: Make Tracing Service not use outgoing InterfaceProvider, update conventions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/tracing/public/cpp/tracing_impl.h ('k') | services/tracing/public/interfaces/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "services/tracing/public/cpp/tracing_impl.h"
6
7 #include <utility>
8
9 #include "base/lazy_instance.h"
10 #include "base/synchronization/lock.h"
11 #include "base/threading/platform_thread.h"
12 #include "base/trace_event/trace_event_impl.h"
13 #include "services/shell/public/cpp/connector.h"
14
15 #ifdef NDEBUG
16 #include "base/command_line.h"
17 #include "services/tracing/public/cpp/switches.h"
18 #endif
19
20 namespace mojo {
21 namespace {
22
23 // Controls access to |g_tracing_singleton_created|, which can be accessed from
24 // different threads.
25 base::LazyInstance<base::Lock>::Leaky g_singleton_lock =
26 LAZY_INSTANCE_INITIALIZER;
27
28 // Whether we are the first TracingImpl to be created in this mojo
29 // application. The first TracingImpl in a physical mojo application connects
30 // to the mojo:tracing service.
31 //
32 // If this is a ContentHandler, it will outlive all its served Applications. If
33 // this is a raw mojo application, it is the only Application served.
34 bool g_tracing_singleton_created = false;
35
36 }
37
38 TracingImpl::TracingImpl() {
39 }
40
41 TracingImpl::~TracingImpl() {
42 }
43
44 void TracingImpl::Initialize(shell::Connector* connector,
45 const std::string& url) {
46 {
47 base::AutoLock lock(g_singleton_lock.Get());
48 if (g_tracing_singleton_created)
49 return;
50 g_tracing_singleton_created = true;
51 }
52
53 // This will only set the name for the first app in a loaded mojo file. It's
54 // up to something like CoreServices to name its own child threads.
55 base::PlatformThread::SetName(url);
56
57 connection_ = connector->Connect("mojo:tracing");
58 connection_->AddInterface(this);
59
60 #ifdef NDEBUG
61 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
62 tracing::kEarlyTracing)) {
63 provider_impl_.ForceEnableTracing();
64 }
65 #else
66 provider_impl_.ForceEnableTracing();
67 #endif
68 }
69
70 void TracingImpl::Create(const shell::Identity& remote_identity,
71 tracing::TraceProviderRequest request) {
72 provider_impl_.Bind(std::move(request));
73 }
74
75 } // namespace mojo
OLDNEW
« no previous file with comments | « services/tracing/public/cpp/tracing_impl.h ('k') | services/tracing/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698