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 "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 Loading... | |
| 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 bool StackSamplingConfiguration::GetSyntheticFieldTrial( |
| 79 std::string* trial_name, | |
| 80 std::string* group_name) const { | |
| 80 if (!IsProfilerSupported()) | 81 if (!IsProfilerSupported()) |
| 81 return; | 82 return false; |
| 82 | 83 |
| 83 std::string group; | 84 *trial_name = "SyntheticStackProfilingConfiguration"; |
| 85 *group_name = ""; | |
|
sky
2016/09/29 18:21:36
Why is this needed? Doesn't the switch statement c
Mike Wittman
2016/09/29 18:27:40
It does currently. But in the case of future chang
sky
2016/09/29 19:12:49
Ok, please convert "" to std::string() then.
Mike Wittman
2016/09/29 19:25:55
Done.
| |
| 84 switch (configuration_) { | 86 switch (configuration_) { |
| 85 case PROFILE_DISABLED: | 87 case PROFILE_DISABLED: |
| 86 group = "Disabled"; | 88 *group_name = "Disabled"; |
| 87 break; | 89 break; |
| 88 | 90 |
| 89 case PROFILE_CONTROL: | 91 case PROFILE_CONTROL: |
| 90 group = "Control"; | 92 *group_name = "Control"; |
| 91 break; | 93 break; |
| 92 | 94 |
| 93 case PROFILE_NO_SAMPLES: | 95 case PROFILE_NO_SAMPLES: |
| 94 group = "NoSamples"; | 96 *group_name = "NoSamples"; |
| 95 break; | 97 break; |
| 96 | 98 |
| 97 case PROFILE_5HZ: | 99 case PROFILE_5HZ: |
| 98 group = "5Hz"; | 100 *group_name = "5Hz"; |
| 99 break; | 101 break; |
| 100 | 102 |
| 101 case PROFILE_10HZ: | 103 case PROFILE_10HZ: |
| 102 group = "10Hz"; | 104 *group_name = "10Hz"; |
| 103 break; | 105 break; |
| 104 | 106 |
| 105 case PROFILE_100HZ: | 107 case PROFILE_100HZ: |
| 106 group = "100Hz"; | 108 *group_name = "100Hz"; |
| 107 break; | 109 break; |
| 108 } | 110 } |
| 109 | 111 |
| 110 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( | 112 return !group_name->empty(); |
| 111 "SyntheticStackProfilingConfiguration", | |
| 112 group); | |
| 113 } | 113 } |
| 114 | 114 |
| 115 // static | 115 // static |
| 116 StackSamplingConfiguration::ProfileConfiguration | 116 StackSamplingConfiguration::ProfileConfiguration |
| 117 StackSamplingConfiguration::GenerateConfiguration() { | 117 StackSamplingConfiguration::GenerateConfiguration() { |
| 118 if (!IsProfilerSupported()) | 118 if (!IsProfilerSupported()) |
| 119 return PROFILE_DISABLED; | 119 return PROFILE_DISABLED; |
| 120 | 120 |
| 121 // Enable the profiler in the intended ultimate production configuration for | 121 // Enable the profiler in the intended ultimate production configuration for |
| 122 // development/waterfall builds. | 122 // development/waterfall builds. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 150 chosen < cumulative_weight + variation.weight) { | 150 chosen < cumulative_weight + variation.weight) { |
| 151 return variation.config; | 151 return variation.config; |
| 152 } | 152 } |
| 153 cumulative_weight += variation.weight; | 153 cumulative_weight += variation.weight; |
| 154 } | 154 } |
| 155 NOTREACHED(); | 155 NOTREACHED(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 return PROFILE_DISABLED; | 158 return PROFILE_DISABLED; |
| 159 } | 159 } |
| OLD | NEW |