OLD | NEW |
---|---|
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 Loading... | |
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; | |
Ilya Sherman
2012/07/09 16:12:54
Hmm, why is this no longer needed?
jar (doing other things)
2012/07/09 16:38:04
Can you motivate this removal?
stuartmorgan
2012/07/10 07:26:25
It was cruft almost the moment it was added; it la
| |
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 Loading... | |
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; | |
jar (doing other things)
2012/07/09 16:38:04
This seems nice, conservative, and defenive.
| |
1162 scheduler_->UploadFinished(true /* healthy */, false /* no unsent logs */); | |
jar (doing other things)
2012/07/09 16:38:04
Why do we need to do this now? Won't this (eventu
stuartmorgan
2012/07/10 07:26:25
Whoops, it's because I'm missing the |return| I in
| |
1163 } | |
1156 // If there are unsent logs, send the next one. If not, start the asynchronous | 1164 // If there are unsent logs, send the next one. If not, start the asynchronous |
1157 // process of finalizing the current log for upload. | 1165 // process of finalizing the current log for upload. |
1158 if (state_ == SENDING_OLD_LOGS) { | 1166 if (state_ == SENDING_OLD_LOGS) { |
1159 DCHECK(log_manager_.has_unsent_logs()); | 1167 DCHECK(log_manager_.has_unsent_logs()); |
1160 log_manager_.StageNextLogForUpload(); | 1168 log_manager_.StageNextLogForUpload(); |
1161 SendStagedLog(); | 1169 SendStagedLog(); |
1162 } else { | 1170 } else { |
1163 StartFinalLogInfoCollection(); | 1171 StartFinalLogInfoCollection(); |
1164 } | 1172 } |
1165 } | 1173 } |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1900 if (local_state) { | 1908 if (local_state) { |
1901 const PrefService::Preference* uma_pref = | 1909 const PrefService::Preference* uma_pref = |
1902 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1910 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1903 if (uma_pref) { | 1911 if (uma_pref) { |
1904 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1912 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1905 DCHECK(success); | 1913 DCHECK(success); |
1906 } | 1914 } |
1907 } | 1915 } |
1908 return result; | 1916 return result; |
1909 } | 1917 } |
OLD | NEW |