OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ |
6 #define CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ | 6 #define CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // |trigger_event| is the cause of the perf data collection. | 125 // |trigger_event| is the cause of the perf data collection. |
126 // |result| is the return value of running perf/quipper. It is 0 if successful | 126 // |result| is the return value of running perf/quipper. It is 0 if successful |
127 // and nonzero if not successful. | 127 // and nonzero if not successful. |
128 void ParseOutputProtoIfValid( | 128 void ParseOutputProtoIfValid( |
129 scoped_ptr<WindowedIncognitoObserver> incognito_observer, | 129 scoped_ptr<WindowedIncognitoObserver> incognito_observer, |
130 scoped_ptr<SampledProfile> sampled_profile, | 130 scoped_ptr<SampledProfile> sampled_profile, |
131 int result, | 131 int result, |
132 const std::vector<uint8>& perf_data, | 132 const std::vector<uint8>& perf_data, |
133 const std::vector<uint8>& perf_stat); | 133 const std::vector<uint8>& perf_stat); |
134 | 134 |
| 135 const CollectionParams& collection_params() const { |
| 136 return collection_params_; |
| 137 } |
| 138 const RandomSelector& command_selector() const { |
| 139 return command_selector_; |
| 140 } |
| 141 |
135 private: | 142 private: |
136 static const CollectionParams kDefaultParameters; | 143 static const CollectionParams kDefaultParameters; |
137 | 144 |
138 // Class that listens for changes to the login state. When a normal user logs | 145 // Class that listens for changes to the login state. When a normal user logs |
139 // in, it updates PerfProvider to start collecting data. | 146 // in, it updates PerfProvider to start collecting data. |
140 class LoginObserver : public chromeos::LoginState::Observer { | 147 class LoginObserver : public chromeos::LoginState::Observer { |
141 public: | 148 public: |
142 explicit LoginObserver(PerfProvider* perf_provider); | 149 explicit LoginObserver(PerfProvider* perf_provider); |
143 | 150 |
144 // Called when either the login state or the logged in user type changes. | 151 // Called when either the login state or the logged in user type changes. |
145 // Activates |perf_provider_| to start collecting. | 152 // Activates |perf_provider_| to start collecting. |
146 void LoggedInStateChanged() override; | 153 void LoggedInStateChanged() override; |
147 | 154 |
148 private: | 155 private: |
149 // Points to a PerfProvider instance that can be turned on or off based on | 156 // Points to a PerfProvider instance that can be turned on or off based on |
150 // the login state. | 157 // the login state. |
151 PerfProvider* perf_provider_; | 158 PerfProvider* perf_provider_; |
152 }; | 159 }; |
153 | 160 |
| 161 // Change the values in |collection_params_| and the commands in |
| 162 // |command_selector_| for any keys that are present in |params|. |
| 163 void SetCollectionParamsFromVariationParams( |
| 164 const std::map<std::string, std::string> ¶ms); |
| 165 |
154 // Called when a suspend finishes. This is either a successful suspend | 166 // Called when a suspend finishes. This is either a successful suspend |
155 // followed by a resume, or a suspend that was canceled. Inherited from | 167 // followed by a resume, or a suspend that was canceled. Inherited from |
156 // PowerManagerClient::Observer. | 168 // PowerManagerClient::Observer. |
157 void SuspendDone(const base::TimeDelta& sleep_duration) override; | 169 void SuspendDone(const base::TimeDelta& sleep_duration) override; |
158 | 170 |
159 // Turns on perf collection. Resets the timer that's used to schedule | 171 // Turns on perf collection. Resets the timer that's used to schedule |
160 // collections. | 172 // collections. |
161 void OnUserLoggedIn(); | 173 void OnUserLoggedIn(); |
162 | 174 |
163 // Called when a session restore has finished. | 175 // Called when a session restore has finished. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 }; | 244 }; |
233 | 245 |
234 // Exposed for unit testing. | 246 // Exposed for unit testing. |
235 namespace internal { | 247 namespace internal { |
236 | 248 |
237 // Return the default set of perf commands and their odds of selection given | 249 // Return the default set of perf commands and their odds of selection given |
238 // the identity of the CPU in |cpuid|. | 250 // the identity of the CPU in |cpuid|. |
239 std::vector<RandomSelector::WeightAndValue> GetDefaultCommandsForCpu( | 251 std::vector<RandomSelector::WeightAndValue> GetDefaultCommandsForCpu( |
240 const CPUIdentity& cpuid); | 252 const CPUIdentity& cpuid); |
241 | 253 |
| 254 // For the "PerfCommand::"-prefixed keys in |params|, return the cpu specifier |
| 255 // that is the narrowest match for the CPU identified by |cpuid|. |
| 256 // Valid CPU specifiers, in increasing order of specificity, are: |
| 257 // "default", a system architecture (e.g. "x86_64"), a CPU microarchitecture |
| 258 // (currently only Intel uarchs supported), or a CPU model name substring. |
| 259 std::string FindBestCpuSpecifierFromParams( |
| 260 const std::map<std::string, std::string>& params, |
| 261 const CPUIdentity& cpuid); |
| 262 |
242 } // namespace internal | 263 } // namespace internal |
243 | 264 |
244 } // namespace metrics | 265 } // namespace metrics |
245 | 266 |
246 #endif // CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ | 267 #endif // CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ |
OLD | NEW |