| 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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 scheduler_->UploadFinished(true /* healthy */, false /* no unsent logs */); | 842 scheduler_->UploadFinished(true /* healthy */, false /* no unsent logs */); |
| 843 return; | 843 return; |
| 844 } | 844 } |
| 845 // If there are unsent logs, send the next one. If not, start the asynchronous | 845 // If there are unsent logs, send the next one. If not, start the asynchronous |
| 846 // process of finalizing the current log for upload. | 846 // process of finalizing the current log for upload. |
| 847 if (state_ == SENDING_OLD_LOGS) { | 847 if (state_ == SENDING_OLD_LOGS) { |
| 848 DCHECK(log_manager_.has_unsent_logs()); | 848 DCHECK(log_manager_.has_unsent_logs()); |
| 849 log_manager_.StageNextLogForUpload(); | 849 log_manager_.StageNextLogForUpload(); |
| 850 SendStagedLog(); | 850 SendStagedLog(); |
| 851 } else { | 851 } else { |
| 852 for (size_t i = 0; i < metrics_providers_.size(); ++i) |
| 853 metrics_providers_[i]->OnCollectFinalMetrics(); |
| 854 |
| 852 client_->CollectFinalMetrics( | 855 client_->CollectFinalMetrics( |
| 853 base::Bind(&MetricsService::OnFinalLogInfoCollectionDone, | 856 base::Bind(&MetricsService::OnFinalLogInfoCollectionDone, |
| 854 self_ptr_factory_.GetWeakPtr())); | 857 self_ptr_factory_.GetWeakPtr())); |
| 855 } | 858 } |
| 856 } | 859 } |
| 857 | 860 |
| 858 void MetricsService::OnFinalLogInfoCollectionDone() { | 861 void MetricsService::OnFinalLogInfoCollectionDone() { |
| 859 // If somehow there is a log upload in progress, we return and hope things | 862 // If somehow there is a log upload in progress, we return and hope things |
| 860 // work out. The scheduler isn't informed since if this happens, the scheduler | 863 // work out. The scheduler isn't informed since if this happens, the scheduler |
| 861 // will get a response from the upload. | 864 // will get a response from the upload. |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 local_state_->SetBoolean(path, value); | 1244 local_state_->SetBoolean(path, value); |
| 1242 RecordCurrentState(local_state_); | 1245 RecordCurrentState(local_state_); |
| 1243 } | 1246 } |
| 1244 | 1247 |
| 1245 void MetricsService::RecordCurrentState(PrefService* pref) { | 1248 void MetricsService::RecordCurrentState(PrefService* pref) { |
| 1246 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, | 1249 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, |
| 1247 base::Time::Now().ToTimeT()); | 1250 base::Time::Now().ToTimeT()); |
| 1248 } | 1251 } |
| 1249 | 1252 |
| 1250 } // namespace metrics | 1253 } // namespace metrics |
| OLD | NEW |