OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/tracing/background_tracing_manager_impl.h" | 5 #include "content/browser/tracing/background_tracing_manager_impl.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
11 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
13 #include "content/browser/tracing/background_tracing_rule.h" | 15 #include "content/browser/tracing/background_tracing_rule.h" |
14 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.h" |
16 #include "content/public/browser/tracing_delegate.h" | 18 #include "content/public/browser/tracing_delegate.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 command_line->HasSwitch(switches::kEnableBlinkFeatures)) { | 154 command_line->HasSwitch(switches::kEnableBlinkFeatures)) { |
153 return false; | 155 return false; |
154 } | 156 } |
155 | 157 |
156 if (!config_impl->disable_blink_features().empty() && | 158 if (!config_impl->disable_blink_features().empty() && |
157 command_line->HasSwitch(switches::kDisableBlinkFeatures)) { | 159 command_line->HasSwitch(switches::kDisableBlinkFeatures)) { |
158 return false; | 160 return false; |
159 } | 161 } |
160 } | 162 } |
161 | 163 |
162 config_ = config_impl.Pass(); | 164 config_ = std::move(config_impl); |
163 receive_callback_ = receive_callback; | 165 receive_callback_ = receive_callback; |
164 requires_anonymized_data_ = requires_anonymized_data; | 166 requires_anonymized_data_ = requires_anonymized_data; |
165 | 167 |
166 if (config_) { | 168 if (config_) { |
167 DCHECK(!config_.get()->rules().empty()); | 169 DCHECK(!config_.get()->rules().empty()); |
168 for (auto& rule : config_.get()->rules()) | 170 for (auto& rule : config_.get()->rules()) |
169 static_cast<BackgroundTracingRule*>(rule)->Install(); | 171 static_cast<BackgroundTracingRule*>(rule)->Install(); |
170 | 172 |
171 if (!config_->enable_blink_features().empty()) { | 173 if (!config_->enable_blink_features().empty()) { |
172 command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures, | 174 command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures, |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 scoped_ptr<const base::DictionaryValue> metadata, | 403 scoped_ptr<const base::DictionaryValue> metadata, |
402 base::RefCountedString* file_contents) { | 404 base::RefCountedString* file_contents) { |
403 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 405 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
404 | 406 |
405 RecordBackgroundTracingMetric(FINALIZATION_STARTED); | 407 RecordBackgroundTracingMetric(FINALIZATION_STARTED); |
406 UMA_HISTOGRAM_MEMORY_KB("Tracing.Background.FinalizingTraceSizeInKB", | 408 UMA_HISTOGRAM_MEMORY_KB("Tracing.Background.FinalizingTraceSizeInKB", |
407 file_contents->size() / 1024); | 409 file_contents->size() / 1024); |
408 | 410 |
409 if (!receive_callback_.is_null()) { | 411 if (!receive_callback_.is_null()) { |
410 receive_callback_.Run( | 412 receive_callback_.Run( |
411 file_contents, metadata.Pass(), | 413 file_contents, std::move(metadata), |
412 base::Bind(&BackgroundTracingManagerImpl::OnFinalizeComplete, | 414 base::Bind(&BackgroundTracingManagerImpl::OnFinalizeComplete, |
413 base::Unretained(this))); | 415 base::Unretained(this))); |
414 } | 416 } |
415 } | 417 } |
416 | 418 |
417 void BackgroundTracingManagerImpl::OnFinalizeComplete() { | 419 void BackgroundTracingManagerImpl::OnFinalizeComplete() { |
418 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 420 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
419 BrowserThread::PostTask( | 421 BrowserThread::PostTask( |
420 BrowserThread::UI, FROM_HERE, | 422 BrowserThread::UI, FROM_HERE, |
421 base::Bind(&BackgroundTracingManagerImpl::OnFinalizeComplete, | 423 base::Bind(&BackgroundTracingManagerImpl::OnFinalizeComplete, |
(...skipping 23 matching lines...) Expand all Loading... |
445 | 447 |
446 RecordBackgroundTracingMetric(FINALIZATION_COMPLETE); | 448 RecordBackgroundTracingMetric(FINALIZATION_COMPLETE); |
447 } | 449 } |
448 | 450 |
449 void BackgroundTracingManagerImpl::AddCustomMetadata( | 451 void BackgroundTracingManagerImpl::AddCustomMetadata( |
450 TracingControllerImpl::TraceDataSink* trace_data_sink) const { | 452 TracingControllerImpl::TraceDataSink* trace_data_sink) const { |
451 base::DictionaryValue metadata_dict; | 453 base::DictionaryValue metadata_dict; |
452 | 454 |
453 scoped_ptr<base::DictionaryValue> config_dict(new base::DictionaryValue()); | 455 scoped_ptr<base::DictionaryValue> config_dict(new base::DictionaryValue()); |
454 config_->IntoDict(config_dict.get()); | 456 config_->IntoDict(config_dict.get()); |
455 metadata_dict.Set("config", config_dict.Pass()); | 457 metadata_dict.Set("config", std::move(config_dict)); |
456 | 458 |
457 trace_data_sink->AddMetadata(metadata_dict); | 459 trace_data_sink->AddMetadata(metadata_dict); |
458 } | 460 } |
459 | 461 |
460 void BackgroundTracingManagerImpl::BeginFinalizing( | 462 void BackgroundTracingManagerImpl::BeginFinalizing( |
461 StartedFinalizingCallback callback) { | 463 StartedFinalizingCallback callback) { |
462 is_gathering_ = true; | 464 is_gathering_ = true; |
463 is_tracing_ = false; | 465 is_tracing_ = false; |
464 triggered_named_event_handle_ = -1; | 466 triggered_named_event_handle_ = -1; |
465 tracing_timer_.reset(); | 467 tracing_timer_.reset(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 "disabled-by-default-toplevel.flow," | 516 "disabled-by-default-toplevel.flow," |
515 "disabled-by-default-ipc.flow"; | 517 "disabled-by-default-ipc.flow"; |
516 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: | 518 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: |
517 return "blink_style"; | 519 return "blink_style"; |
518 } | 520 } |
519 NOTREACHED(); | 521 NOTREACHED(); |
520 return ""; | 522 return ""; |
521 } | 523 } |
522 | 524 |
523 } // namspace content | 525 } // namspace content |
OLD | NEW |