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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 void set_sampling_factor(int64_t factor) { sampling_factor_ = factor; } | 54 void set_sampling_factor(int64_t factor) { sampling_factor_ = factor; } |
55 | 55 |
56 base::TimeDelta max_collection_delay() const { | 56 base::TimeDelta max_collection_delay() const { |
57 return base::TimeDelta::FromInternalValue(max_collection_delay_); | 57 return base::TimeDelta::FromInternalValue(max_collection_delay_); |
58 } | 58 } |
59 void set_max_collection_delay(base::TimeDelta delay) { | 59 void set_max_collection_delay(base::TimeDelta delay) { |
60 max_collection_delay_ = delay.ToInternalValue(); | 60 max_collection_delay_ = delay.ToInternalValue(); |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 TriggerParams() = default; // POD | 64 TriggerParams() = delete; |
65 | 65 |
66 // Limit the number of profiles collected. | 66 // Limit the number of profiles collected. |
67 int64_t sampling_factor_; | 67 int64_t sampling_factor_; |
68 | 68 |
69 // Add a random delay before collecting after the trigger. | 69 // Add a random delay before collecting after the trigger. |
70 // The delay should be randomly selected between 0 and this value. | 70 // The delay should be randomly selected between 0 and this value. |
71 TimeDeltaInternalType max_collection_delay_; | 71 TimeDeltaInternalType max_collection_delay_; |
72 }; | 72 }; |
73 | 73 |
| 74 CollectionParams(); |
| 75 |
74 CollectionParams(base::TimeDelta collection_duration, | 76 CollectionParams(base::TimeDelta collection_duration, |
75 base::TimeDelta periodic_interval, | 77 base::TimeDelta periodic_interval, |
76 TriggerParams resume_from_suspend, | 78 TriggerParams resume_from_suspend, |
77 TriggerParams restore_session); | 79 TriggerParams restore_session); |
78 | 80 |
79 base::TimeDelta collection_duration() const { | 81 base::TimeDelta collection_duration() const { |
80 return base::TimeDelta::FromInternalValue(collection_duration_); | 82 return base::TimeDelta::FromInternalValue(collection_duration_); |
81 } | 83 } |
82 void set_collection_duration(base::TimeDelta duration) { | 84 void set_collection_duration(base::TimeDelta duration) { |
83 collection_duration_ = duration.ToInternalValue(); | 85 collection_duration_ = duration.ToInternalValue(); |
(...skipping 13 matching lines...) Expand all Loading... |
97 return &resume_from_suspend_; | 99 return &resume_from_suspend_; |
98 } | 100 } |
99 const TriggerParams& restore_session() const { | 101 const TriggerParams& restore_session() const { |
100 return restore_session_; | 102 return restore_session_; |
101 } | 103 } |
102 TriggerParams* mutable_restore_session() { | 104 TriggerParams* mutable_restore_session() { |
103 return &restore_session_; | 105 return &restore_session_; |
104 } | 106 } |
105 | 107 |
106 private: | 108 private: |
107 CollectionParams() = default; // POD | |
108 | |
109 // Time perf is run for. | 109 // Time perf is run for. |
110 TimeDeltaInternalType collection_duration_; | 110 TimeDeltaInternalType collection_duration_; |
111 | 111 |
112 // For PERIODIC_COLLECTION, partition time since login into successive | 112 // For PERIODIC_COLLECTION, partition time since login into successive |
113 // intervals of this duration. In each interval, a random time is picked to | 113 // intervals of this duration. In each interval, a random time is picked to |
114 // collect a profile. | 114 // collect a profile. |
115 TimeDeltaInternalType periodic_interval_; | 115 TimeDeltaInternalType periodic_interval_; |
116 | 116 |
117 // Parameters for RESUME_FROM_SUSPEND and RESTORE_SESSION collections: | 117 // Parameters for RESUME_FROM_SUSPEND and RESTORE_SESSION collections: |
118 TriggerParams resume_from_suspend_; | 118 TriggerParams resume_from_suspend_; |
119 TriggerParams restore_session_; | 119 TriggerParams restore_session_; |
| 120 |
| 121 DISALLOW_COPY_AND_ASSIGN(CollectionParams); |
120 }; | 122 }; |
121 | 123 |
122 // Parses a PerfDataProto from serialized data |perf_data|, if it exists. | 124 // Parses a PerfDataProto from serialized data |perf_data|, if it exists. |
123 // Parses a PerfStatProto from serialized data |perf_stat|, if it exists. | 125 // Parses a PerfStatProto from serialized data |perf_stat|, if it exists. |
124 // Only one of these may contain data. If both |perf_data| and |perf_stat| | 126 // Only one of these may contain data. If both |perf_data| and |perf_stat| |
125 // contain data, it is counted as an error and neither is parsed. | 127 // contain data, it is counted as an error and neither is parsed. |
126 // |incognito_observer| indicates whether an incognito window had been opened | 128 // |incognito_observer| indicates whether an incognito window had been opened |
127 // during the profile collection period. If there was an incognito window, | 129 // during the profile collection period. If there was an incognito window, |
128 // discard the incoming data. | 130 // discard the incoming data. |
129 // |trigger_event| is the cause of the perf data collection. | 131 // |trigger_event| is the cause of the perf data collection. |
(...skipping 18 matching lines...) Expand all Loading... |
148 } | 150 } |
149 const RandomSelector& command_selector() const { | 151 const RandomSelector& command_selector() const { |
150 return command_selector_; | 152 return command_selector_; |
151 } | 153 } |
152 | 154 |
153 const base::OneShotTimer& timer() const { | 155 const base::OneShotTimer& timer() const { |
154 return timer_; | 156 return timer_; |
155 } | 157 } |
156 | 158 |
157 private: | 159 private: |
158 static const CollectionParams kDefaultParameters; | |
159 | |
160 // Class that listens for changes to the login state. When a normal user logs | 160 // Class that listens for changes to the login state. When a normal user logs |
161 // in, it updates PerfProvider to start collecting data. | 161 // in, it updates PerfProvider to start collecting data. |
162 class LoginObserver : public chromeos::LoginState::Observer { | 162 class LoginObserver : public chromeos::LoginState::Observer { |
163 public: | 163 public: |
164 explicit LoginObserver(PerfProvider* perf_provider); | 164 explicit LoginObserver(PerfProvider* perf_provider); |
165 | 165 |
166 // Called when either the login state or the logged in user type changes. | 166 // Called when either the login state or the logged in user type changes. |
167 // Activates |perf_provider_| to start collecting. | 167 // Activates |perf_provider_| to start collecting. |
168 void LoggedInStateChanged() override; | 168 void LoggedInStateChanged() override; |
169 | 169 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // (currently only Intel uarchs supported), or a CPU model name substring. | 266 // (currently only Intel uarchs supported), or a CPU model name substring. |
267 std::string FindBestCpuSpecifierFromParams( | 267 std::string FindBestCpuSpecifierFromParams( |
268 const std::map<std::string, std::string>& params, | 268 const std::map<std::string, std::string>& params, |
269 const CPUIdentity& cpuid); | 269 const CPUIdentity& cpuid); |
270 | 270 |
271 } // namespace internal | 271 } // namespace internal |
272 | 272 |
273 } // namespace metrics | 273 } // namespace metrics |
274 | 274 |
275 #endif // CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ | 275 #endif // CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ |
OLD | NEW |