OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 //------------------------------------------------------------------------------ | 5 //------------------------------------------------------------------------------ |
6 // Description of the life cycle of a instance of MetricsService. | 6 // Description of the life cycle of a instance of MetricsService. |
7 // | 7 // |
8 // OVERVIEW | 8 // OVERVIEW |
9 // | 9 // |
10 // A MetricsService instance is typically created at application startup. It is | 10 // A MetricsService instance is typically created at application startup. It is |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 | 659 |
660 const int64 incremental_time_secs = incremental_uptime->InSeconds(); | 660 const int64 incremental_time_secs = incremental_uptime->InSeconds(); |
661 if (incremental_time_secs > 0) { | 661 if (incremental_time_secs > 0) { |
662 int64 metrics_uptime = | 662 int64 metrics_uptime = |
663 pref->GetInt64(metrics::prefs::kUninstallMetricsUptimeSec); | 663 pref->GetInt64(metrics::prefs::kUninstallMetricsUptimeSec); |
664 metrics_uptime += incremental_time_secs; | 664 metrics_uptime += incremental_time_secs; |
665 pref->SetInt64(metrics::prefs::kUninstallMetricsUptimeSec, metrics_uptime); | 665 pref->SetInt64(metrics::prefs::kUninstallMetricsUptimeSec, metrics_uptime); |
666 } | 666 } |
667 } | 667 } |
668 | 668 |
669 void MetricsService::AddObserver(MetricsServiceObserver* observer) { | |
670 DCHECK(thread_checker_.CalledOnValidThread()); | |
671 observers_.AddObserver(observer); | |
672 } | |
673 | |
674 void MetricsService::RemoveObserver(MetricsServiceObserver* observer) { | |
675 DCHECK(thread_checker_.CalledOnValidThread()); | |
676 observers_.RemoveObserver(observer); | |
677 } | |
678 | |
679 void MetricsService::NotifyOnDidCreateMetricsLog() { | 669 void MetricsService::NotifyOnDidCreateMetricsLog() { |
680 DCHECK(thread_checker_.CalledOnValidThread()); | 670 DCHECK(IsSingleThreaded()); |
Ilya Sherman
2014/09/03 00:28:40
nit: Hmm, is this change needed for this CL? I've
Alexei Svitkine (slow)
2014/09/03 13:24:41
These were the only things using |thread_checker_|
| |
681 FOR_EACH_OBSERVER( | |
682 MetricsServiceObserver, observers_, OnDidCreateMetricsLog()); | |
683 for (size_t i = 0; i < metrics_providers_.size(); ++i) | 671 for (size_t i = 0; i < metrics_providers_.size(); ++i) |
684 metrics_providers_[i]->OnDidCreateMetricsLog(); | 672 metrics_providers_[i]->OnDidCreateMetricsLog(); |
685 } | 673 } |
686 | 674 |
687 //------------------------------------------------------------------------------ | 675 //------------------------------------------------------------------------------ |
688 // State save methods | 676 // State save methods |
689 | 677 |
690 void MetricsService::ScheduleNextStateSave() { | 678 void MetricsService::ScheduleNextStateSave() { |
691 state_saver_factory_.InvalidateWeakPtrs(); | 679 state_saver_factory_.InvalidateWeakPtrs(); |
692 | 680 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1186 local_state_->SetBoolean(path, value); | 1174 local_state_->SetBoolean(path, value); |
1187 RecordCurrentState(local_state_); | 1175 RecordCurrentState(local_state_); |
1188 } | 1176 } |
1189 | 1177 |
1190 void MetricsService::RecordCurrentState(PrefService* pref) { | 1178 void MetricsService::RecordCurrentState(PrefService* pref) { |
1191 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, | 1179 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, |
1192 base::Time::Now().ToTimeT()); | 1180 base::Time::Now().ToTimeT()); |
1193 } | 1181 } |
1194 | 1182 |
1195 } // namespace metrics | 1183 } // namespace metrics |
OLD | NEW |