| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 LogCleanShutdown(); | 462 LogCleanShutdown(); |
| 463 RecordBooleanPrefValue(prefs::kStabilitySessionEndCompleted, true); | 463 RecordBooleanPrefValue(prefs::kStabilitySessionEndCompleted, true); |
| 464 } | 464 } |
| 465 | 465 |
| 466 #if defined(OS_ANDROID) || defined(OS_IOS) | 466 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 467 void MetricsService::OnAppEnterBackground() { | 467 void MetricsService::OnAppEnterBackground() { |
| 468 scheduler_->Stop(); | 468 scheduler_->Stop(); |
| 469 | 469 |
| 470 MarkAppCleanShutdownAndCommit(&clean_exit_beacon_, local_state_); | 470 MarkAppCleanShutdownAndCommit(&clean_exit_beacon_, local_state_); |
| 471 | 471 |
| 472 // Give providers a chance to persist histograms as part of being |
| 473 // backgrounded. |
| 474 for (MetricsProvider* provider : metrics_providers_) |
| 475 provider->OnAppEnterBackground(); |
| 476 |
| 472 // At this point, there's no way of knowing when the process will be | 477 // At this point, there's no way of knowing when the process will be |
| 473 // killed, so this has to be treated similar to a shutdown, closing and | 478 // killed, so this has to be treated similar to a shutdown, closing and |
| 474 // persisting all logs. Unlinke a shutdown, the state is primed to be ready | 479 // persisting all logs. Unlinke a shutdown, the state is primed to be ready |
| 475 // to continue logging and uploading if the process does return. | 480 // to continue logging and uploading if the process does return. |
| 476 if (recording_active() && state_ >= SENDING_LOGS) { | 481 if (recording_active() && state_ >= SENDING_LOGS) { |
| 477 PushPendingLogsToPersistentStorage(); | 482 PushPendingLogsToPersistentStorage(); |
| 478 // Persisting logs closes the current log, so start recording a new log | 483 // Persisting logs closes the current log, so start recording a new log |
| 479 // immediately to capture any background work that might be done before the | 484 // immediately to capture any background work that might be done before the |
| 480 // process is killed. | 485 // process is killed. |
| 481 OpenNewLog(); | 486 OpenNewLog(); |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 base::Time::Now().ToTimeT()); | 1179 base::Time::Now().ToTimeT()); |
| 1175 } | 1180 } |
| 1176 | 1181 |
| 1177 void MetricsService::SkipAndDiscardUpload() { | 1182 void MetricsService::SkipAndDiscardUpload() { |
| 1178 log_manager_.DiscardStagedLog(); | 1183 log_manager_.DiscardStagedLog(); |
| 1179 scheduler_->UploadCancelled(); | 1184 scheduler_->UploadCancelled(); |
| 1180 log_upload_in_progress_ = false; | 1185 log_upload_in_progress_ = false; |
| 1181 } | 1186 } |
| 1182 | 1187 |
| 1183 } // namespace metrics | 1188 } // namespace metrics |
| OLD | NEW |