Chromium Code Reviews| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 #include "base/metrics/sparse_histogram.h" | 141 #include "base/metrics/sparse_histogram.h" |
| 142 #include "base/metrics/statistics_recorder.h" | 142 #include "base/metrics/statistics_recorder.h" |
| 143 #include "base/single_thread_task_runner.h" | 143 #include "base/single_thread_task_runner.h" |
| 144 #include "base/strings/string_number_conversions.h" | 144 #include "base/strings/string_number_conversions.h" |
| 145 #include "base/strings/utf_string_conversions.h" | 145 #include "base/strings/utf_string_conversions.h" |
| 146 #include "base/threading/thread_task_runner_handle.h" | 146 #include "base/threading/thread_task_runner_handle.h" |
| 147 #include "base/time/time.h" | 147 #include "base/time/time.h" |
| 148 #include "base/tracked_objects.h" | 148 #include "base/tracked_objects.h" |
| 149 #include "build/build_config.h" | 149 #include "build/build_config.h" |
| 150 #include "components/metrics/data_use_tracker.h" | 150 #include "components/metrics/data_use_tracker.h" |
| 151 #include "components/metrics/environment_recorder.h" | |
| 151 #include "components/metrics/metrics_log.h" | 152 #include "components/metrics/metrics_log.h" |
| 152 #include "components/metrics/metrics_log_manager.h" | 153 #include "components/metrics/metrics_log_manager.h" |
| 153 #include "components/metrics/metrics_log_uploader.h" | 154 #include "components/metrics/metrics_log_uploader.h" |
| 154 #include "components/metrics/metrics_pref_names.h" | 155 #include "components/metrics/metrics_pref_names.h" |
| 155 #include "components/metrics/metrics_reporting_scheduler.h" | 156 #include "components/metrics/metrics_reporting_scheduler.h" |
| 156 #include "components/metrics/metrics_rotation_scheduler.h" | 157 #include "components/metrics/metrics_rotation_scheduler.h" |
| 157 #include "components/metrics/metrics_service_client.h" | 158 #include "components/metrics/metrics_service_client.h" |
| 158 #include "components/metrics/metrics_state_manager.h" | 159 #include "components/metrics/metrics_state_manager.h" |
| 159 #include "components/metrics/metrics_upload_scheduler.h" | 160 #include "components/metrics/metrics_upload_scheduler.h" |
| 161 #include "components/metrics/stability_metrics_provider.h" | |
| 160 #include "components/metrics/url_constants.h" | 162 #include "components/metrics/url_constants.h" |
| 161 #include "components/prefs/pref_registry_simple.h" | 163 #include "components/prefs/pref_registry_simple.h" |
| 162 #include "components/prefs/pref_service.h" | 164 #include "components/prefs/pref_service.h" |
| 163 #include "components/variations/entropy_provider.h" | 165 #include "components/variations/entropy_provider.h" |
| 164 | 166 |
| 165 namespace metrics { | 167 namespace metrics { |
| 166 | 168 |
| 167 // This feature moves the upload schedule to a seperate schedule from the | 169 // This feature moves the upload schedule to a seperate schedule from the |
| 168 // log rotation schedule. This may change upload timing slightly, but | 170 // log rotation schedule. This may change upload timing slightly, but |
| 169 // would allow some compartmentalization of uploader logic to allow more | 171 // would allow some compartmentalization of uploader logic to allow more |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 237 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| 236 | 238 |
| 237 } // namespace | 239 } // namespace |
| 238 | 240 |
| 239 // static | 241 // static |
| 240 MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = | 242 MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = |
| 241 MetricsService::CLEANLY_SHUTDOWN; | 243 MetricsService::CLEANLY_SHUTDOWN; |
| 242 | 244 |
| 243 // static | 245 // static |
| 244 void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { | 246 void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { |
| 247 CleanExitBeacon::RegisterPrefs(registry); | |
| 245 MetricsStateManager::RegisterPrefs(registry); | 248 MetricsStateManager::RegisterPrefs(registry); |
| 246 MetricsLog::RegisterPrefs(registry); | 249 EnvironmentRecorder::RegisterPrefs(registry); |
| 250 StabilityMetricsProvider::RegisterPrefs(registry); | |
| 247 DataUseTracker::RegisterPrefs(registry); | 251 DataUseTracker::RegisterPrefs(registry); |
| 252 ExecutionPhaseManager::RegisterPrefs(registry); | |
| 248 | 253 |
| 249 registry->RegisterInt64Pref(prefs::kInstallDate, 0); | 254 registry->RegisterInt64Pref(prefs::kInstallDate, 0); |
| 250 | 255 |
| 251 registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); | |
| 252 registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); | |
| 253 registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); | |
| 254 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); | |
| 255 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | |
| 256 ExecutionPhaseManager::RegisterPrefs(registry); | |
| 257 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); | |
| 258 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); | 256 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); |
| 259 | 257 |
| 260 registry->RegisterListPref(prefs::kMetricsInitialLogs); | 258 registry->RegisterListPref(prefs::kMetricsInitialLogs); |
| 261 registry->RegisterListPref(prefs::kMetricsOngoingLogs); | 259 registry->RegisterListPref(prefs::kMetricsOngoingLogs); |
| 262 | 260 |
| 263 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); | 261 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); |
| 264 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); | 262 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); |
| 265 } | 263 } |
| 266 | 264 |
| 267 MetricsService::MetricsService(MetricsStateManager* state_manager, | 265 MetricsService::MetricsService(MetricsStateManager* state_manager, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 284 self_ptr_factory_(this) { | 282 self_ptr_factory_(this) { |
| 285 DCHECK(thread_checker_.CalledOnValidThread()); | 283 DCHECK(thread_checker_.CalledOnValidThread()); |
| 286 DCHECK(state_manager_); | 284 DCHECK(state_manager_); |
| 287 DCHECK(client_); | 285 DCHECK(client_); |
| 288 DCHECK(local_state_); | 286 DCHECK(local_state_); |
| 289 | 287 |
| 290 // Set the install date if this is our first run. | 288 // Set the install date if this is our first run. |
| 291 int64_t install_date = local_state_->GetInt64(prefs::kInstallDate); | 289 int64_t install_date = local_state_->GetInt64(prefs::kInstallDate); |
| 292 if (install_date == 0) | 290 if (install_date == 0) |
| 293 local_state_->SetInt64(prefs::kInstallDate, base::Time::Now().ToTimeT()); | 291 local_state_->SetInt64(prefs::kInstallDate, base::Time::Now().ToTimeT()); |
| 292 RegisterMetricsProvider(std::unique_ptr<metrics::MetricsProvider>( | |
|
rkaplow
2017/02/14 20:11:19
nit, add a blank line, looks like it's related to
Steven Holte
2017/02/15 22:42:09
Done.
| |
| 293 new StabilityMetricsProvider(local_state_))); | |
| 294 } | 294 } |
| 295 | 295 |
| 296 MetricsService::~MetricsService() { | 296 MetricsService::~MetricsService() { |
| 297 DisableRecording(); | 297 DisableRecording(); |
| 298 } | 298 } |
| 299 | 299 |
| 300 void MetricsService::InitializeMetricsRecordingState() { | 300 void MetricsService::InitializeMetricsRecordingState() { |
| 301 InitializeMetricsState(); | 301 InitializeMetricsState(); |
| 302 | 302 |
| 303 base::Closure upload_callback = | 303 base::Closure upload_callback = |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 } | 505 } |
| 506 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 506 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| 507 | 507 |
| 508 // static | 508 // static |
| 509 void MetricsService::SetExecutionPhase(ExecutionPhase execution_phase, | 509 void MetricsService::SetExecutionPhase(ExecutionPhase execution_phase, |
| 510 PrefService* local_state) { | 510 PrefService* local_state) { |
| 511 ExecutionPhaseManager(local_state).SetExecutionPhase(execution_phase); | 511 ExecutionPhaseManager(local_state).SetExecutionPhase(execution_phase); |
| 512 } | 512 } |
| 513 | 513 |
| 514 void MetricsService::RecordBreakpadRegistration(bool success) { | 514 void MetricsService::RecordBreakpadRegistration(bool success) { |
| 515 if (!success) | 515 StabilityMetricsProvider(local_state_).RecordBreakpadRegistration(success); |
| 516 IncrementPrefValue(prefs::kStabilityBreakpadRegistrationFail); | |
| 517 else | |
| 518 IncrementPrefValue(prefs::kStabilityBreakpadRegistrationSuccess); | |
| 519 } | 516 } |
| 520 | 517 |
| 521 void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { | 518 void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { |
| 522 if (!has_debugger) | 519 StabilityMetricsProvider(local_state_) |
| 523 IncrementPrefValue(prefs::kStabilityDebuggerNotPresent); | 520 .RecordBreakpadHasDebugger(has_debugger); |
| 524 else | |
| 525 IncrementPrefValue(prefs::kStabilityDebuggerPresent); | |
| 526 } | 521 } |
| 527 | 522 |
| 528 void MetricsService::ClearSavedStabilityMetrics() { | 523 void MetricsService::ClearSavedStabilityMetrics() { |
| 529 for (MetricsProvider* provider : metrics_providers_) | 524 for (MetricsProvider* provider : metrics_providers_) |
| 530 provider->ClearSavedStabilityMetrics(); | 525 provider->ClearSavedStabilityMetrics(); |
| 531 | |
| 532 // Reset the prefs that are managed by MetricsService/MetricsLog directly. | |
| 533 local_state_->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); | |
| 534 local_state_->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); | |
| 535 local_state_->SetInteger(prefs::kStabilityCrashCount, 0); | |
| 536 local_state_->SetInteger(prefs::kStabilityDebuggerPresent, 0); | |
| 537 local_state_->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); | |
| 538 local_state_->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); | |
| 539 local_state_->SetInteger(prefs::kStabilityLaunchCount, 0); | |
| 540 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true); | |
| 541 local_state_->SetInteger(prefs::kStabilityDeferredCount, 0); | |
| 542 // Note: kStabilityDiscardCount is not cleared as its intent is to measure | |
| 543 // the number of times data is discarded, even across versions. | |
| 544 local_state_->SetInteger(prefs::kStabilityVersionMismatchCount, 0); | |
| 545 } | 526 } |
| 546 | 527 |
| 547 void MetricsService::PushExternalLog(const std::string& log) { | 528 void MetricsService::PushExternalLog(const std::string& log) { |
| 548 log_manager_.StoreLog(log, MetricsLog::ONGOING_LOG); | 529 log_manager_.StoreLog(log, MetricsLog::ONGOING_LOG); |
| 549 } | 530 } |
| 550 | 531 |
| 551 void MetricsService::UpdateMetricsUsagePrefs(const std::string& service_name, | 532 void MetricsService::UpdateMetricsUsagePrefs(const std::string& service_name, |
| 552 int message_size, | 533 int message_size, |
| 553 bool is_cellular) { | 534 bool is_cellular) { |
| 554 DCHECK(thread_checker_.CalledOnValidThread()); | 535 DCHECK(thread_checker_.CalledOnValidThread()); |
| 555 if (data_use_tracker_) { | 536 if (data_use_tracker_) { |
| 556 data_use_tracker_->UpdateMetricsUsagePrefs(service_name, | 537 data_use_tracker_->UpdateMetricsUsagePrefs(service_name, |
| 557 message_size, | 538 message_size, |
| 558 is_cellular); | 539 is_cellular); |
| 559 } | 540 } |
| 560 } | 541 } |
| 561 | 542 |
| 562 //------------------------------------------------------------------------------ | 543 //------------------------------------------------------------------------------ |
| 563 // private methods | 544 // private methods |
| 564 //------------------------------------------------------------------------------ | 545 //------------------------------------------------------------------------------ |
| 565 | 546 |
| 566 | 547 |
| 567 //------------------------------------------------------------------------------ | 548 //------------------------------------------------------------------------------ |
| 568 // Initialization methods | 549 // Initialization methods |
| 569 | 550 |
| 570 void MetricsService::InitializeMetricsState() { | 551 void MetricsService::InitializeMetricsState() { |
| 571 const int64_t buildtime = MetricsLog::GetBuildTime(); | 552 const int64_t buildtime = MetricsLog::GetBuildTime(); |
| 572 const std::string version = client_->GetVersionString(); | 553 const std::string version = client_->GetVersionString(); |
| 573 | 554 |
| 574 // Delete deprecated prefs | |
| 575 // TODO(holte): Remove these in M58 | |
| 576 local_state_->ClearPref(prefs::kStabilityLaunchTimeSec); | |
| 577 local_state_->ClearPref(prefs::kStabilityLastTimestampSec); | |
| 578 | |
| 579 bool version_changed = false; | 555 bool version_changed = false; |
| 580 int64_t previous_buildtime = | 556 EnvironmentRecorder recorder(local_state_); |
| 581 local_state_->GetInt64(prefs::kStabilityStatsBuildTime); | 557 StabilityMetricsProvider provider(local_state_); |
| 582 std::string previous_version = | 558 int64_t previous_buildtime = recorder.GetLastBuildtime(); |
| 583 local_state_->GetString(prefs::kStabilityStatsVersion); | 559 std::string previous_version = recorder.GetLastVersion(); |
| 584 if (previous_buildtime != buildtime || previous_version != version) { | 560 if (previous_buildtime != buildtime || previous_version != version) { |
| 585 local_state_->SetString(prefs::kStabilityStatsVersion, version); | 561 recorder.SetBuildtimeAndVersion(buildtime, version); |
| 586 local_state_->SetInt64(prefs::kStabilityStatsBuildTime, buildtime); | |
| 587 version_changed = true; | 562 version_changed = true; |
| 588 } | 563 } |
| 589 | 564 |
| 590 log_manager_.LoadPersistedUnsentLogs(); | 565 log_manager_.LoadPersistedUnsentLogs(); |
| 591 | 566 |
| 592 session_id_ = local_state_->GetInteger(prefs::kMetricsSessionID); | 567 session_id_ = local_state_->GetInteger(prefs::kMetricsSessionID); |
| 593 | 568 |
| 594 if (!clean_exit_beacon_.exited_cleanly()) { | 569 if (!clean_exit_beacon_.exited_cleanly()) { |
| 595 IncrementPrefValue(prefs::kStabilityCrashCount); | 570 provider.LogCrash(); |
| 596 // Reset flag, and wait until we call LogNeedForCleanShutdown() before | 571 // Reset flag, and wait until we call LogNeedForCleanShutdown() before |
| 597 // monitoring. | 572 // monitoring. |
| 598 clean_exit_beacon_.WriteBeaconValue(true); | 573 clean_exit_beacon_.WriteBeaconValue(true); |
| 599 ExecutionPhaseManager manager(local_state_); | 574 ExecutionPhaseManager manager(local_state_); |
| 600 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", | 575 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", |
| 601 static_cast<int>(manager.GetExecutionPhase())); | 576 static_cast<int>(manager.GetExecutionPhase())); |
| 602 manager.SetExecutionPhase(ExecutionPhase::UNINITIALIZED_PHASE); | 577 manager.SetExecutionPhase(ExecutionPhase::UNINITIALIZED_PHASE); |
| 603 } | 578 } |
| 604 | 579 |
| 605 // ProvidersHaveInitialStabilityMetrics is called first to ensure it is never | 580 // ProvidersHaveInitialStabilityMetrics is called first to ensure it is never |
| 606 // bypassed. | 581 // bypassed. |
| 607 const bool is_initial_stability_log_required = | 582 const bool is_initial_stability_log_required = |
| 608 ProvidersHaveInitialStabilityMetrics() || | 583 ProvidersHaveInitialStabilityMetrics() || |
| 609 !clean_exit_beacon_.exited_cleanly(); | 584 !clean_exit_beacon_.exited_cleanly(); |
| 610 bool has_initial_stability_log = false; | 585 bool has_initial_stability_log = false; |
| 611 if (is_initial_stability_log_required) { | 586 if (is_initial_stability_log_required) { |
| 612 // If the previous session didn't exit cleanly, or if any provider | 587 // If the previous session didn't exit cleanly, or if any provider |
| 613 // explicitly requests it, prepare an initial stability log - | 588 // explicitly requests it, prepare an initial stability log - |
| 614 // provided UMA is enabled. | 589 // provided UMA is enabled. |
| 615 if (state_manager_->IsMetricsReportingEnabled()) { | 590 if (state_manager_->IsMetricsReportingEnabled()) { |
| 616 has_initial_stability_log = PrepareInitialStabilityLog(previous_version); | 591 has_initial_stability_log = PrepareInitialStabilityLog(previous_version); |
| 617 if (!has_initial_stability_log) | 592 if (!has_initial_stability_log) |
| 618 IncrementPrefValue(prefs::kStabilityDeferredCount); | 593 provider.LogStabilityLogDeferred(); |
| 619 } | 594 } |
| 620 } | 595 } |
| 621 | 596 |
| 622 // If the version changed, but no initial stability log was generated, clear | 597 // If the version changed, but no initial stability log was generated, clear |
| 623 // the stability stats from the previous version (so that they don't get | 598 // the stability stats from the previous version (so that they don't get |
| 624 // attributed to the current version). This could otherwise happen due to a | 599 // attributed to the current version). This could otherwise happen due to a |
| 625 // number of different edge cases, such as if the last version crashed before | 600 // number of different edge cases, such as if the last version crashed before |
| 626 // it could save off a system profile or if UMA reporting is disabled (which | 601 // it could save off a system profile or if UMA reporting is disabled (which |
| 627 // normally results in stats being accumulated). | 602 // normally results in stats being accumulated). |
| 628 if (version_changed && !has_initial_stability_log) { | 603 if (version_changed && !has_initial_stability_log) { |
| 629 ClearSavedStabilityMetrics(); | 604 ClearSavedStabilityMetrics(); |
| 630 IncrementPrefValue(prefs::kStabilityDiscardCount); | 605 provider.LogStabilityDataDiscarded(); |
| 631 } | 606 } |
| 632 | 607 |
| 633 // If the version changed, the system profile is obsolete and needs to be | 608 // If the version changed, the system profile is obsolete and needs to be |
| 634 // cleared. This is to avoid the stability data misattribution that could | 609 // cleared. This is to avoid the stability data misattribution that could |
| 635 // occur if the current version crashed before saving its own system profile. | 610 // occur if the current version crashed before saving its own system profile. |
| 636 // Note however this clearing occurs only after preparing the initial | 611 // Note however this clearing occurs only after preparing the initial |
| 637 // stability log, an operation that requires the previous version's system | 612 // stability log, an operation that requires the previous version's system |
| 638 // profile. At this point, stability metrics pertaining to the previous | 613 // profile. At this point, stability metrics pertaining to the previous |
| 639 // version have been cleared. | 614 // version have been cleared. |
| 640 if (version_changed) { | 615 if (version_changed) { |
| 641 local_state_->ClearPref(prefs::kStabilitySavedSystemProfile); | 616 recorder.ClearEnvironmentFromPrefs(); |
| 642 local_state_->ClearPref(prefs::kStabilitySavedSystemProfileHash); | |
| 643 } | 617 } |
| 644 | 618 |
| 645 // Update session ID. | 619 // Update session ID. |
| 646 ++session_id_; | 620 ++session_id_; |
| 647 local_state_->SetInteger(prefs::kMetricsSessionID, session_id_); | 621 local_state_->SetInteger(prefs::kMetricsSessionID, session_id_); |
| 648 | 622 |
| 649 // Stability bookkeeping | 623 // Stability bookkeeping |
|
rkaplow
2017/02/14 20:11:19
can you change this to a more helpful comment
Steven Holte
2017/02/15 22:42:09
Done.
| |
| 650 IncrementPrefValue(prefs::kStabilityLaunchCount); | 624 provider.LogLaunch(); |
| 651 | 625 |
| 652 SetExecutionPhase(ExecutionPhase::START_METRICS_RECORDING, local_state_); | 626 SetExecutionPhase(ExecutionPhase::START_METRICS_RECORDING, local_state_); |
| 653 | 627 |
| 654 if (!local_state_->GetBoolean(prefs::kStabilitySessionEndCompleted)) { | 628 provider.CheckLastSessionEndCompleted(); |
| 655 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); | |
| 656 // This is marked false when we get a WM_ENDSESSION. | |
| 657 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true); | |
| 658 } | |
| 659 | 629 |
| 660 // Call GetUptimes() for the first time, thus allowing all later calls | 630 // Call GetUptimes() for the first time, thus allowing all later calls |
| 661 // to record incremental uptimes accurately. | 631 // to record incremental uptimes accurately. |
| 662 base::TimeDelta ignored_uptime_parameter; | 632 base::TimeDelta ignored_uptime_parameter; |
| 663 base::TimeDelta startup_uptime; | 633 base::TimeDelta startup_uptime; |
| 664 GetUptimes(local_state_, &startup_uptime, &ignored_uptime_parameter); | 634 GetUptimes(local_state_, &startup_uptime, &ignored_uptime_parameter); |
| 665 DCHECK_EQ(0, startup_uptime.InMicroseconds()); | 635 DCHECK_EQ(0, startup_uptime.InMicroseconds()); |
| 666 | 636 |
| 667 // Bookkeeping for the uninstall metrics. | 637 // Bookkeeping for the uninstall metrics. |
| 668 IncrementLongPrefsValue(prefs::kUninstallLaunchCount); | 638 IncrementLongPrefsValue(prefs::kUninstallLaunchCount); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 966 CreateLog(MetricsLog::INITIAL_STABILITY_LOG)); | 936 CreateLog(MetricsLog::INITIAL_STABILITY_LOG)); |
| 967 | 937 |
| 968 // Do not call NotifyOnDidCreateMetricsLog here because the stability | 938 // Do not call NotifyOnDidCreateMetricsLog here because the stability |
| 969 // log describes stats from the _previous_ session. | 939 // log describes stats from the _previous_ session. |
| 970 std::string system_profile_app_version; | 940 std::string system_profile_app_version; |
| 971 if (!initial_stability_log->LoadSavedEnvironmentFromPrefs( | 941 if (!initial_stability_log->LoadSavedEnvironmentFromPrefs( |
| 972 &system_profile_app_version)) { | 942 &system_profile_app_version)) { |
| 973 return false; | 943 return false; |
| 974 } | 944 } |
| 975 if (system_profile_app_version != prefs_previous_version) | 945 if (system_profile_app_version != prefs_previous_version) |
| 976 IncrementPrefValue(prefs::kStabilityVersionMismatchCount); | 946 StabilityMetricsProvider(local_state_).LogStabilityVersionMismatch(); |
| 977 | 947 |
| 978 log_manager_.PauseCurrentLog(); | 948 log_manager_.PauseCurrentLog(); |
| 979 log_manager_.BeginLoggingWithLog(std::move(initial_stability_log)); | 949 log_manager_.BeginLoggingWithLog(std::move(initial_stability_log)); |
| 980 | 950 |
| 981 // Note: Some stability providers may record stability stats via histograms, | 951 // Note: Some stability providers may record stability stats via histograms, |
| 982 // so this call has to be after BeginLoggingWithLog(). | 952 // so this call has to be after BeginLoggingWithLog(). |
| 983 log_manager_.current_log()->RecordStabilityMetrics( | 953 log_manager_.current_log()->RecordStabilityMetrics( |
| 984 metrics_providers_.get(), base::TimeDelta(), base::TimeDelta()); | 954 metrics_providers_.get(), base::TimeDelta(), base::TimeDelta()); |
| 985 RecordCurrentStabilityHistograms(); | 955 RecordCurrentStabilityHistograms(); |
| 986 | 956 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1097 DVLOG(1) << "Stopping upload_scheduler_"; | 1067 DVLOG(1) << "Stopping upload_scheduler_"; |
| 1098 upload_scheduler_->Stop(); | 1068 upload_scheduler_->Stop(); |
| 1099 } | 1069 } |
| 1100 upload_scheduler_->UploadFinished(server_is_healthy); | 1070 upload_scheduler_->UploadFinished(server_is_healthy); |
| 1101 } else { | 1071 } else { |
| 1102 scheduler_->UploadFinished(server_is_healthy, | 1072 scheduler_->UploadFinished(server_is_healthy, |
| 1103 log_manager_.has_unsent_logs()); | 1073 log_manager_.has_unsent_logs()); |
| 1104 } | 1074 } |
| 1105 } | 1075 } |
| 1106 | 1076 |
| 1107 void MetricsService::IncrementPrefValue(const char* path) { | |
| 1108 int value = local_state_->GetInteger(path); | |
| 1109 local_state_->SetInteger(path, value + 1); | |
| 1110 } | |
| 1111 | |
| 1112 void MetricsService::IncrementLongPrefsValue(const char* path) { | 1077 void MetricsService::IncrementLongPrefsValue(const char* path) { |
| 1113 int64_t value = local_state_->GetInt64(path); | 1078 int64_t value = local_state_->GetInt64(path); |
| 1114 local_state_->SetInt64(path, value + 1); | 1079 local_state_->SetInt64(path, value + 1); |
| 1115 } | 1080 } |
| 1116 | 1081 |
| 1117 bool MetricsService::UmaMetricsProperlyShutdown() { | 1082 bool MetricsService::UmaMetricsProperlyShutdown() { |
| 1118 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || | 1083 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || |
| 1119 clean_shutdown_status_ == NEED_TO_SHUTDOWN); | 1084 clean_shutdown_status_ == NEED_TO_SHUTDOWN); |
| 1120 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; | 1085 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; |
| 1121 } | 1086 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1253 } | 1218 } |
| 1254 | 1219 |
| 1255 void MetricsService::LogCleanShutdown(bool end_completed) { | 1220 void MetricsService::LogCleanShutdown(bool end_completed) { |
| 1256 DCHECK(thread_checker_.CalledOnValidThread()); | 1221 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1257 // Redundant setting to assure that we always reset this value at shutdown | 1222 // 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). | 1223 // (and that we don't use some alternate path, and not call LogCleanShutdown). |
| 1259 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | 1224 clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
| 1260 client_->OnLogCleanShutdown(); | 1225 client_->OnLogCleanShutdown(); |
| 1261 clean_exit_beacon_.WriteBeaconValue(true); | 1226 clean_exit_beacon_.WriteBeaconValue(true); |
| 1262 SetExecutionPhase(ExecutionPhase::SHUTDOWN_COMPLETE, local_state_); | 1227 SetExecutionPhase(ExecutionPhase::SHUTDOWN_COMPLETE, local_state_); |
| 1263 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, end_completed); | 1228 StabilityMetricsProvider(local_state_).MarkSessionEndCompleted(end_completed); |
| 1264 } | 1229 } |
| 1265 | 1230 |
| 1266 } // namespace metrics | 1231 } // namespace metrics |
| OLD | NEW |