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

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

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
Patch Set: . Created 4 years, 10 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
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "base/threading/platform_thread.h" 11 #include "base/threading/platform_thread.h"
12 #include "base/trace_event/trace_event_impl.h" 12 #include "base/trace_event/trace_event_impl.h"
13 #include "mojo/shell/public/cpp/application_impl.h" 13 #include "mojo/shell/public/cpp/shell.h"
14 14
15 #ifdef NDEBUG 15 #ifdef NDEBUG
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "mojo/services/tracing/public/cpp/switches.h" 17 #include "mojo/services/tracing/public/cpp/switches.h"
18 #endif 18 #endif
19 19
20 namespace mojo { 20 namespace mojo {
21 namespace { 21 namespace {
22 22
23 // Controls access to |g_tracing_singleton_created|, which can be accessed from 23 // Controls access to |g_tracing_singleton_created|, which can be accessed from
(...skipping 10 matching lines...) Expand all
34 bool g_tracing_singleton_created = false; 34 bool g_tracing_singleton_created = false;
35 35
36 } 36 }
37 37
38 TracingImpl::TracingImpl() { 38 TracingImpl::TracingImpl() {
39 } 39 }
40 40
41 TracingImpl::~TracingImpl() { 41 TracingImpl::~TracingImpl() {
42 } 42 }
43 43
44 void TracingImpl::Initialize(ApplicationImpl* app) { 44 void TracingImpl::Initialize(Shell* shell, const std::string& url) {
45 { 45 {
46 base::AutoLock lock(g_singleton_lock.Get()); 46 base::AutoLock lock(g_singleton_lock.Get());
47 if (g_tracing_singleton_created) 47 if (g_tracing_singleton_created)
48 return; 48 return;
49 g_tracing_singleton_created = true; 49 g_tracing_singleton_created = true;
50 } 50 }
51 51
52 // This will only set the name for the first app in a loaded mojo file. It's 52 // This will only set the name for the first app in a loaded mojo file. It's
53 // up to something like CoreServices to name its own child threads. 53 // up to something like CoreServices to name its own child threads.
54 base::PlatformThread::SetName(app->url()); 54 base::PlatformThread::SetName(url);
55 55
56 connection_ = app->ConnectToApplication("mojo:tracing"); 56 connection_ = shell->ConnectToApplication("mojo:tracing");
57 connection_->AddService(this); 57 connection_->AddService(this);
58 58
59 #ifdef NDEBUG 59 #ifdef NDEBUG
60 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 60 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
61 tracing::kEarlyTracing)) { 61 tracing::kEarlyTracing)) {
62 provider_impl_.ForceEnableTracing(); 62 provider_impl_.ForceEnableTracing();
63 } 63 }
64 #else 64 #else
65 provider_impl_.ForceEnableTracing(); 65 provider_impl_.ForceEnableTracing();
66 #endif 66 #endif
67 } 67 }
68 68
69 void TracingImpl::Create(ApplicationConnection* connection, 69 void TracingImpl::Create(ApplicationConnection* connection,
70 InterfaceRequest<tracing::TraceProvider> request) { 70 InterfaceRequest<tracing::TraceProvider> request) {
71 provider_impl_.Bind(std::move(request)); 71 provider_impl_.Bind(std::move(request));
72 } 72 }
73 73
74 } // namespace mojo 74 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/tracing/public/cpp/tracing_impl.h ('k') | mojo/shell/application_manager_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698