| 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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 std::vector<variations::ActiveGroupId> synthetic_trials; | 769 std::vector<variations::ActiveGroupId> synthetic_trials; |
| 770 GetCurrentSyntheticFieldTrials(&synthetic_trials); | 770 GetCurrentSyntheticFieldTrials(&synthetic_trials); |
| 771 current_log->RecordEnvironment( | 771 current_log->RecordEnvironment( |
| 772 metrics_providers_.get(), synthetic_trials, GetInstallDate()); | 772 metrics_providers_.get(), synthetic_trials, GetInstallDate()); |
| 773 base::TimeDelta incremental_uptime; | 773 base::TimeDelta incremental_uptime; |
| 774 base::TimeDelta uptime; | 774 base::TimeDelta uptime; |
| 775 GetUptimes(local_state_, &incremental_uptime, &uptime); | 775 GetUptimes(local_state_, &incremental_uptime, &uptime); |
| 776 current_log->RecordStabilityMetrics(metrics_providers_.get(), | 776 current_log->RecordStabilityMetrics(metrics_providers_.get(), |
| 777 incremental_uptime, uptime); | 777 incremental_uptime, uptime); |
| 778 | 778 |
| 779 current_log->RecordGeneralMetrics(metrics_providers_.get()); |
| 779 RecordCurrentHistograms(); | 780 RecordCurrentHistograms(); |
| 780 current_log->RecordGeneralMetrics(metrics_providers_.get()); | |
| 781 | 781 |
| 782 log_manager_.FinishCurrentLog(); | 782 log_manager_.FinishCurrentLog(); |
| 783 } | 783 } |
| 784 | 784 |
| 785 void MetricsService::PushPendingLogsToPersistentStorage() { | 785 void MetricsService::PushPendingLogsToPersistentStorage() { |
| 786 if (state_ < SENDING_INITIAL_STABILITY_LOG) | 786 if (state_ < SENDING_INITIAL_STABILITY_LOG) |
| 787 return; // We didn't and still don't have time to get plugin list etc. | 787 return; // We didn't and still don't have time to get plugin list etc. |
| 788 | 788 |
| 789 CloseCurrentLog(); | 789 CloseCurrentLog(); |
| 790 log_manager_.PersistUnsentLogs(); | 790 log_manager_.PersistUnsentLogs(); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 // Histograms only get written to the current log, so make the new log current | 984 // Histograms only get written to the current log, so make the new log current |
| 985 // before writing them. | 985 // before writing them. |
| 986 log_manager_.PauseCurrentLog(); | 986 log_manager_.PauseCurrentLog(); |
| 987 log_manager_.BeginLoggingWithLog(initial_metrics_log_.Pass()); | 987 log_manager_.BeginLoggingWithLog(initial_metrics_log_.Pass()); |
| 988 | 988 |
| 989 // Note: Some stability providers may record stability stats via histograms, | 989 // Note: Some stability providers may record stability stats via histograms, |
| 990 // so this call has to be after BeginLoggingWithLog(). | 990 // so this call has to be after BeginLoggingWithLog(). |
| 991 MetricsLog* current_log = log_manager_.current_log(); | 991 MetricsLog* current_log = log_manager_.current_log(); |
| 992 current_log->RecordStabilityMetrics(metrics_providers_.get(), | 992 current_log->RecordStabilityMetrics(metrics_providers_.get(), |
| 993 base::TimeDelta(), base::TimeDelta()); | 993 base::TimeDelta(), base::TimeDelta()); |
| 994 current_log->RecordGeneralMetrics(metrics_providers_.get()); |
| 994 RecordCurrentHistograms(); | 995 RecordCurrentHistograms(); |
| 995 | 996 |
| 996 current_log->RecordGeneralMetrics(metrics_providers_.get()); | |
| 997 | |
| 998 log_manager_.FinishCurrentLog(); | 997 log_manager_.FinishCurrentLog(); |
| 999 log_manager_.ResumePausedLog(); | 998 log_manager_.ResumePausedLog(); |
| 1000 | 999 |
| 1001 // Store unsent logs, including the initial log that was just saved, so | 1000 // Store unsent logs, including the initial log that was just saved, so |
| 1002 // that they're not lost in case of a crash before upload time. | 1001 // that they're not lost in case of a crash before upload time. |
| 1003 log_manager_.PersistUnsentLogs(); | 1002 log_manager_.PersistUnsentLogs(); |
| 1004 | 1003 |
| 1005 DCHECK(!log_manager_.has_staged_log()); | 1004 DCHECK(!log_manager_.has_staged_log()); |
| 1006 log_manager_.StageNextLogForUpload(); | 1005 log_manager_.StageNextLogForUpload(); |
| 1007 } | 1006 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 local_state_->SetBoolean(path, value); | 1214 local_state_->SetBoolean(path, value); |
| 1216 RecordCurrentState(local_state_); | 1215 RecordCurrentState(local_state_); |
| 1217 } | 1216 } |
| 1218 | 1217 |
| 1219 void MetricsService::RecordCurrentState(PrefService* pref) { | 1218 void MetricsService::RecordCurrentState(PrefService* pref) { |
| 1220 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, | 1219 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, |
| 1221 base::Time::Now().ToTimeT()); | 1220 base::Time::Now().ToTimeT()); |
| 1222 } | 1221 } |
| 1223 | 1222 |
| 1224 } // namespace metrics | 1223 } // namespace metrics |
| OLD | NEW |