Chromium Code Reviews| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/cpu.h" | 8 #include "base/cpu.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/rand_util.h" | |
| 12 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "content/browser/tracing/background_tracing_rule.h" | 15 #include "content/browser/tracing/background_tracing_rule.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.h" |
| 17 #include "content/public/browser/gpu_data_manager.h" | 18 #include "content/public/browser/gpu_data_manager.h" |
| 18 #include "content/public/browser/tracing_delegate.h" | 19 #include "content/public/browser/tracing_delegate.h" |
| 19 #include "content/public/common/content_client.h" | 20 #include "content/public/common/content_client.h" |
| 20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 21 #include "gpu/config/gpu_info.h" | 22 #include "gpu/config/gpu_info.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 | 308 |
| 308 triggered_named_event_handle_ = handle; | 309 triggered_named_event_handle_ = handle; |
| 309 OnRuleTriggered(triggered_rule, callback); | 310 OnRuleTriggered(triggered_rule, callback); |
| 310 } | 311 } |
| 311 | 312 |
| 312 void BackgroundTracingManagerImpl::OnRuleTriggered( | 313 void BackgroundTracingManagerImpl::OnRuleTriggered( |
| 313 const BackgroundTracingRule* triggered_rule, | 314 const BackgroundTracingRule* triggered_rule, |
| 314 StartedFinalizingCallback callback) { | 315 StartedFinalizingCallback callback) { |
| 315 CHECK(config_); | 316 CHECK(config_); |
| 316 | 317 |
| 318 float trigger_chance = triggered_rule->trigger_chance(); | |
| 319 if (trigger_chance < 1.0f && base::RandDouble() > trigger_chance) { | |
|
shatch
2015/10/30 19:17:06
nit: consistent using float or double?
oystein (OOO til 10th of July)
2015/10/30 19:24:47
Done.
| |
| 320 if (!callback.is_null()) | |
| 321 callback.Run(false); | |
| 322 return; | |
| 323 } | |
| 324 | |
| 317 int trace_timeout = triggered_rule->GetTraceTimeout(); | 325 int trace_timeout = triggered_rule->GetTraceTimeout(); |
| 318 | 326 |
| 319 if (config_->tracing_mode() == BackgroundTracingConfigImpl::REACTIVE) { | 327 if (config_->tracing_mode() == BackgroundTracingConfigImpl::REACTIVE) { |
| 320 // In reactive mode, a trigger starts tracing, or finalizes tracing | 328 // In reactive mode, a trigger starts tracing, or finalizes tracing |
| 321 // immediately if it's already running. | 329 // immediately if it's already running. |
| 322 RecordBackgroundTracingMetric(REACTIVE_TRIGGERED); | 330 RecordBackgroundTracingMetric(REACTIVE_TRIGGERED); |
| 323 | 331 |
| 324 if (!is_tracing_) { | 332 if (!is_tracing_) { |
| 325 // It was not already tracing, start a new trace. | 333 // It was not already tracing, start a new trace. |
| 326 EnableRecording(GetCategoryFilterStringForCategoryPreset( | 334 EnableRecording(GetCategoryFilterStringForCategoryPreset( |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 "disabled-by-default-toplevel.flow," | 592 "disabled-by-default-toplevel.flow," |
| 585 "disabled-by-default-ipc.flow"; | 593 "disabled-by-default-ipc.flow"; |
| 586 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: | 594 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: |
| 587 return "blink_style"; | 595 return "blink_style"; |
| 588 } | 596 } |
| 589 NOTREACHED(); | 597 NOTREACHED(); |
| 590 return ""; | 598 return ""; |
| 591 } | 599 } |
| 592 | 600 |
| 593 } // namspace content | 601 } // namspace content |
| OLD | NEW |