| 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 | |
| 9 #include <algorithm> | 8 #include <algorithm> |
| 10 #include <map> | 9 #include <map> |
| 11 #include <string> | 10 #include <string> |
| 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_split.h" | 20 #include "base/strings/string_split.h" |
| 21 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 collection_params_.collection_duration().InSeconds(), command, | 585 collection_params_.collection_duration().InSeconds(), command, |
| 586 base::Bind(&PerfProvider::ParseOutputProtoIfValid, | 586 base::Bind(&PerfProvider::ParseOutputProtoIfValid, |
| 587 weak_factory_.GetWeakPtr(), base::Passed(&incognito_observer), | 587 weak_factory_.GetWeakPtr(), base::Passed(&incognito_observer), |
| 588 base::Passed(&sampled_profile))); | 588 base::Passed(&sampled_profile))); |
| 589 } | 589 } |
| 590 | 590 |
| 591 void PerfProvider::DoPeriodicCollection() { | 591 void PerfProvider::DoPeriodicCollection() { |
| 592 scoped_ptr<SampledProfile> sampled_profile(new SampledProfile); | 592 scoped_ptr<SampledProfile> sampled_profile(new SampledProfile); |
| 593 sampled_profile->set_trigger_event(SampledProfile::PERIODIC_COLLECTION); | 593 sampled_profile->set_trigger_event(SampledProfile::PERIODIC_COLLECTION); |
| 594 | 594 |
| 595 CollectIfNecessary(sampled_profile.Pass()); | 595 CollectIfNecessary(std::move(sampled_profile)); |
| 596 } | 596 } |
| 597 | 597 |
| 598 void PerfProvider::CollectPerfDataAfterResume( | 598 void PerfProvider::CollectPerfDataAfterResume( |
| 599 const base::TimeDelta& sleep_duration, | 599 const base::TimeDelta& sleep_duration, |
| 600 const base::TimeDelta& time_after_resume) { | 600 const base::TimeDelta& time_after_resume) { |
| 601 // Fill out a SampledProfile protobuf that will contain the collected data. | 601 // Fill out a SampledProfile protobuf that will contain the collected data. |
| 602 scoped_ptr<SampledProfile> sampled_profile(new SampledProfile); | 602 scoped_ptr<SampledProfile> sampled_profile(new SampledProfile); |
| 603 sampled_profile->set_trigger_event(SampledProfile::RESUME_FROM_SUSPEND); | 603 sampled_profile->set_trigger_event(SampledProfile::RESUME_FROM_SUSPEND); |
| 604 sampled_profile->set_suspend_duration_ms(sleep_duration.InMilliseconds()); | 604 sampled_profile->set_suspend_duration_ms(sleep_duration.InMilliseconds()); |
| 605 sampled_profile->set_ms_after_resume(time_after_resume.InMilliseconds()); | 605 sampled_profile->set_ms_after_resume(time_after_resume.InMilliseconds()); |
| 606 | 606 |
| 607 CollectIfNecessary(sampled_profile.Pass()); | 607 CollectIfNecessary(std::move(sampled_profile)); |
| 608 } | 608 } |
| 609 | 609 |
| 610 void PerfProvider::CollectPerfDataAfterSessionRestore( | 610 void PerfProvider::CollectPerfDataAfterSessionRestore( |
| 611 const base::TimeDelta& time_after_restore, | 611 const base::TimeDelta& time_after_restore, |
| 612 int num_tabs_restored) { | 612 int num_tabs_restored) { |
| 613 // Fill out a SampledProfile protobuf that will contain the collected data. | 613 // Fill out a SampledProfile protobuf that will contain the collected data. |
| 614 scoped_ptr<SampledProfile> sampled_profile(new SampledProfile); | 614 scoped_ptr<SampledProfile> sampled_profile(new SampledProfile); |
| 615 sampled_profile->set_trigger_event(SampledProfile::RESTORE_SESSION); | 615 sampled_profile->set_trigger_event(SampledProfile::RESTORE_SESSION); |
| 616 sampled_profile->set_ms_after_restore(time_after_restore.InMilliseconds()); | 616 sampled_profile->set_ms_after_restore(time_after_restore.InMilliseconds()); |
| 617 sampled_profile->set_num_tabs_restored(num_tabs_restored); | 617 sampled_profile->set_num_tabs_restored(num_tabs_restored); |
| 618 | 618 |
| 619 CollectIfNecessary(sampled_profile.Pass()); | 619 CollectIfNecessary(std::move(sampled_profile)); |
| 620 last_session_restore_collection_time_ = base::TimeTicks::Now(); | 620 last_session_restore_collection_time_ = base::TimeTicks::Now(); |
| 621 } | 621 } |
| 622 | 622 |
| 623 } // namespace metrics | 623 } // namespace metrics |
| OLD | NEW |