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

Unified Diff: services/tracing/public/cpp/provider.cc

Issue 2427013002: Make tracing work in service manager (Closed)
Patch Set: Rename InitializeWithFactoryLocked to InitializeWithFactoryInternal Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/tracing/public/cpp/provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/tracing/public/cpp/provider.cc
diff --git a/services/tracing/public/cpp/provider.cc b/services/tracing/public/cpp/provider.cc
index 47e0ab0c0fc6d74e1777fd84f2bcbb549f913c22..66e3a70cd7dba5eb8c1914a7bccbf7186d49311c 100644
--- a/services/tracing/public/cpp/provider.cc
+++ b/services/tracing/public/cpp/provider.cc
@@ -42,6 +42,30 @@ Provider::~Provider() {
StopTracing();
}
+void Provider::InitializeWithFactoryInternal(mojom::FactoryPtr* factory) {
+ mojom::ProviderPtr provider;
+ Bind(GetProxy(&provider));
+ (*factory)->CreateRecorder(std::move(provider));
+#ifdef NDEBUG
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ tracing::kEarlyTracing)) {
+ ForceEnableTracing();
+ }
+#else
+ ForceEnableTracing();
+#endif
+}
+
+void Provider::InitializeWithFactory(mojom::FactoryPtr* factory) {
+ {
+ base::AutoLock lock(g_singleton_lock.Get());
+ if (g_tracing_singleton_created)
+ return;
+ g_tracing_singleton_created = true;
+ }
+ InitializeWithFactoryInternal(factory);
+}
+
void Provider::Initialize(service_manager::Connector* connector,
const std::string& url) {
{
@@ -50,24 +74,12 @@ void Provider::Initialize(service_manager::Connector* connector,
return;
g_tracing_singleton_created = true;
}
-
+ mojom::FactoryPtr factory;
+ connector->ConnectToInterface("service:tracing", &factory);
+ InitializeWithFactoryInternal(&factory);
// This will only set the name for the first app in a loaded mojo file. It's
// up to something like CoreServices to name its own child threads.
base::PlatformThread::SetName(url);
-
- mojom::FactoryPtr factory;
- connector->ConnectToInterface("service:tracing", &factory);
- mojom::ProviderPtr provider;
- Bind(GetProxy(&provider));
- factory->CreateRecorder(std::move(provider));
-#ifdef NDEBUG
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- tracing::kEarlyTracing)) {
- ForceEnableTracing();
- }
-#else
- ForceEnableTracing();
-#endif
}
void Provider::Bind(mojom::ProviderRequest request) {
« no previous file with comments | « services/tracing/public/cpp/provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698