| Index: content/browser/tracing/tracing_controller_impl.cc
|
| diff --git a/content/browser/tracing/tracing_controller_impl.cc b/content/browser/tracing/tracing_controller_impl.cc
|
| index 13a5333fe5a642659586045f42420e0b4ed51aad..de64f832b36d7de84b00464d8e1924a46229444f 100644
|
| --- a/content/browser/tracing/tracing_controller_impl.cc
|
| +++ b/content/browser/tracing/tracing_controller_impl.cc
|
| @@ -45,7 +45,6 @@ namespace {
|
| base::LazyInstance<TracingControllerImpl>::Leaky g_controller =
|
| LAZY_INSTANCE_INITIALIZER;
|
|
|
| -
|
| std::string GetNetworkTypeString() {
|
| switch (net::NetworkChangeNotifier::GetConnectionType()) {
|
| case net::NetworkChangeNotifier::CONNECTION_ETHERNET:
|
| @@ -145,6 +144,7 @@ TracingControllerImpl::TracingControllerImpl()
|
| approximate_event_count_(0),
|
| pending_memory_dump_ack_count_(0),
|
| failed_memory_dump_count_(0),
|
| + start_tracing_done_callback_(StartTracingDoneCallback()),
|
| // Tracing may have been enabled by ContentMainRunner if kTraceStartup
|
| // is specified in command line.
|
| #if defined(OS_CHROMEOS) || defined(OS_WIN)
|
| @@ -214,6 +214,7 @@ bool TracingControllerImpl::StartTracing(
|
| if (!can_start_tracing())
|
| return false;
|
| is_tracing_ = true;
|
| + start_tracing_done_callback_ = callback;
|
|
|
| #if defined(OS_ANDROID)
|
| if (pending_get_categories_done_callback_.is_null())
|
| @@ -222,16 +223,17 @@ bool TracingControllerImpl::StartTracing(
|
|
|
| if (trace_config.IsSystraceEnabled()) {
|
| DCHECK(!is_power_tracing_);
|
| - is_power_tracing_ = PowerTracingAgent::GetInstance()->StartTracing();
|
| + is_power_tracing_ = PowerTracingAgent::GetInstance()->
|
| + StartAgentTracing(trace_config);
|
| #if defined(OS_CHROMEOS)
|
| DCHECK(!is_system_tracing_);
|
| chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->
|
| - StartSystemTracing();
|
| + StartAgentTracing(trace_config);
|
| is_system_tracing_ = true;
|
| #elif defined(OS_WIN)
|
| DCHECK(!is_system_tracing_);
|
| is_system_tracing_ =
|
| - EtwSystemEventConsumer::GetInstance()->StartSystemTracing();
|
| + EtwSystemEventConsumer::GetInstance()->StartAgentTracing(trace_config);
|
| #endif
|
| }
|
|
|
| @@ -239,28 +241,10 @@ bool TracingControllerImpl::StartTracing(
|
| if (TraceLog::GetInstance()->IsEnabled())
|
| return true;
|
|
|
| - base::Closure on_start_tracing_done_callback =
|
| - base::Bind(&TracingControllerImpl::OnStartTracingDone,
|
| - base::Unretained(this),
|
| - trace_config, callback);
|
| - if (!BrowserThread::PostTask(
|
| - BrowserThread::FILE, FROM_HERE,
|
| - base::Bind(&TracingControllerImpl::SetEnabledOnFileThread,
|
| - base::Unretained(this), trace_config,
|
| - base::trace_event::TraceLog::RECORDING_MODE,
|
| - on_start_tracing_done_callback))) {
|
| - // BrowserThread::PostTask fails if the threads haven't been created yet,
|
| - // so it should be safe to just use TraceLog::SetEnabled directly.
|
| - base::trace_event::TraceLog::GetInstance()->SetEnabled(
|
| - trace_config, base::trace_event::TraceLog::RECORDING_MODE);
|
| - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| - on_start_tracing_done_callback);
|
| - }
|
| -
|
| - return true;
|
| + return StartAgentTracing(trace_config);
|
| }
|
|
|
| -void TracingControllerImpl::OnStartTracingDone(
|
| +void TracingControllerImpl::OnStartAgentTracingDone(
|
| const TraceConfig& trace_config,
|
| const StartTracingDoneCallback& callback) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| @@ -326,12 +310,14 @@ void TracingControllerImpl::OnStopTracingDone() {
|
| BrowserThread::GetBlockingPool();
|
| chromeos::DBusThreadManager::Get()
|
| ->GetDebugDaemonClient()
|
| - ->RequestStopSystemTracing(
|
| - task_runner,
|
| + ->SetStopAgentTracingTaskRunner(task_runner);
|
| + chromeos::DBusThreadManager::Get()
|
| + ->GetDebugDaemonClient()
|
| + ->StopAgentTracing(
|
| base::Bind(&TracingControllerImpl::OnEndSystemTracingAcked,
|
| base::Unretained(this)));
|
| #elif defined(OS_WIN)
|
| - EtwSystemEventConsumer::GetInstance()->StopSystemTracing(
|
| + EtwSystemEventConsumer::GetInstance()->StopAgentTracing(
|
| base::Bind(&TracingControllerImpl::OnEndSystemTracingAcked,
|
| base::Unretained(this)));
|
| #endif
|
| @@ -341,37 +327,12 @@ void TracingControllerImpl::OnStopTracingDone() {
|
| if (is_power_tracing_) {
|
| is_power_tracing_ = false;
|
| ++pending_stop_tracing_ack_count_;
|
| - PowerTracingAgent::GetInstance()->StopTracing(
|
| + PowerTracingAgent::GetInstance()->StopAgentTracing(
|
| base::Bind(&TracingControllerImpl::OnEndPowerTracingAcked,
|
| base::Unretained(this)));
|
| }
|
|
|
| - // Handle special case of zero child processes by immediately flushing the
|
| - // trace log. Once the flush has completed the caller will be notified that
|
| - // tracing has ended.
|
| - if (pending_stop_tracing_ack_count_ == 1) {
|
| - // Flush/cancel asynchronously now, because we don't have any children to
|
| - // wait for.
|
| - if (trace_data_sink_) {
|
| - TraceLog::GetInstance()->Flush(
|
| - base::Bind(&TracingControllerImpl::OnLocalTraceDataCollected,
|
| - base::Unretained(this)),
|
| - true);
|
| - } else {
|
| - TraceLog::GetInstance()->CancelTracing(
|
| - base::Bind(&TracingControllerImpl::OnLocalTraceDataCollected,
|
| - base::Unretained(this)));
|
| - }
|
| - }
|
| -
|
| - // Notify all child processes.
|
| - for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin();
|
| - it != trace_message_filters_.end(); ++it) {
|
| - if (trace_data_sink_)
|
| - it->get()->SendEndTracing();
|
| - else
|
| - it->get()->SendCancelTracing();
|
| - }
|
| + StopAgentTracing(StopAgentTracingCallback());
|
| }
|
|
|
| bool TracingControllerImpl::StartMonitoring(
|
| @@ -914,6 +875,82 @@ void TracingControllerImpl::UnregisterTracingUI(TracingUI* tracing_ui) {
|
| tracing_uis_.erase(it);
|
| }
|
|
|
| +std::string TracingControllerImpl::GetTracingAgentName() {
|
| + return kChromeTracingAgentName;
|
| +}
|
| +
|
| +bool TracingControllerImpl::StartAgentTracing(
|
| + const base::trace_event::TraceConfig& trace_config) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + base::Closure on_start_tracing_done_callback =
|
| + base::Bind(&TracingControllerImpl::OnStartAgentTracingDone,
|
| + base::Unretained(this),
|
| + trace_config, start_tracing_done_callback_);
|
| + if (!BrowserThread::PostTask(
|
| + BrowserThread::FILE, FROM_HERE,
|
| + base::Bind(&TracingControllerImpl::SetEnabledOnFileThread,
|
| + base::Unretained(this), trace_config,
|
| + base::trace_event::TraceLog::RECORDING_MODE,
|
| + on_start_tracing_done_callback))) {
|
| + // BrowserThread::PostTask fails if the threads haven't been created yet,
|
| + // so it should be safe to just use TraceLog::SetEnabled directly.
|
| + base::trace_event::TraceLog::GetInstance()->SetEnabled(
|
| + trace_config, base::trace_event::TraceLog::RECORDING_MODE);
|
| + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| + on_start_tracing_done_callback);
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| +void TracingControllerImpl::StopAgentTracing(
|
| + const StopAgentTracingCallback& callback) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + // Handle special case of zero child processes by immediately flushing the
|
| + // trace log. Once the flush has completed the caller will be notified that
|
| + // tracing has ended.
|
| + if (pending_stop_tracing_ack_count_ == 1) {
|
| + // Flush/cancel asynchronously now, because we don't have any children to
|
| + // wait for.
|
| + if (trace_data_sink_) {
|
| + TraceLog::GetInstance()->Flush(
|
| + base::Bind(&TracingControllerImpl::OnLocalTraceDataCollected,
|
| + base::Unretained(this)),
|
| + true);
|
| + } else {
|
| + TraceLog::GetInstance()->CancelTracing(
|
| + base::Bind(&TracingControllerImpl::OnLocalTraceDataCollected,
|
| + base::Unretained(this)));
|
| + }
|
| + }
|
| +
|
| + // Notify all child processes.
|
| + for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin();
|
| + it != trace_message_filters_.end(); ++it) {
|
| + if (trace_data_sink_)
|
| + it->get()->SendEndTracing();
|
| + else
|
| + it->get()->SendCancelTracing();
|
| + }
|
| +}
|
| +
|
| +bool TracingControllerImpl::SupportsExplicitClockSync() {
|
| + // TODO(zhenw): return true after implementing explicit clock sync.
|
| + return false;
|
| +}
|
| +
|
| +void TracingControllerImpl::RecordClockSyncMarker(
|
| + scoped_ptr<base::DictionaryValue> marker) {
|
| + DCHECK(SupportsExplicitClockSync());
|
| + // TODO(zhenw): implement explicit clock sync.
|
| +}
|
| +
|
| +void TracingControllerImpl::IssueClockSyncMarker() {
|
| + DCHECK(SupportsExplicitClockSync());
|
| + // TODO(zhenw): implement explicit clock sync.
|
| +}
|
| +
|
| void TracingControllerImpl::RequestGlobalMemoryDump(
|
| const base::trace_event::MemoryDumpRequestArgs& args,
|
| const base::trace_event::MemoryDumpCallback& callback) {
|
|
|