| 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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 | 647 |
| 648 // Bookkeeping for the uninstall metrics. | 648 // Bookkeeping for the uninstall metrics. |
| 649 IncrementLongPrefsValue(prefs::kUninstallLaunchCount); | 649 IncrementLongPrefsValue(prefs::kUninstallLaunchCount); |
| 650 | 650 |
| 651 // Kick off the process of saving the state (so the uptime numbers keep | 651 // Kick off the process of saving the state (so the uptime numbers keep |
| 652 // getting updated) every n minutes. | 652 // getting updated) every n minutes. |
| 653 ScheduleNextStateSave(); | 653 ScheduleNextStateSave(); |
| 654 } | 654 } |
| 655 | 655 |
| 656 void MetricsService::OnUserAction(const std::string& action) { | 656 void MetricsService::OnUserAction(const std::string& action) { |
| 657 if (!ShouldLogEvents()) | |
| 658 return; | |
| 659 | |
| 660 log_manager_.current_log()->RecordUserAction(action); | 657 log_manager_.current_log()->RecordUserAction(action); |
| 661 HandleIdleSinceLastTransmission(false); | 658 HandleIdleSinceLastTransmission(false); |
| 662 } | 659 } |
| 663 | 660 |
| 664 void MetricsService::FinishedInitTask() { | 661 void MetricsService::FinishedInitTask() { |
| 665 DCHECK_EQ(INIT_TASK_SCHEDULED, state_); | 662 DCHECK_EQ(INIT_TASK_SCHEDULED, state_); |
| 666 state_ = INIT_TASK_DONE; | 663 state_ = INIT_TASK_DONE; |
| 667 | 664 |
| 668 // Create the initial log. | 665 // Create the initial log. |
| 669 if (!initial_metrics_log_.get()) { | 666 if (!initial_metrics_log_.get()) { |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 // Redundant setting to assure that we always reset this value at shutdown | 1190 // Redundant setting to assure that we always reset this value at shutdown |
| 1194 // (and that we don't use some alternate path, and not call LogCleanShutdown). | 1191 // (and that we don't use some alternate path, and not call LogCleanShutdown). |
| 1195 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | 1192 clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
| 1196 | 1193 |
| 1197 clean_exit_beacon_.WriteBeaconValue(true); | 1194 clean_exit_beacon_.WriteBeaconValue(true); |
| 1198 RecordCurrentState(local_state_); | 1195 RecordCurrentState(local_state_); |
| 1199 local_state_->SetInteger(prefs::kStabilityExecutionPhase, | 1196 local_state_->SetInteger(prefs::kStabilityExecutionPhase, |
| 1200 MetricsService::SHUTDOWN_COMPLETE); | 1197 MetricsService::SHUTDOWN_COMPLETE); |
| 1201 } | 1198 } |
| 1202 | 1199 |
| 1203 bool MetricsService::ShouldLogEvents() { | |
| 1204 // We simply don't log events to UMA if there is a single incognito | |
| 1205 // session visible. The problem is that we always notify using the original | |
| 1206 // profile in order to simplify notification processing. | |
| 1207 return !client_->IsOffTheRecordSessionActive(); | |
| 1208 } | |
| 1209 | |
| 1210 void MetricsService::RecordBooleanPrefValue(const char* path, bool value) { | 1200 void MetricsService::RecordBooleanPrefValue(const char* path, bool value) { |
| 1211 DCHECK(IsSingleThreaded()); | 1201 DCHECK(IsSingleThreaded()); |
| 1212 local_state_->SetBoolean(path, value); | 1202 local_state_->SetBoolean(path, value); |
| 1213 RecordCurrentState(local_state_); | 1203 RecordCurrentState(local_state_); |
| 1214 } | 1204 } |
| 1215 | 1205 |
| 1216 void MetricsService::RecordCurrentState(PrefService* pref) { | 1206 void MetricsService::RecordCurrentState(PrefService* pref) { |
| 1217 pref->SetInt64(prefs::kStabilityLastTimestampSec, | 1207 pref->SetInt64(prefs::kStabilityLastTimestampSec, |
| 1218 base::Time::Now().ToTimeT()); | 1208 base::Time::Now().ToTimeT()); |
| 1219 } | 1209 } |
| 1220 | 1210 |
| 1221 void MetricsService::SkipAndDiscardUpload() { | 1211 void MetricsService::SkipAndDiscardUpload() { |
| 1222 log_manager_.DiscardStagedLog(); | 1212 log_manager_.DiscardStagedLog(); |
| 1223 scheduler_->UploadCancelled(); | 1213 scheduler_->UploadCancelled(); |
| 1224 log_upload_in_progress_ = false; | 1214 log_upload_in_progress_ = false; |
| 1225 } | 1215 } |
| 1226 | 1216 |
| 1227 } // namespace metrics | 1217 } // namespace metrics |
| OLD | NEW |