Index: content/browser/browser_main_loop.cc |
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc |
index 8030f7c9e2464ca54f96d2ac110a182376ae7ac7..bba31d2a778b3bf1608b46741bf955bb74d62adb 100644 |
--- a/content/browser/browser_main_loop.cc |
+++ b/content/browser/browser_main_loop.cc |
@@ -75,6 +75,7 @@ |
#include "content/browser/service_manager/service_manager_context.h" |
#include "content/browser/speech/speech_recognition_manager_impl.h" |
#include "content/browser/startup_task_runner.h" |
+#include "content/browser/tracing/tracing_controller_impl.h" |
#include "content/browser/utility_process_host_impl.h" |
#include "content/browser/webui/content_web_ui_controller_factory.h" |
#include "content/browser/webui/url_data_manager.h" |
@@ -103,6 +104,9 @@ |
#include "net/ssl/ssl_config_service.h" |
#include "ppapi/features/features.h" |
#include "services/resource_coordinator/memory/coordinator/coordinator_impl.h" |
+#include "services/resource_coordinator/public/cpp/tracing/chrome_agent.h" |
+#include "services/resource_coordinator/public/interfaces/tracing/tracing.mojom.h" |
+#include "services/resource_coordinator/tracing/coordinator_impl.h" |
#include "services/service_manager/runner/common/client_util.h" |
#include "skia/ext/event_tracer_impl.h" |
#include "skia/ext/skia_memory_dump_provider.h" |
@@ -725,35 +729,6 @@ void BrowserMainLoop::PostMainMessageLoopStart() { |
if (parts_) |
parts_->PostMainMessageLoopStart(); |
- // Start startup tracing through TracingController's interface. TraceLog has |
- // been enabled in content_main_runner where threads are not available. Now We |
- // need to start tracing for all other tracing agents, which require threads. |
- if (parsed_command_line_.HasSwitch(switches::kTraceStartup)) { |
- base::trace_event::TraceConfig trace_config( |
- parsed_command_line_.GetSwitchValueASCII(switches::kTraceStartup), |
- base::trace_event::RECORD_UNTIL_FULL); |
- TracingController::GetInstance()->StartTracing( |
- trace_config, |
- TracingController::StartTracingDoneCallback()); |
- } else if (parsed_command_line_.HasSwitch(switches::kTraceToConsole)) { |
- TracingController::GetInstance()->StartTracing( |
- tracing::GetConfigForTraceToConsole(), |
- TracingController::StartTracingDoneCallback()); |
- } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) { |
- // This checks kTraceConfigFile switch. |
- TracingController::GetInstance()->StartTracing( |
- tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), |
- TracingController::StartTracingDoneCallback()); |
- } |
- // Start tracing to a file for certain duration if needed. Only do this after |
- // starting the main message loop to avoid calling |
- // MessagePumpForUI::ScheduleWork() before MessagePumpForUI::Start() as it |
- // will crash the browser. |
- if (is_tracing_startup_for_duration_) { |
- TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracingForDuration"); |
- InitStartupTracingForDuration(parsed_command_line_); |
- } |
- |
#if defined(OS_ANDROID) |
{ |
TRACE_EVENT0("startup", |
@@ -1393,6 +1368,48 @@ int BrowserMainLoop::BrowserThreadsStarted() { |
// so this cannot happen any earlier than now. |
InitializeMojo(); |
+ if (service_manager::ServiceManagerIsRemote()) { |
+ service_manager::Connector* connector = |
+ content::ServiceManagerConnection::GetForProcess()->GetConnector(); |
+ TracingControllerImpl::GetInstance()->Initialize(connector); |
+ |
+ resource_coordinator::tracing::mojom::AgentSetPtr agent_set; |
+ connector->BindInterface("tracing", mojo::MakeRequest(&agent_set)); |
+ resource_coordinator::tracing::ChromeAgent::InitializeIfNeeded( |
+ std::move(agent_set)); |
+ } else { |
+ tracing_coordinator_ = |
+ base::MakeUnique<resource_coordinator::tracing::CoordinatorImpl>(); |
+ TracingControllerImpl::GetInstance()->Initialize(nullptr); |
+ } |
+ // Start startup tracing through TracingController's interface. TraceLog has |
+ // been enabled in content_main_runner where threads are not available. Now We |
+ // need to start tracing for all other tracing agents, which require threads. |
+ if (parsed_command_line_.HasSwitch(switches::kTraceStartup)) { |
+ base::trace_event::TraceConfig trace_config( |
+ parsed_command_line_.GetSwitchValueASCII(switches::kTraceStartup), |
+ base::trace_event::RECORD_UNTIL_FULL); |
+ TracingControllerImpl::GetInstance()->StartTracing( |
+ trace_config, TracingControllerImpl::StartTracingDoneCallback()); |
+ } else if (parsed_command_line_.HasSwitch(switches::kTraceToConsole)) { |
+ TracingControllerImpl::GetInstance()->StartTracing( |
+ tracing::GetConfigForTraceToConsole(), |
+ TracingControllerImpl::StartTracingDoneCallback()); |
+ } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) { |
+ // This checks kTraceConfigFile switch. |
+ TracingControllerImpl::GetInstance()->StartTracing( |
+ tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), |
+ TracingControllerImpl::StartTracingDoneCallback()); |
+ } |
+ // Start tracing to a file for certain duration if needed. Only do this after |
+ // starting the main message loop to avoid calling |
+ // MessagePumpForUI::ScheduleWork() before MessagePumpForUI::Start() as it |
+ // will crash the browser. |
+ if (is_tracing_startup_for_duration_) { |
+ TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracingForDuration"); |
+ InitStartupTracingForDuration(parsed_command_line_); |
+ } |
+ |
#if defined(USE_AURA) |
if (service_manager::ServiceManagerIsRemote()) { |
base::CommandLine::ForCurrentProcess()->AppendSwitch( |
@@ -1752,8 +1769,8 @@ void BrowserMainLoop::EndStartupTracing() { |
DCHECK(is_tracing_startup_for_duration_); |
is_tracing_startup_for_duration_ = false; |
- TracingController::GetInstance()->StopTracing( |
- TracingController::CreateFileSink( |
+ TracingControllerImpl::GetInstance()->StopTracing( |
+ TracingControllerImpl::CreateFileSink( |
startup_trace_file_, |
base::Bind(OnStoppedStartupTracing, startup_trace_file_))); |
} |