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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 // MetricsLog class. | 771 // MetricsLog class. |
772 MetricsLog* current_log = log_manager_.current_log(); | 772 MetricsLog* current_log = log_manager_.current_log(); |
773 DCHECK(current_log); | 773 DCHECK(current_log); |
774 RecordCurrentEnvironment(current_log); | 774 RecordCurrentEnvironment(current_log); |
775 base::TimeDelta incremental_uptime; | 775 base::TimeDelta incremental_uptime; |
776 base::TimeDelta uptime; | 776 base::TimeDelta uptime; |
777 GetUptimes(local_state_, &incremental_uptime, &uptime); | 777 GetUptimes(local_state_, &incremental_uptime, &uptime); |
778 current_log->RecordStabilityMetrics(metrics_providers_.get(), | 778 current_log->RecordStabilityMetrics(metrics_providers_.get(), |
779 incremental_uptime, uptime); | 779 incremental_uptime, uptime); |
780 | 780 |
| 781 current_log->RecordGeneralMetrics(metrics_providers_.get()); |
781 RecordCurrentHistograms(); | 782 RecordCurrentHistograms(); |
782 current_log->RecordGeneralMetrics(metrics_providers_.get()); | |
783 | 783 |
784 log_manager_.FinishCurrentLog(); | 784 log_manager_.FinishCurrentLog(); |
785 } | 785 } |
786 | 786 |
787 void MetricsService::PushPendingLogsToPersistentStorage() { | 787 void MetricsService::PushPendingLogsToPersistentStorage() { |
788 if (state_ < SENDING_INITIAL_STABILITY_LOG) | 788 if (state_ < SENDING_INITIAL_STABILITY_LOG) |
789 return; // We didn't and still don't have time to get plugin list etc. | 789 return; // We didn't and still don't have time to get plugin list etc. |
790 | 790 |
791 CloseCurrentLog(); | 791 CloseCurrentLog(); |
792 log_manager_.PersistUnsentLogs(); | 792 log_manager_.PersistUnsentLogs(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 // Histograms only get written to the current log, so make the new log current | 998 // Histograms only get written to the current log, so make the new log current |
999 // before writing them. | 999 // before writing them. |
1000 log_manager_.PauseCurrentLog(); | 1000 log_manager_.PauseCurrentLog(); |
1001 log_manager_.BeginLoggingWithLog(initial_metrics_log_.Pass()); | 1001 log_manager_.BeginLoggingWithLog(initial_metrics_log_.Pass()); |
1002 | 1002 |
1003 // Note: Some stability providers may record stability stats via histograms, | 1003 // Note: Some stability providers may record stability stats via histograms, |
1004 // so this call has to be after BeginLoggingWithLog(). | 1004 // so this call has to be after BeginLoggingWithLog(). |
1005 MetricsLog* current_log = log_manager_.current_log(); | 1005 MetricsLog* current_log = log_manager_.current_log(); |
1006 current_log->RecordStabilityMetrics(metrics_providers_.get(), | 1006 current_log->RecordStabilityMetrics(metrics_providers_.get(), |
1007 base::TimeDelta(), base::TimeDelta()); | 1007 base::TimeDelta(), base::TimeDelta()); |
| 1008 current_log->RecordGeneralMetrics(metrics_providers_.get()); |
1008 RecordCurrentHistograms(); | 1009 RecordCurrentHistograms(); |
1009 | 1010 |
1010 current_log->RecordGeneralMetrics(metrics_providers_.get()); | |
1011 | |
1012 log_manager_.FinishCurrentLog(); | 1011 log_manager_.FinishCurrentLog(); |
1013 log_manager_.ResumePausedLog(); | 1012 log_manager_.ResumePausedLog(); |
1014 | 1013 |
1015 // Store unsent logs, including the initial log that was just saved, so | 1014 // Store unsent logs, including the initial log that was just saved, so |
1016 // that they're not lost in case of a crash before upload time. | 1015 // that they're not lost in case of a crash before upload time. |
1017 log_manager_.PersistUnsentLogs(); | 1016 log_manager_.PersistUnsentLogs(); |
1018 } | 1017 } |
1019 | 1018 |
1020 void MetricsService::SendStagedLog() { | 1019 void MetricsService::SendStagedLog() { |
1021 DCHECK(log_manager_.has_staged_log()); | 1020 DCHECK(log_manager_.has_staged_log()); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 local_state_->SetBoolean(path, value); | 1240 local_state_->SetBoolean(path, value); |
1242 RecordCurrentState(local_state_); | 1241 RecordCurrentState(local_state_); |
1243 } | 1242 } |
1244 | 1243 |
1245 void MetricsService::RecordCurrentState(PrefService* pref) { | 1244 void MetricsService::RecordCurrentState(PrefService* pref) { |
1246 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, | 1245 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, |
1247 base::Time::Now().ToTimeT()); | 1246 base::Time::Now().ToTimeT()); |
1248 } | 1247 } |
1249 | 1248 |
1250 } // namespace metrics | 1249 } // namespace metrics |
OLD | NEW |