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

Side by Side Diff: chrome/common/stack_sampling_configuration.cc

Issue 2375563002: Stack sampling profiler: move configuration to chrome/common (Closed)
Patch Set: formatting fix Created 4 years, 2 months 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
« no previous file with comments | « chrome/common/stack_sampling_configuration.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/stack_sampling_configuration.h" 5 #include "chrome/common/stack_sampling_configuration.h"
6 6
7 #include "base/rand_util.h" 7 #include "base/rand_util.h"
8 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
9 #include "chrome/common/channel_info.h" 8 #include "chrome/common/channel_info.h"
10 #include "components/version_info/version_info.h" 9 #include "components/version_info/version_info.h"
11 10
12 namespace { 11 namespace {
13 12
14 // The profiler is currently only implemented for Windows x64, and only runs on 13 // The profiler is currently only implemented for Windows x64, and only runs on
15 // trunk, canary, and dev. 14 // trunk, canary, and dev.
16 bool IsProfilerSupported() { 15 bool IsProfilerSupported() {
17 #if !defined(_WIN64) 16 #if !defined(_WIN64)
18 return false; 17 return false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 break; 68 break;
70 } 69 }
71 return params; 70 return params;
72 } 71 }
73 72
74 bool StackSamplingConfiguration::IsProfilerEnabled() const { 73 bool StackSamplingConfiguration::IsProfilerEnabled() const {
75 return (configuration_ != PROFILE_DISABLED && 74 return (configuration_ != PROFILE_DISABLED &&
76 configuration_ != PROFILE_CONTROL); 75 configuration_ != PROFILE_CONTROL);
77 } 76 }
78 77
79 void StackSamplingConfiguration::RegisterSyntheticFieldTrial() const { 78 void StackSamplingConfiguration::RegisterSyntheticFieldTrial(
79 const RegisterSyntheticFieldTrialFunction& register_field_trial) const {
sky 2016/09/28 20:34:14 How come you need a callback here? Could this inst
Mike Wittman 2016/09/28 21:51:27 The callback is not strictly necessary, but it all
80 if (!IsProfilerSupported()) 80 if (!IsProfilerSupported())
81 return; 81 return;
82 82
83 std::string group; 83 std::string group;
84 switch (configuration_) { 84 switch (configuration_) {
85 case PROFILE_DISABLED: 85 case PROFILE_DISABLED:
86 group = "Disabled"; 86 group = "Disabled";
87 break; 87 break;
88 88
89 case PROFILE_CONTROL: 89 case PROFILE_CONTROL:
(...skipping 10 matching lines...) Expand all
100 100
101 case PROFILE_10HZ: 101 case PROFILE_10HZ:
102 group = "10Hz"; 102 group = "10Hz";
103 break; 103 break;
104 104
105 case PROFILE_100HZ: 105 case PROFILE_100HZ:
106 group = "100Hz"; 106 group = "100Hz";
107 break; 107 break;
108 } 108 }
109 109
110 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( 110 register_field_trial.Run("SyntheticStackProfilingConfiguration", group);
111 "SyntheticStackProfilingConfiguration",
112 group);
113 } 111 }
114 112
115 // static 113 // static
116 StackSamplingConfiguration::ProfileConfiguration 114 StackSamplingConfiguration::ProfileConfiguration
117 StackSamplingConfiguration::GenerateConfiguration() { 115 StackSamplingConfiguration::GenerateConfiguration() {
118 if (!IsProfilerSupported()) 116 if (!IsProfilerSupported())
119 return PROFILE_DISABLED; 117 return PROFILE_DISABLED;
120 118
121 // Enable the profiler in the intended ultimate production configuration for 119 // Enable the profiler in the intended ultimate production configuration for
122 // development/waterfall builds. 120 // development/waterfall builds.
(...skipping 27 matching lines...) Expand all
150 chosen < cumulative_weight + variation.weight) { 148 chosen < cumulative_weight + variation.weight) {
151 return variation.config; 149 return variation.config;
152 } 150 }
153 cumulative_weight += variation.weight; 151 cumulative_weight += variation.weight;
154 } 152 }
155 NOTREACHED(); 153 NOTREACHED();
156 } 154 }
157 155
158 return PROFILE_DISABLED; 156 return PROFILE_DISABLED;
159 } 157 }
OLDNEW
« no previous file with comments | « chrome/common/stack_sampling_configuration.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698