Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Side by Side Diff: components/metrics/metrics_service.cc

Issue 658903002: Starting a refactor to allow adding metrics on upload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Style fixes Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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();
Alexei Svitkine (slow) 2014/10/17 18:30:52 Can you call this from DisableRecording() too? Pe
Maria 2014/10/17 21:44:50 It's a little weird I think to call onCollectFinal
Alexei Svitkine (slow) 2014/10/20 15:47:00 It's not done because CollectFinalMetrics() involv
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
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
OLDNEW
« chrome/browser/metrics/android_metrics_provider.cc ('K') | « components/metrics/metrics_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698