Chromium Code Reviews| Index: content/browser/tracing/background_tracing_manager_impl.cc |
| diff --git a/content/browser/tracing/background_tracing_manager_impl.cc b/content/browser/tracing/background_tracing_manager_impl.cc |
| index 560e5a4c1e40ba6bfe49eb16c6c9f7a1c06d7aa9..7864287f2ca0e2cd6f260499ddeec843377696e9 100644 |
| --- a/content/browser/tracing/background_tracing_manager_impl.cc |
| +++ b/content/browser/tracing/background_tracing_manager_impl.cc |
| @@ -93,6 +93,7 @@ bool BackgroundTracingManagerImpl::IsSupportedConfig( |
| bool BackgroundTracingManagerImpl::SetActiveScenario( |
| scoped_ptr<BackgroundTracingConfig> config, |
| const BackgroundTracingManager::ReceiveCallback& receive_callback, |
| + const base::Closure& enabled_callback, |
| bool requires_anonymized_data) { |
| CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| if (is_tracing_) |
| @@ -109,19 +110,21 @@ bool BackgroundTracingManagerImpl::SetActiveScenario( |
| receive_callback_ = receive_callback; |
| requires_anonymized_data_ = requires_anonymized_data; |
| - EnableRecordingIfConfigNeedsIt(); |
| + EnableRecordingIfConfigNeedsIt(enabled_callback); |
| return true; |
| } |
| -void BackgroundTracingManagerImpl::EnableRecordingIfConfigNeedsIt() { |
| +void BackgroundTracingManagerImpl::EnableRecordingIfConfigNeedsIt( |
| + const base::Closure& enabled_callback) { |
| if (!config_) |
| return; |
| if (config_->mode == BackgroundTracingConfig::PREEMPTIVE_TRACING_MODE) { |
| EnableRecording(GetCategoryFilterForCategoryPreset( |
| - static_cast<BackgroundTracingPreemptiveConfig*>(config_.get()) |
| - ->category_preset)); |
| + static_cast<BackgroundTracingPreemptiveConfig*>( |
| + config_.get())->category_preset), |
| + enabled_callback); |
| } else { |
| // TODO(simonhatch): Implement reactive tracing path. |
| NOTREACHED(); |
| @@ -228,11 +231,15 @@ void BackgroundTracingManagerImpl::InvalidateTriggerHandlesForTesting() { |
| } |
| void BackgroundTracingManagerImpl::EnableRecording( |
| - base::trace_event::CategoryFilter category_filter) { |
| + base::trace_event::CategoryFilter category_filter, |
| + const base::Closure& enabled_callback) { |
| + base::trace_event::TraceOptions trace_options( |
| + base::trace_event::RECORD_CONTINUOUSLY); |
| + trace_options.enable_argument_filter = requires_anonymized_data_; |
|
shatch
2015/05/22 22:21:37
Am I taking crazy pills, or is this not actually u
|
| is_tracing_ = TracingController::GetInstance()->EnableRecording( |
| category_filter, |
| base::trace_event::TraceOptions(base::trace_event::RECORD_CONTINUOUSLY), |
| - TracingController::EnableRecordingDoneCallback()); |
| + enabled_callback); |
| } |
| void BackgroundTracingManagerImpl::OnFinalizeStarted( |
| @@ -241,7 +248,7 @@ void BackgroundTracingManagerImpl::OnFinalizeStarted( |
| if (!receive_callback_.is_null()) |
| receive_callback_.Run( |
| - file_contents.get(), |
| + file_contents, |
| base::Bind(&BackgroundTracingManagerImpl::OnFinalizeComplete, |
| base::Unretained(this))); |
| } |
| @@ -263,7 +270,7 @@ void BackgroundTracingManagerImpl::OnFinalizeComplete() { |
| idle_callback_.Run(); |
| // Now that a trace has completed, we may need to enable recording again. |
| - EnableRecordingIfConfigNeedsIt(); |
| + EnableRecordingIfConfigNeedsIt(base::Closure()); |
| } |
| void BackgroundTracingManagerImpl::BeginFinalizing( |
| @@ -271,9 +278,16 @@ void BackgroundTracingManagerImpl::BeginFinalizing( |
| is_gathering_ = true; |
| is_tracing_ = false; |
| - content::TracingController::GetInstance()->DisableRecording( |
| - content::TracingController::CreateCompressedStringSink( |
| - data_endpoint_wrapper_)); |
| + scoped_refptr<TracingControllerImpl::TraceDataSink> trace_data_sink; |
| + if (config_->compress_trace) { |
| + trace_data_sink = content::TracingController::CreateCompressedStringSink( |
| + data_endpoint_wrapper_); |
| + } else { |
| + trace_data_sink = |
| + content::TracingController::CreateStringSink(data_endpoint_wrapper_); |
| + } |
| + |
| + content::TracingController::GetInstance()->DisableRecording(trace_data_sink); |
| if (!callback.is_null()) |
| callback.Run(true); |