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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // At this point, there's no way of knowing when the process will be | 472 // 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 | 473 // 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 | 474 // persisting all logs. Unlinke a shutdown, the state is primed to be ready |
475 // to continue logging and uploading if the process does return. | 475 // to continue logging and uploading if the process does return. |
476 if (recording_active() && state_ >= SENDING_LOGS) { | 476 if (recording_active() && state_ >= SENDING_LOGS) { |
477 // Give providers a chance to persist histograms as part of being | |
478 // backgrounded. | |
479 for (MetricsProvider* provider : metrics_providers_) | |
Bryan McQuade
2016/07/27 13:18:34
I wasnt't sure if we should be informing providers
Alexei Svitkine (slow)
2016/07/27 17:41:11
It's debatable, but I somewhat prefer doing it out
Bryan McQuade
2016/07/27 18:25:15
Good point, I agree. I moved it.
| |
480 provider->OnAppEnterBackground(); | |
481 | |
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(); |
482 } | 487 } |
483 } | 488 } |
484 | 489 |
485 void MetricsService::OnAppEnterForeground() { | 490 void MetricsService::OnAppEnterForeground() { |
486 clean_exit_beacon_.WriteBeaconValue(false); | 491 clean_exit_beacon_.WriteBeaconValue(false); |
(...skipping 687 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 |