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

Side by Side Diff: chrome/browser/metrics/metrics_service.cc

Issue 10692059: Make metrics state machine more lenient about OLD vs. CURRENT (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing return Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/metrics/metrics_log_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 10 // A MetricsService instance is typically created at application startup. It
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 748
749 PrefService* pref = g_browser_process->local_state(); 749 PrefService* pref = g_browser_process->local_state();
750 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); 750 pref->SetBoolean(prefs::kStabilityExitedCleanly, true);
751 751
752 // At this point, there's no way of knowing when the process will be 752 // At this point, there's no way of knowing when the process will be
753 // killed, so this has to be treated similar to a shutdown, closing and 753 // killed, so this has to be treated similar to a shutdown, closing and
754 // persisting all logs. Unlinke a shutdown, the state is primed to be ready 754 // persisting all logs. Unlinke a shutdown, the state is primed to be ready
755 // to continue logging and uploading if the process does return. 755 // to continue logging and uploading if the process does return.
756 if (recording_active() && state_ >= INITIAL_LOG_READY) { 756 if (recording_active() && state_ >= INITIAL_LOG_READY) {
757 PushPendingLogsToPersistentStorage(); 757 PushPendingLogsToPersistentStorage();
758 if (state_ == SENDING_CURRENT_LOGS)
759 state_ = SENDING_OLD_LOGS;
760 // Persisting logs stops recording, so start recording a new log immediately 758 // Persisting logs stops recording, so start recording a new log immediately
761 // to capture any background work that might be done before the process is 759 // to capture any background work that might be done before the process is
762 // killed. 760 // killed.
763 StartRecording(); 761 StartRecording();
764 } 762 }
765 763
766 // Start writing right away (write happens on a different thread). 764 // Start writing right away (write happens on a different thread).
767 pref->CommitPendingWrite(); 765 pref->CommitPendingWrite();
768 } 766 }
769 767
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 // Similarly, if logs should no longer be uploaded, stop here. 1144 // Similarly, if logs should no longer be uploaded, stop here.
1147 // TODO(stuartmorgan): Call Stop() on the schedule when reporting and/or 1145 // TODO(stuartmorgan): Call Stop() on the schedule when reporting and/or
1148 // recording are turned off instead of letting it fire and then aborting. 1146 // recording are turned off instead of letting it fire and then aborting.
1149 if (idle_since_last_transmission_ || 1147 if (idle_since_last_transmission_ ||
1150 !recording_active() || !reporting_active()) { 1148 !recording_active() || !reporting_active()) {
1151 scheduler_->Stop(); 1149 scheduler_->Stop();
1152 scheduler_->UploadCancelled(); 1150 scheduler_->UploadCancelled();
1153 return; 1151 return;
1154 } 1152 }
1155 1153
1154 // If the callback was to upload an old log, but there no longer is one,
1155 // just report success back to the scheduler to begin the ongoing log
1156 // callbacks.
1157 // TODO(stuartmorgan): Consider removing the distinction between
1158 // SENDING_OLD_LOGS and SENDING_CURRENT_LOGS to simplify the state machine
1159 // now that the log upload flow is the same for both modes.
1160 if (state_ == SENDING_OLD_LOGS && !log_manager_.has_unsent_logs()) {
1161 state_ = SENDING_CURRENT_LOGS;
1162 scheduler_->UploadFinished(true /* healthy */, false /* no unsent logs */);
1163 return;
1164 }
1156 // If there are unsent logs, send the next one. If not, start the asynchronous 1165 // If there are unsent logs, send the next one. If not, start the asynchronous
1157 // process of finalizing the current log for upload. 1166 // process of finalizing the current log for upload.
1158 if (state_ == SENDING_OLD_LOGS) { 1167 if (state_ == SENDING_OLD_LOGS) {
1159 DCHECK(log_manager_.has_unsent_logs()); 1168 DCHECK(log_manager_.has_unsent_logs());
1160 log_manager_.StageNextLogForUpload(); 1169 log_manager_.StageNextLogForUpload();
1161 SendStagedLog(); 1170 SendStagedLog();
1162 } else { 1171 } else {
1163 StartFinalLogInfoCollection(); 1172 StartFinalLogInfoCollection();
1164 } 1173 }
1165 } 1174 }
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 if (local_state) { 1909 if (local_state) {
1901 const PrefService::Preference* uma_pref = 1910 const PrefService::Preference* uma_pref =
1902 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1911 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1903 if (uma_pref) { 1912 if (uma_pref) {
1904 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1913 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1905 DCHECK(success); 1914 DCHECK(success);
1906 } 1915 }
1907 } 1916 }
1908 return result; 1917 return result;
1909 } 1918 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/metrics/metrics_log_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698