Chromium Code Reviews| 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 #include "chrome/browser/metrics/perf/perf_provider_chromeos.h" | 5 #include "chrome/browser/metrics/perf/perf_provider_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 return cmds; | 183 return cmds; |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Unknown CPUs | 186 // Unknown CPUs |
| 187 cmds.push_back(WeightAndValue(1.0, kPerfRecordCyclesCmd)); | 187 cmds.push_back(WeightAndValue(1.0, kPerfRecordCyclesCmd)); |
| 188 return cmds; | 188 return cmds; |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace internal | 191 } // namespace internal |
| 192 | 192 |
| 193 PerfProvider::CollectionParams::CollectionParams() | |
| 194 : CollectionParams(base::TimeDelta::FromSeconds(2), | |
|
dhsharp
2016/02/27 03:05:24
Please at least restore the comments for what thes
Lei Zhang
2016/03/29 19:03:45
Done.
| |
| 195 base::TimeDelta::FromHours(3), | |
| 196 PerfProvider::CollectionParams::TriggerParams( | |
| 197 10, | |
| 198 base::TimeDelta::FromSeconds(5)), | |
| 199 PerfProvider::CollectionParams::TriggerParams( | |
| 200 10, | |
| 201 base::TimeDelta::FromSeconds(10))) { | |
| 202 } | |
| 203 | |
| 193 PerfProvider::CollectionParams::CollectionParams( | 204 PerfProvider::CollectionParams::CollectionParams( |
| 194 base::TimeDelta collection_duration, | 205 base::TimeDelta collection_duration, |
| 195 base::TimeDelta periodic_interval, | 206 base::TimeDelta periodic_interval, |
| 196 TriggerParams resume_from_suspend, | 207 TriggerParams resume_from_suspend, |
| 197 TriggerParams restore_session) | 208 TriggerParams restore_session) |
| 198 : collection_duration_(collection_duration.ToInternalValue()), | 209 : collection_duration_(collection_duration.ToInternalValue()), |
| 199 periodic_interval_(periodic_interval.ToInternalValue()), | 210 periodic_interval_(periodic_interval.ToInternalValue()), |
| 200 resume_from_suspend_(resume_from_suspend), | 211 resume_from_suspend_(resume_from_suspend), |
| 201 restore_session_(restore_session) { | 212 restore_session_(restore_session) { |
| 202 } | 213 } |
| 203 | 214 |
| 204 PerfProvider::CollectionParams::TriggerParams::TriggerParams( | 215 PerfProvider::CollectionParams::TriggerParams::TriggerParams( |
| 205 int64_t sampling_factor, | 216 int64_t sampling_factor, |
| 206 base::TimeDelta max_collection_delay) | 217 base::TimeDelta max_collection_delay) |
| 207 : sampling_factor_(sampling_factor), | 218 : sampling_factor_(sampling_factor), |
| 208 max_collection_delay_(max_collection_delay.ToInternalValue()) {} | 219 max_collection_delay_(max_collection_delay.ToInternalValue()) {} |
| 209 | 220 |
| 210 const PerfProvider::CollectionParams PerfProvider::kDefaultParameters( | |
| 211 /* collection_duration = */ base::TimeDelta::FromSeconds(2), | |
| 212 /* periodic_interval = */ base::TimeDelta::FromHours(3), | |
| 213 /* resume_from_suspend = */ PerfProvider::CollectionParams::TriggerParams( | |
| 214 /* sampling_factor = */ 10, | |
| 215 /* max_collection_delay = */ base::TimeDelta::FromSeconds(5)), | |
| 216 /* restore_session = */ PerfProvider::CollectionParams::TriggerParams( | |
| 217 /* sampling_factor = */ 10, | |
| 218 /* max_collection_delay = */ base::TimeDelta::FromSeconds(10))); | |
| 219 | |
| 220 PerfProvider::PerfProvider() | 221 PerfProvider::PerfProvider() |
| 221 : collection_params_(kDefaultParameters), | 222 : login_observer_(this), |
| 222 login_observer_(this), | |
| 223 next_profiling_interval_start_(base::TimeTicks::Now()), | 223 next_profiling_interval_start_(base::TimeTicks::Now()), |
| 224 weak_factory_(this) { | 224 weak_factory_(this) { |
| 225 } | 225 } |
| 226 | 226 |
| 227 PerfProvider::~PerfProvider() { | 227 PerfProvider::~PerfProvider() { |
| 228 chromeos::LoginState::Get()->RemoveObserver(&login_observer_); | 228 chromeos::LoginState::Get()->RemoveObserver(&login_observer_); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void PerfProvider::Init() { | 231 void PerfProvider::Init() { |
| 232 CHECK(command_selector_.SetOdds( | 232 CHECK(command_selector_.SetOdds( |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 scoped_ptr<SampledProfile> sampled_profile(new SampledProfile); | 621 scoped_ptr<SampledProfile> sampled_profile(new SampledProfile); |
| 622 sampled_profile->set_trigger_event(SampledProfile::RESTORE_SESSION); | 622 sampled_profile->set_trigger_event(SampledProfile::RESTORE_SESSION); |
| 623 sampled_profile->set_ms_after_restore(time_after_restore.InMilliseconds()); | 623 sampled_profile->set_ms_after_restore(time_after_restore.InMilliseconds()); |
| 624 sampled_profile->set_num_tabs_restored(num_tabs_restored); | 624 sampled_profile->set_num_tabs_restored(num_tabs_restored); |
| 625 | 625 |
| 626 CollectIfNecessary(std::move(sampled_profile)); | 626 CollectIfNecessary(std::move(sampled_profile)); |
| 627 last_session_restore_collection_time_ = base::TimeTicks::Now(); | 627 last_session_restore_collection_time_ = base::TimeTicks::Now(); |
| 628 } | 628 } |
| 629 | 629 |
| 630 } // namespace metrics | 630 } // namespace metrics |
| OLD | NEW |