Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: content/browser/tracing/background_tracing_manager_impl.cc

Issue 1427873003: Background tracing: Added trace_chance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Oops Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 double trigger_chance = triggered_rule->trigger_chance();
319 if (trigger_chance < 1.0 && base::RandDouble() > trigger_chance) {
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
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
OLDNEW
« no previous file with comments | « content/browser/tracing/background_tracing_manager_browsertest.cc ('k') | content/browser/tracing/background_tracing_rule.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698