| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 NUMBER_OF_BACKGROUND_TRACING_METRICS, | 45 NUMBER_OF_BACKGROUND_TRACING_METRICS, |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 void RecordBackgroundTracingMetric(BackgroundTracingMetrics metric) { | 48 void RecordBackgroundTracingMetric(BackgroundTracingMetrics metric) { |
| 49 UMA_HISTOGRAM_ENUMERATION("Tracing.Background.ScenarioState", metric, | 49 UMA_HISTOGRAM_ENUMERATION("Tracing.Background.ScenarioState", metric, |
| 50 NUMBER_OF_BACKGROUND_TRACING_METRICS); | 50 NUMBER_OF_BACKGROUND_TRACING_METRICS); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Tracing enabled callback for BENCHMARK_MEMORY_LIGHT category preset. | 53 // Tracing enabled callback for BENCHMARK_MEMORY_LIGHT category preset. |
| 54 void BenchmarkMemoryLight_TracingEnabledCallback() { | 54 void BenchmarkMemoryLight_TracingEnabledCallback() { |
| 55 auto dump_manager = base::trace_event::MemoryDumpManager::GetInstance(); | 55 auto* dump_manager = base::trace_event::MemoryDumpManager::GetInstance(); |
| 56 dump_manager->RequestGlobalDump( | 56 dump_manager->RequestGlobalDump( |
| 57 base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED, | 57 base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED, |
| 58 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND); | 58 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND); |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| 63 BackgroundTracingManagerImpl::TracingTimer::TracingTimer( | 63 BackgroundTracingManagerImpl::TracingTimer::TracingTimer( |
| 64 StartedFinalizingCallback callback) : callback_(callback) { | 64 StartedFinalizingCallback callback) : callback_(callback) { |
| 65 } | 65 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 return false; | 172 return false; |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 config_ = std::move(config_impl); | 176 config_ = std::move(config_impl); |
| 177 receive_callback_ = receive_callback; | 177 receive_callback_ = receive_callback; |
| 178 requires_anonymized_data_ = requires_anonymized_data; | 178 requires_anonymized_data_ = requires_anonymized_data; |
| 179 | 179 |
| 180 if (config_) { | 180 if (config_) { |
| 181 DCHECK(!config_.get()->rules().empty()); | 181 DCHECK(!config_.get()->rules().empty()); |
| 182 for (auto& rule : config_.get()->rules()) | 182 for (auto* rule : config_.get()->rules()) |
| 183 static_cast<BackgroundTracingRule*>(rule)->Install(); | 183 static_cast<BackgroundTracingRule*>(rule)->Install(); |
| 184 | 184 |
| 185 if (!config_->enable_blink_features().empty()) { | 185 if (!config_->enable_blink_features().empty()) { |
| 186 command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures, | 186 command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures, |
| 187 config_->enable_blink_features()); | 187 config_->enable_blink_features()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 if (!config_->disable_blink_features().empty()) { | 190 if (!config_->disable_blink_features().empty()) { |
| 191 command_line->AppendSwitchASCII(switches::kDisableBlinkFeatures, | 191 command_line->AppendSwitchASCII(switches::kDisableBlinkFeatures, |
| 192 config_->disable_blink_features()); | 192 config_->disable_blink_features()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 // If the last trace is still uploading, we don't allow a new one to trigger. | 237 // If the last trace is still uploading, we don't allow a new one to trigger. |
| 238 if (is_gathering_) | 238 if (is_gathering_) |
| 239 return nullptr; | 239 return nullptr; |
| 240 | 240 |
| 241 if (!IsTriggerHandleValid(handle)) { | 241 if (!IsTriggerHandleValid(handle)) { |
| 242 return nullptr; | 242 return nullptr; |
| 243 } | 243 } |
| 244 | 244 |
| 245 std::string trigger_name = GetTriggerNameFromHandle(handle); | 245 std::string trigger_name = GetTriggerNameFromHandle(handle); |
| 246 for (const auto& rule : config_.get()->rules()) { | 246 for (auto* rule : config_.get()->rules()) { |
| 247 if (static_cast<BackgroundTracingRule*>(rule) | 247 if (static_cast<BackgroundTracingRule*>(rule) |
| 248 ->ShouldTriggerNamedEvent(trigger_name)) | 248 ->ShouldTriggerNamedEvent(trigger_name)) |
| 249 return static_cast<BackgroundTracingRule*>(rule); | 249 return static_cast<BackgroundTracingRule*>(rule); |
| 250 } | 250 } |
| 251 | 251 |
| 252 return nullptr; | 252 return nullptr; |
| 253 } | 253 } |
| 254 | 254 |
| 255 void BackgroundTracingManagerImpl::OnHistogramTrigger( | 255 void BackgroundTracingManagerImpl::OnHistogramTrigger( |
| 256 const std::string& histogram_name) { | 256 const std::string& histogram_name) { |
| 257 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { | 257 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
| 258 content::BrowserThread::PostTask( | 258 content::BrowserThread::PostTask( |
| 259 content::BrowserThread::UI, FROM_HERE, | 259 content::BrowserThread::UI, FROM_HERE, |
| 260 base::Bind(&BackgroundTracingManagerImpl::OnHistogramTrigger, | 260 base::Bind(&BackgroundTracingManagerImpl::OnHistogramTrigger, |
| 261 base::Unretained(this), histogram_name)); | 261 base::Unretained(this), histogram_name)); |
| 262 return; | 262 return; |
| 263 } | 263 } |
| 264 | 264 |
| 265 for (const auto& rule : config_->rules()) { | 265 for (auto* rule : config_->rules()) { |
| 266 if (rule->ShouldTriggerNamedEvent(histogram_name)) | 266 if (rule->ShouldTriggerNamedEvent(histogram_name)) |
| 267 OnRuleTriggered(rule, StartedFinalizingCallback()); | 267 OnRuleTriggered(rule, StartedFinalizingCallback()); |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 void BackgroundTracingManagerImpl::TriggerNamedEvent( | 271 void BackgroundTracingManagerImpl::TriggerNamedEvent( |
| 272 BackgroundTracingManagerImpl::TriggerHandle handle, | 272 BackgroundTracingManagerImpl::TriggerHandle handle, |
| 273 StartedFinalizingCallback callback) { | 273 StartedFinalizingCallback callback) { |
| 274 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { | 274 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
| 275 content::BrowserThread::PostTask( | 275 content::BrowserThread::PostTask( |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: | 559 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: |
| 560 return "blink_style"; | 560 return "blink_style"; |
| 561 case BackgroundTracingConfigImpl::CategoryPreset::CATEGORY_PRESET_UNSET: | 561 case BackgroundTracingConfigImpl::CategoryPreset::CATEGORY_PRESET_UNSET: |
| 562 NOTREACHED(); | 562 NOTREACHED(); |
| 563 } | 563 } |
| 564 NOTREACHED(); | 564 NOTREACHED(); |
| 565 return ""; | 565 return ""; |
| 566 } | 566 } |
| 567 | 567 |
| 568 } // namspace content | 568 } // namspace content |
| OLD | NEW |