| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 upload_scheduler_.reset(new MetricsUploadScheduler(send_next_log_callback)); | 316 upload_scheduler_.reset(new MetricsUploadScheduler(send_next_log_callback)); |
| 317 } else { | 317 } else { |
| 318 scheduler_.reset(new MetricsReportingScheduler( | 318 scheduler_.reset(new MetricsReportingScheduler( |
| 319 upload_callback, | 319 upload_callback, |
| 320 // MetricsServiceClient outlives MetricsService, and | 320 // MetricsServiceClient outlives MetricsService, and |
| 321 // MetricsReportingScheduler is tied to the lifetime of |this|. | 321 // MetricsReportingScheduler is tied to the lifetime of |this|. |
| 322 base::Bind(&MetricsServiceClient::GetStandardUploadInterval, | 322 base::Bind(&MetricsServiceClient::GetStandardUploadInterval, |
| 323 base::Unretained(client_)))); | 323 base::Unretained(client_)))); |
| 324 } | 324 } |
| 325 | 325 |
| 326 for (MetricsProvider* provider : metrics_providers_) | 326 for (auto& provider : metrics_providers_) |
| 327 provider->Init(); | 327 provider->Init(); |
| 328 } | 328 } |
| 329 | 329 |
| 330 void MetricsService::Start() { | 330 void MetricsService::Start() { |
| 331 HandleIdleSinceLastTransmission(false); | 331 HandleIdleSinceLastTransmission(false); |
| 332 EnableRecording(); | 332 EnableRecording(); |
| 333 EnableReporting(); | 333 EnableReporting(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void MetricsService::StartRecordingForTests() { | 336 void MetricsService::StartRecordingForTests() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 377 |
| 378 if (recording_state_ == ACTIVE) | 378 if (recording_state_ == ACTIVE) |
| 379 return; | 379 return; |
| 380 recording_state_ = ACTIVE; | 380 recording_state_ = ACTIVE; |
| 381 | 381 |
| 382 state_manager_->ForceClientIdCreation(); | 382 state_manager_->ForceClientIdCreation(); |
| 383 client_->SetMetricsClientId(state_manager_->client_id()); | 383 client_->SetMetricsClientId(state_manager_->client_id()); |
| 384 if (!log_manager_.current_log()) | 384 if (!log_manager_.current_log()) |
| 385 OpenNewLog(); | 385 OpenNewLog(); |
| 386 | 386 |
| 387 for (MetricsProvider* provider : metrics_providers_) | 387 for (auto& provider : metrics_providers_) |
| 388 provider->OnRecordingEnabled(); | 388 provider->OnRecordingEnabled(); |
| 389 | 389 |
| 390 base::RemoveActionCallback(action_callback_); | 390 base::RemoveActionCallback(action_callback_); |
| 391 action_callback_ = base::Bind(&MetricsService::OnUserAction, | 391 action_callback_ = base::Bind(&MetricsService::OnUserAction, |
| 392 base::Unretained(this)); | 392 base::Unretained(this)); |
| 393 base::AddActionCallback(action_callback_); | 393 base::AddActionCallback(action_callback_); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void MetricsService::DisableRecording() { | 396 void MetricsService::DisableRecording() { |
| 397 DCHECK(thread_checker_.CalledOnValidThread()); | 397 DCHECK(thread_checker_.CalledOnValidThread()); |
| 398 | 398 |
| 399 if (recording_state_ == INACTIVE) | 399 if (recording_state_ == INACTIVE) |
| 400 return; | 400 return; |
| 401 recording_state_ = INACTIVE; | 401 recording_state_ = INACTIVE; |
| 402 | 402 |
| 403 base::RemoveActionCallback(action_callback_); | 403 base::RemoveActionCallback(action_callback_); |
| 404 | 404 |
| 405 for (MetricsProvider* provider : metrics_providers_) | 405 for (auto& provider : metrics_providers_) |
| 406 provider->OnRecordingDisabled(); | 406 provider->OnRecordingDisabled(); |
| 407 | 407 |
| 408 PushPendingLogsToPersistentStorage(); | 408 PushPendingLogsToPersistentStorage(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 bool MetricsService::recording_active() const { | 411 bool MetricsService::recording_active() const { |
| 412 DCHECK(thread_checker_.CalledOnValidThread()); | 412 DCHECK(thread_checker_.CalledOnValidThread()); |
| 413 return recording_state_ == ACTIVE; | 413 return recording_state_ == ACTIVE; |
| 414 } | 414 } |
| 415 | 415 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 rotation_scheduler_->Stop(); | 469 rotation_scheduler_->Stop(); |
| 470 upload_scheduler_->Stop(); | 470 upload_scheduler_->Stop(); |
| 471 } else { | 471 } else { |
| 472 scheduler_->Stop(); | 472 scheduler_->Stop(); |
| 473 } | 473 } |
| 474 | 474 |
| 475 MarkAppCleanShutdownAndCommit(&clean_exit_beacon_, local_state_); | 475 MarkAppCleanShutdownAndCommit(&clean_exit_beacon_, local_state_); |
| 476 | 476 |
| 477 // Give providers a chance to persist histograms as part of being | 477 // Give providers a chance to persist histograms as part of being |
| 478 // backgrounded. | 478 // backgrounded. |
| 479 for (MetricsProvider* provider : metrics_providers_) | 479 for (auto& provider : metrics_providers_) |
| 480 provider->OnAppEnterBackground(); | 480 provider->OnAppEnterBackground(); |
| 481 | 481 |
| 482 // At this point, there's no way of knowing when the process will be | 482 // At this point, there's no way of knowing when the process will be |
| 483 // killed, so this has to be treated similar to a shutdown, closing and | 483 // killed, so this has to be treated similar to a shutdown, closing and |
| 484 // persisting all logs. Unlinke a shutdown, the state is primed to be ready | 484 // persisting all logs. Unlinke a shutdown, the state is primed to be ready |
| 485 // to continue logging and uploading if the process does return. | 485 // to continue logging and uploading if the process does return. |
| 486 if (recording_active() && state_ >= SENDING_LOGS) { | 486 if (recording_active() && state_ >= SENDING_LOGS) { |
| 487 PushPendingLogsToPersistentStorage(); | 487 PushPendingLogsToPersistentStorage(); |
| 488 // Persisting logs closes the current log, so start recording a new log | 488 // Persisting logs closes the current log, so start recording a new log |
| 489 // immediately to capture any background work that might be done before the | 489 // immediately to capture any background work that might be done before the |
| (...skipping 29 matching lines...) Expand all Loading... |
| 519 } | 519 } |
| 520 | 520 |
| 521 void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { | 521 void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { |
| 522 if (!has_debugger) | 522 if (!has_debugger) |
| 523 IncrementPrefValue(prefs::kStabilityDebuggerNotPresent); | 523 IncrementPrefValue(prefs::kStabilityDebuggerNotPresent); |
| 524 else | 524 else |
| 525 IncrementPrefValue(prefs::kStabilityDebuggerPresent); | 525 IncrementPrefValue(prefs::kStabilityDebuggerPresent); |
| 526 } | 526 } |
| 527 | 527 |
| 528 void MetricsService::ClearSavedStabilityMetrics() { | 528 void MetricsService::ClearSavedStabilityMetrics() { |
| 529 for (MetricsProvider* provider : metrics_providers_) | 529 for (auto& provider : metrics_providers_) |
| 530 provider->ClearSavedStabilityMetrics(); | 530 provider->ClearSavedStabilityMetrics(); |
| 531 | 531 |
| 532 // Reset the prefs that are managed by MetricsService/MetricsLog directly. | 532 // Reset the prefs that are managed by MetricsService/MetricsLog directly. |
| 533 local_state_->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); | 533 local_state_->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); |
| 534 local_state_->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); | 534 local_state_->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); |
| 535 local_state_->SetInteger(prefs::kStabilityCrashCount, 0); | 535 local_state_->SetInteger(prefs::kStabilityCrashCount, 0); |
| 536 local_state_->SetInteger(prefs::kStabilityDebuggerPresent, 0); | 536 local_state_->SetInteger(prefs::kStabilityDebuggerPresent, 0); |
| 537 local_state_->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); | 537 local_state_->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); |
| 538 local_state_->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); | 538 local_state_->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); |
| 539 local_state_->SetInteger(prefs::kStabilityLaunchCount, 0); | 539 local_state_->SetInteger(prefs::kStabilityLaunchCount, 0); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 const int64_t incremental_time_secs = incremental_uptime->InSeconds(); | 707 const int64_t incremental_time_secs = incremental_uptime->InSeconds(); |
| 708 if (incremental_time_secs > 0) { | 708 if (incremental_time_secs > 0) { |
| 709 int64_t metrics_uptime = pref->GetInt64(prefs::kUninstallMetricsUptimeSec); | 709 int64_t metrics_uptime = pref->GetInt64(prefs::kUninstallMetricsUptimeSec); |
| 710 metrics_uptime += incremental_time_secs; | 710 metrics_uptime += incremental_time_secs; |
| 711 pref->SetInt64(prefs::kUninstallMetricsUptimeSec, metrics_uptime); | 711 pref->SetInt64(prefs::kUninstallMetricsUptimeSec, metrics_uptime); |
| 712 } | 712 } |
| 713 } | 713 } |
| 714 | 714 |
| 715 void MetricsService::NotifyOnDidCreateMetricsLog() { | 715 void MetricsService::NotifyOnDidCreateMetricsLog() { |
| 716 DCHECK(thread_checker_.CalledOnValidThread()); | 716 DCHECK(thread_checker_.CalledOnValidThread()); |
| 717 for (MetricsProvider* provider : metrics_providers_) | 717 for (auto& provider : metrics_providers_) |
| 718 provider->OnDidCreateMetricsLog(); | 718 provider->OnDidCreateMetricsLog(); |
| 719 } | 719 } |
| 720 | 720 |
| 721 | 721 |
| 722 //------------------------------------------------------------------------------ | 722 //------------------------------------------------------------------------------ |
| 723 // Recording control methods | 723 // Recording control methods |
| 724 | 724 |
| 725 void MetricsService::OpenNewLog() { | 725 void MetricsService::OpenNewLog() { |
| 726 DCHECK(!log_manager_.current_log()); | 726 DCHECK(!log_manager_.current_log()); |
| 727 | 727 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 // Put incremental data (histogram deltas, and realtime stats deltas) at the | 768 // Put incremental data (histogram deltas, and realtime stats deltas) at the |
| 769 // end of all log transmissions (initial log handles this separately). | 769 // end of all log transmissions (initial log handles this separately). |
| 770 // RecordIncrementalStabilityElements only exists on the derived | 770 // RecordIncrementalStabilityElements only exists on the derived |
| 771 // MetricsLog class. | 771 // MetricsLog class. |
| 772 MetricsLog* current_log = log_manager_.current_log(); | 772 MetricsLog* current_log = log_manager_.current_log(); |
| 773 DCHECK(current_log); | 773 DCHECK(current_log); |
| 774 RecordCurrentEnvironment(current_log); | 774 RecordCurrentEnvironment(current_log); |
| 775 base::TimeDelta incremental_uptime; | 775 base::TimeDelta incremental_uptime; |
| 776 base::TimeDelta uptime; | 776 base::TimeDelta uptime; |
| 777 GetUptimes(local_state_, &incremental_uptime, &uptime); | 777 GetUptimes(local_state_, &incremental_uptime, &uptime); |
| 778 current_log->RecordStabilityMetrics(metrics_providers_.get(), | 778 current_log->RecordStabilityMetrics(metrics_providers_, incremental_uptime, |
| 779 incremental_uptime, uptime); | 779 uptime); |
| 780 | 780 |
| 781 current_log->RecordGeneralMetrics(metrics_providers_.get()); | 781 current_log->RecordGeneralMetrics(metrics_providers_); |
| 782 RecordCurrentHistograms(); | 782 RecordCurrentHistograms(); |
| 783 DVLOG(1) << "Generated an ongoing log."; | 783 DVLOG(1) << "Generated an ongoing log."; |
| 784 log_manager_.FinishCurrentLog(); | 784 log_manager_.FinishCurrentLog(); |
| 785 } | 785 } |
| 786 | 786 |
| 787 void MetricsService::PushPendingLogsToPersistentStorage() { | 787 void MetricsService::PushPendingLogsToPersistentStorage() { |
| 788 if (state_ < SENDING_LOGS) | 788 if (state_ < SENDING_LOGS) |
| 789 return; // We didn't and still don't have time to get plugin list etc. | 789 return; // We didn't and still don't have time to get plugin list etc. |
| 790 | 790 |
| 791 CloseCurrentLog(); | 791 CloseCurrentLog(); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 upload_canceled); | 945 upload_canceled); |
| 946 } | 946 } |
| 947 } | 947 } |
| 948 | 948 |
| 949 bool MetricsService::ProvidersHaveInitialStabilityMetrics() { | 949 bool MetricsService::ProvidersHaveInitialStabilityMetrics() { |
| 950 // Check whether any metrics provider has initial stability metrics. | 950 // Check whether any metrics provider has initial stability metrics. |
| 951 // All providers are queried (rather than stopping after the first "true" | 951 // All providers are queried (rather than stopping after the first "true" |
| 952 // response) in case they do any kind of setup work in preparation for | 952 // response) in case they do any kind of setup work in preparation for |
| 953 // the later call to RecordInitialHistogramSnapshots(). | 953 // the later call to RecordInitialHistogramSnapshots(). |
| 954 bool has_stability_metrics = false; | 954 bool has_stability_metrics = false; |
| 955 for (MetricsProvider* provider : metrics_providers_) | 955 for (auto& provider : metrics_providers_) |
| 956 has_stability_metrics |= provider->HasInitialStabilityMetrics(); | 956 has_stability_metrics |= provider->HasInitialStabilityMetrics(); |
| 957 | 957 |
| 958 return has_stability_metrics; | 958 return has_stability_metrics; |
| 959 } | 959 } |
| 960 | 960 |
| 961 bool MetricsService::PrepareInitialStabilityLog( | 961 bool MetricsService::PrepareInitialStabilityLog( |
| 962 const std::string& prefs_previous_version) { | 962 const std::string& prefs_previous_version) { |
| 963 DCHECK_EQ(INITIALIZED, state_); | 963 DCHECK_EQ(INITIALIZED, state_); |
| 964 | 964 |
| 965 std::unique_ptr<MetricsLog> initial_stability_log( | 965 std::unique_ptr<MetricsLog> initial_stability_log( |
| 966 CreateLog(MetricsLog::INITIAL_STABILITY_LOG)); | 966 CreateLog(MetricsLog::INITIAL_STABILITY_LOG)); |
| 967 | 967 |
| 968 // Do not call NotifyOnDidCreateMetricsLog here because the stability | 968 // Do not call NotifyOnDidCreateMetricsLog here because the stability |
| 969 // log describes stats from the _previous_ session. | 969 // log describes stats from the _previous_ session. |
| 970 std::string system_profile_app_version; | 970 std::string system_profile_app_version; |
| 971 if (!initial_stability_log->LoadSavedEnvironmentFromPrefs( | 971 if (!initial_stability_log->LoadSavedEnvironmentFromPrefs( |
| 972 &system_profile_app_version)) { | 972 &system_profile_app_version)) { |
| 973 return false; | 973 return false; |
| 974 } | 974 } |
| 975 if (system_profile_app_version != prefs_previous_version) | 975 if (system_profile_app_version != prefs_previous_version) |
| 976 IncrementPrefValue(prefs::kStabilityVersionMismatchCount); | 976 IncrementPrefValue(prefs::kStabilityVersionMismatchCount); |
| 977 | 977 |
| 978 log_manager_.PauseCurrentLog(); | 978 log_manager_.PauseCurrentLog(); |
| 979 log_manager_.BeginLoggingWithLog(std::move(initial_stability_log)); | 979 log_manager_.BeginLoggingWithLog(std::move(initial_stability_log)); |
| 980 | 980 |
| 981 // Note: Some stability providers may record stability stats via histograms, | 981 // Note: Some stability providers may record stability stats via histograms, |
| 982 // so this call has to be after BeginLoggingWithLog(). | 982 // so this call has to be after BeginLoggingWithLog(). |
| 983 log_manager_.current_log()->RecordStabilityMetrics( | 983 log_manager_.current_log()->RecordStabilityMetrics( |
| 984 metrics_providers_.get(), base::TimeDelta(), base::TimeDelta()); | 984 metrics_providers_, base::TimeDelta(), base::TimeDelta()); |
| 985 RecordCurrentStabilityHistograms(); | 985 RecordCurrentStabilityHistograms(); |
| 986 | 986 |
| 987 // Note: RecordGeneralMetrics() intentionally not called since this log is for | 987 // Note: RecordGeneralMetrics() intentionally not called since this log is for |
| 988 // stability stats from a previous session only. | 988 // stability stats from a previous session only. |
| 989 | 989 |
| 990 DVLOG(1) << "Generated an stability log."; | 990 DVLOG(1) << "Generated an stability log."; |
| 991 log_manager_.FinishCurrentLog(); | 991 log_manager_.FinishCurrentLog(); |
| 992 log_manager_.ResumePausedLog(); | 992 log_manager_.ResumePausedLog(); |
| 993 | 993 |
| 994 // Store unsent logs, including the stability log that was just saved, so | 994 // Store unsent logs, including the stability log that was just saved, so |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1007 GetUptimes(local_state_, &incremental_uptime, &uptime); | 1007 GetUptimes(local_state_, &incremental_uptime, &uptime); |
| 1008 | 1008 |
| 1009 // Histograms only get written to the current log, so make the new log current | 1009 // Histograms only get written to the current log, so make the new log current |
| 1010 // before writing them. | 1010 // before writing them. |
| 1011 log_manager_.PauseCurrentLog(); | 1011 log_manager_.PauseCurrentLog(); |
| 1012 log_manager_.BeginLoggingWithLog(std::move(initial_metrics_log_)); | 1012 log_manager_.BeginLoggingWithLog(std::move(initial_metrics_log_)); |
| 1013 | 1013 |
| 1014 // Note: Some stability providers may record stability stats via histograms, | 1014 // Note: Some stability providers may record stability stats via histograms, |
| 1015 // so this call has to be after BeginLoggingWithLog(). | 1015 // so this call has to be after BeginLoggingWithLog(). |
| 1016 MetricsLog* current_log = log_manager_.current_log(); | 1016 MetricsLog* current_log = log_manager_.current_log(); |
| 1017 current_log->RecordStabilityMetrics(metrics_providers_.get(), | 1017 current_log->RecordStabilityMetrics(metrics_providers_, base::TimeDelta(), |
| 1018 base::TimeDelta(), base::TimeDelta()); | 1018 base::TimeDelta()); |
| 1019 current_log->RecordGeneralMetrics(metrics_providers_.get()); | 1019 current_log->RecordGeneralMetrics(metrics_providers_); |
| 1020 RecordCurrentHistograms(); | 1020 RecordCurrentHistograms(); |
| 1021 | 1021 |
| 1022 DVLOG(1) << "Generated an initial log."; | 1022 DVLOG(1) << "Generated an initial log."; |
| 1023 log_manager_.FinishCurrentLog(); | 1023 log_manager_.FinishCurrentLog(); |
| 1024 log_manager_.ResumePausedLog(); | 1024 log_manager_.ResumePausedLog(); |
| 1025 | 1025 |
| 1026 // Store unsent logs, including the initial log that was just saved, so | 1026 // Store unsent logs, including the initial log that was just saved, so |
| 1027 // that they're not lost in case of a crash before upload time. | 1027 // that they're not lost in case of a crash before upload time. |
| 1028 log_manager_.PersistUnsentLogs(); | 1028 log_manager_.PersistUnsentLogs(); |
| 1029 | 1029 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 MetricsLog::LogType log_type) { | 1216 MetricsLog::LogType log_type) { |
| 1217 return base::MakeUnique<MetricsLog>(state_manager_->client_id(), session_id_, | 1217 return base::MakeUnique<MetricsLog>(state_manager_->client_id(), session_id_, |
| 1218 log_type, client_, local_state_); | 1218 log_type, client_, local_state_); |
| 1219 } | 1219 } |
| 1220 | 1220 |
| 1221 void MetricsService::RecordCurrentEnvironment(MetricsLog* log) { | 1221 void MetricsService::RecordCurrentEnvironment(MetricsLog* log) { |
| 1222 DCHECK(client_); | 1222 DCHECK(client_); |
| 1223 std::vector<variations::ActiveGroupId> synthetic_trials; | 1223 std::vector<variations::ActiveGroupId> synthetic_trials; |
| 1224 GetSyntheticFieldTrialsOlderThan(log->creation_time(), &synthetic_trials); | 1224 GetSyntheticFieldTrialsOlderThan(log->creation_time(), &synthetic_trials); |
| 1225 std::string serialized_environment = log->RecordEnvironment( | 1225 std::string serialized_environment = log->RecordEnvironment( |
| 1226 metrics_providers_.get(), synthetic_trials, GetInstallDate(), | 1226 metrics_providers_, synthetic_trials, GetInstallDate(), |
| 1227 GetMetricsReportingEnabledDate()); | 1227 GetMetricsReportingEnabledDate()); |
| 1228 client_->OnEnvironmentUpdate(&serialized_environment); | 1228 client_->OnEnvironmentUpdate(&serialized_environment); |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 void MetricsService::RecordCurrentHistograms() { | 1231 void MetricsService::RecordCurrentHistograms() { |
| 1232 DCHECK(log_manager_.current_log()); | 1232 DCHECK(log_manager_.current_log()); |
| 1233 SCOPED_UMA_HISTOGRAM_TIMER("UMA.MetricsService.RecordCurrentHistograms.Time"); | 1233 SCOPED_UMA_HISTOGRAM_TIMER("UMA.MetricsService.RecordCurrentHistograms.Time"); |
| 1234 | 1234 |
| 1235 // "true" to the begin() call indicates that StatisticsRecorder should include | 1235 // "true" to the begin() call indicates that StatisticsRecorder should include |
| 1236 // histograms held in persistent storage. | 1236 // histograms held in persistent storage. |
| 1237 histogram_snapshot_manager_.PrepareDeltas( | 1237 histogram_snapshot_manager_.PrepareDeltas( |
| 1238 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), | 1238 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), |
| 1239 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); | 1239 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); |
| 1240 for (MetricsProvider* provider : metrics_providers_) | 1240 for (auto& provider : metrics_providers_) |
| 1241 provider->RecordHistogramSnapshots(&histogram_snapshot_manager_); | 1241 provider->RecordHistogramSnapshots(&histogram_snapshot_manager_); |
| 1242 } | 1242 } |
| 1243 | 1243 |
| 1244 void MetricsService::RecordCurrentStabilityHistograms() { | 1244 void MetricsService::RecordCurrentStabilityHistograms() { |
| 1245 DCHECK(log_manager_.current_log()); | 1245 DCHECK(log_manager_.current_log()); |
| 1246 // "true" indicates that StatisticsRecorder should include histograms in | 1246 // "true" indicates that StatisticsRecorder should include histograms in |
| 1247 // persistent storage. | 1247 // persistent storage. |
| 1248 histogram_snapshot_manager_.PrepareDeltas( | 1248 histogram_snapshot_manager_.PrepareDeltas( |
| 1249 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), | 1249 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), |
| 1250 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag); | 1250 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag); |
| 1251 for (MetricsProvider* provider : metrics_providers_) | 1251 for (auto& provider : metrics_providers_) |
| 1252 provider->RecordInitialHistogramSnapshots(&histogram_snapshot_manager_); | 1252 provider->RecordInitialHistogramSnapshots(&histogram_snapshot_manager_); |
| 1253 } | 1253 } |
| 1254 | 1254 |
| 1255 void MetricsService::LogCleanShutdown(bool end_completed) { | 1255 void MetricsService::LogCleanShutdown(bool end_completed) { |
| 1256 DCHECK(thread_checker_.CalledOnValidThread()); | 1256 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1257 // Redundant setting to assure that we always reset this value at shutdown | 1257 // Redundant setting to assure that we always reset this value at shutdown |
| 1258 // (and that we don't use some alternate path, and not call LogCleanShutdown). | 1258 // (and that we don't use some alternate path, and not call LogCleanShutdown). |
| 1259 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | 1259 clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
| 1260 client_->OnLogCleanShutdown(); | 1260 client_->OnLogCleanShutdown(); |
| 1261 clean_exit_beacon_.WriteBeaconValue(true); | 1261 clean_exit_beacon_.WriteBeaconValue(true); |
| 1262 SetExecutionPhase(ExecutionPhase::SHUTDOWN_COMPLETE, local_state_); | 1262 SetExecutionPhase(ExecutionPhase::SHUTDOWN_COMPLETE, local_state_); |
| 1263 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, end_completed); | 1263 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, end_completed); |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 } // namespace metrics | 1266 } // namespace metrics |
| OLD | NEW |