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 namespace { | 169 namespace { |
| 168 | 170 |
| 169 // This drops records if the number of events (user action and omnibox) exceeds | 171 // This drops records if the number of events (user action and omnibox) exceeds |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 230 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| 229 | 231 |
| 230 } // namespace | 232 } // namespace |
| 231 | 233 |
| 232 // static | 234 // static |
| 233 MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = | 235 MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = |
| 234 MetricsService::CLEANLY_SHUTDOWN; | 236 MetricsService::CLEANLY_SHUTDOWN; |
| 235 | 237 |
| 236 // static | 238 // static |
| 237 void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { | 239 void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { |
| 240 CleanExitBeacon::RegisterPrefs(registry); | |
| 238 MetricsStateManager::RegisterPrefs(registry); | 241 MetricsStateManager::RegisterPrefs(registry); |
| 239 MetricsLog::RegisterPrefs(registry); | 242 MetricsLog::RegisterPrefs(registry); |
| 243 StabilityMetricsProvider::RegisterPrefs(registry); | |
| 240 DataUseTracker::RegisterPrefs(registry); | 244 DataUseTracker::RegisterPrefs(registry); |
| 245 ExecutionPhaseManager::RegisterPrefs(registry); | |
| 241 | 246 |
| 242 registry->RegisterInt64Pref(prefs::kInstallDate, 0); | 247 registry->RegisterInt64Pref(prefs::kInstallDate, 0); |
| 243 | 248 |
| 244 registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); | |
| 245 registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); | |
| 246 registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); | |
| 247 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); | |
| 248 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | |
| 249 ExecutionPhaseManager::RegisterPrefs(registry); | |
| 250 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); | |
| 251 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); | 249 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); |
| 252 | 250 |
| 253 registry->RegisterListPref(prefs::kMetricsInitialLogs); | 251 registry->RegisterListPref(prefs::kMetricsInitialLogs); |
| 254 registry->RegisterListPref(prefs::kMetricsOngoingLogs); | 252 registry->RegisterListPref(prefs::kMetricsOngoingLogs); |
| 255 | 253 |
| 256 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); | 254 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); |
| 257 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); | 255 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); |
| 258 } | 256 } |
| 259 | 257 |
| 260 MetricsService::MetricsService(MetricsStateManager* state_manager, | 258 MetricsService::MetricsService(MetricsStateManager* state_manager, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 277 self_ptr_factory_(this) { | 275 self_ptr_factory_(this) { |
| 278 DCHECK(thread_checker_.CalledOnValidThread()); | 276 DCHECK(thread_checker_.CalledOnValidThread()); |
| 279 DCHECK(state_manager_); | 277 DCHECK(state_manager_); |
| 280 DCHECK(client_); | 278 DCHECK(client_); |
| 281 DCHECK(local_state_); | 279 DCHECK(local_state_); |
| 282 | 280 |
| 283 // Set the install date if this is our first run. | 281 // Set the install date if this is our first run. |
| 284 int64_t install_date = local_state_->GetInt64(prefs::kInstallDate); | 282 int64_t install_date = local_state_->GetInt64(prefs::kInstallDate); |
| 285 if (install_date == 0) | 283 if (install_date == 0) |
| 286 local_state_->SetInt64(prefs::kInstallDate, base::Time::Now().ToTimeT()); | 284 local_state_->SetInt64(prefs::kInstallDate, base::Time::Now().ToTimeT()); |
| 285 | |
| 286 RegisterMetricsProvider(std::unique_ptr<metrics::MetricsProvider>( | |
| 287 new StabilityMetricsProvider(local_state_))); | |
| 287 } | 288 } |
| 288 | 289 |
| 289 MetricsService::~MetricsService() { | 290 MetricsService::~MetricsService() { |
| 290 DisableRecording(); | 291 DisableRecording(); |
| 291 } | 292 } |
| 292 | 293 |
| 293 void MetricsService::InitializeMetricsRecordingState() { | 294 void MetricsService::InitializeMetricsRecordingState() { |
| 294 InitializeMetricsState(); | 295 InitializeMetricsState(); |
| 295 | 296 |
| 296 base::Closure upload_callback = | 297 base::Closure upload_callback = |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 } | 499 } |
| 499 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 500 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| 500 | 501 |
| 501 // static | 502 // static |
| 502 void MetricsService::SetExecutionPhase(ExecutionPhase execution_phase, | 503 void MetricsService::SetExecutionPhase(ExecutionPhase execution_phase, |
| 503 PrefService* local_state) { | 504 PrefService* local_state) { |
| 504 ExecutionPhaseManager(local_state).SetExecutionPhase(execution_phase); | 505 ExecutionPhaseManager(local_state).SetExecutionPhase(execution_phase); |
| 505 } | 506 } |
| 506 | 507 |
| 507 void MetricsService::RecordBreakpadRegistration(bool success) { | 508 void MetricsService::RecordBreakpadRegistration(bool success) { |
| 508 if (!success) | 509 StabilityMetricsProvider(local_state_).RecordBreakpadRegistration(success); |
| 509 IncrementPrefValue(prefs::kStabilityBreakpadRegistrationFail); | |
| 510 else | |
| 511 IncrementPrefValue(prefs::kStabilityBreakpadRegistrationSuccess); | |
| 512 } | 510 } |
| 513 | 511 |
| 514 void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { | 512 void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { |
| 515 if (!has_debugger) | 513 StabilityMetricsProvider(local_state_) |
| 516 IncrementPrefValue(prefs::kStabilityDebuggerNotPresent); | 514 .RecordBreakpadHasDebugger(has_debugger); |
| 517 else | |
| 518 IncrementPrefValue(prefs::kStabilityDebuggerPresent); | |
| 519 } | 515 } |
| 520 | 516 |
| 521 void MetricsService::ClearSavedStabilityMetrics() { | 517 void MetricsService::ClearSavedStabilityMetrics() { |
| 522 for (auto& provider : metrics_providers_) | 518 for (auto& provider : metrics_providers_) |
| 523 provider->ClearSavedStabilityMetrics(); | 519 provider->ClearSavedStabilityMetrics(); |
| 524 | |
| 525 // Reset the prefs that are managed by MetricsService/MetricsLog directly. | |
| 526 local_state_->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); | |
| 527 local_state_->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); | |
| 528 local_state_->SetInteger(prefs::kStabilityCrashCount, 0); | |
| 529 local_state_->SetInteger(prefs::kStabilityDebuggerPresent, 0); | |
| 530 local_state_->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); | |
| 531 local_state_->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); | |
| 532 local_state_->SetInteger(prefs::kStabilityLaunchCount, 0); | |
| 533 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true); | |
| 534 local_state_->SetInteger(prefs::kStabilityDeferredCount, 0); | |
| 535 // Note: kStabilityDiscardCount is not cleared as its intent is to measure | |
| 536 // the number of times data is discarded, even across versions. | |
| 537 local_state_->SetInteger(prefs::kStabilityVersionMismatchCount, 0); | |
| 538 } | 520 } |
| 539 | 521 |
| 540 void MetricsService::PushExternalLog(const std::string& log) { | 522 void MetricsService::PushExternalLog(const std::string& log) { |
| 541 log_manager_.StoreLog(log, MetricsLog::ONGOING_LOG); | 523 log_manager_.StoreLog(log, MetricsLog::ONGOING_LOG); |
| 542 } | 524 } |
| 543 | 525 |
| 544 void MetricsService::UpdateMetricsUsagePrefs(const std::string& service_name, | 526 void MetricsService::UpdateMetricsUsagePrefs(const std::string& service_name, |
| 545 int message_size, | 527 int message_size, |
| 546 bool is_cellular) { | 528 bool is_cellular) { |
| 547 DCHECK(thread_checker_.CalledOnValidThread()); | 529 DCHECK(thread_checker_.CalledOnValidThread()); |
| 548 if (data_use_tracker_) { | 530 if (data_use_tracker_) { |
| 549 data_use_tracker_->UpdateMetricsUsagePrefs(service_name, | 531 data_use_tracker_->UpdateMetricsUsagePrefs(service_name, |
| 550 message_size, | 532 message_size, |
| 551 is_cellular); | 533 is_cellular); |
| 552 } | 534 } |
| 553 } | 535 } |
| 554 | 536 |
| 555 //------------------------------------------------------------------------------ | 537 //------------------------------------------------------------------------------ |
| 556 // private methods | 538 // private methods |
| 557 //------------------------------------------------------------------------------ | 539 //------------------------------------------------------------------------------ |
| 558 | 540 |
| 559 | 541 |
| 560 //------------------------------------------------------------------------------ | 542 //------------------------------------------------------------------------------ |
| 561 // Initialization methods | 543 // Initialization methods |
| 562 | 544 |
| 563 void MetricsService::InitializeMetricsState() { | 545 void MetricsService::InitializeMetricsState() { |
| 564 const int64_t buildtime = MetricsLog::GetBuildTime(); | 546 const int64_t buildtime = MetricsLog::GetBuildTime(); |
| 565 const std::string version = client_->GetVersionString(); | 547 const std::string version = client_->GetVersionString(); |
| 566 | 548 |
| 567 // Delete deprecated prefs | |
| 568 // TODO(holte): Remove these in M58 | |
| 569 local_state_->ClearPref(prefs::kStabilityLaunchTimeSec); | |
| 570 local_state_->ClearPref(prefs::kStabilityLastTimestampSec); | |
| 571 | |
| 572 bool version_changed = false; | 549 bool version_changed = false; |
| 573 int64_t previous_buildtime = | 550 EnvironmentRecorder recorder(local_state_); |
| 574 local_state_->GetInt64(prefs::kStabilityStatsBuildTime); | 551 StabilityMetricsProvider provider(local_state_); |
|
Alexei Svitkine (slow)
2017/02/17 16:02:23
Move this closer to where it's used.
Steven Holte
2017/02/17 20:21:32
Done.
| |
| 575 std::string previous_version = | 552 int64_t previous_buildtime = recorder.GetLastBuildtime(); |
| 576 local_state_->GetString(prefs::kStabilityStatsVersion); | 553 std::string previous_version = recorder.GetLastVersion(); |
| 577 if (previous_buildtime != buildtime || previous_version != version) { | 554 if (previous_buildtime != buildtime || previous_version != version) { |
| 578 local_state_->SetString(prefs::kStabilityStatsVersion, version); | 555 recorder.SetBuildtimeAndVersion(buildtime, version); |
| 579 local_state_->SetInt64(prefs::kStabilityStatsBuildTime, buildtime); | |
| 580 version_changed = true; | 556 version_changed = true; |
| 581 } | 557 } |
| 582 | 558 |
| 583 log_manager_.LoadPersistedUnsentLogs(); | 559 log_manager_.LoadPersistedUnsentLogs(); |
| 584 | 560 |
| 585 session_id_ = local_state_->GetInteger(prefs::kMetricsSessionID); | 561 session_id_ = local_state_->GetInteger(prefs::kMetricsSessionID); |
| 586 | 562 |
| 587 if (!clean_exit_beacon_.exited_cleanly()) { | 563 if (!clean_exit_beacon_.exited_cleanly()) { |
| 588 IncrementPrefValue(prefs::kStabilityCrashCount); | 564 provider.LogCrash(); |
| 589 // Reset flag, and wait until we call LogNeedForCleanShutdown() before | 565 // Reset flag, and wait until we call LogNeedForCleanShutdown() before |
| 590 // monitoring. | 566 // monitoring. |
| 591 clean_exit_beacon_.WriteBeaconValue(true); | 567 clean_exit_beacon_.WriteBeaconValue(true); |
| 592 ExecutionPhaseManager manager(local_state_); | 568 ExecutionPhaseManager manager(local_state_); |
| 593 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", | 569 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", |
| 594 static_cast<int>(manager.GetExecutionPhase())); | 570 static_cast<int>(manager.GetExecutionPhase())); |
| 595 manager.SetExecutionPhase(ExecutionPhase::UNINITIALIZED_PHASE); | 571 manager.SetExecutionPhase(ExecutionPhase::UNINITIALIZED_PHASE); |
| 596 } | 572 } |
| 597 | 573 |
| 598 // ProvidersHaveInitialStabilityMetrics is called first to ensure it is never | 574 // ProvidersHaveInitialStabilityMetrics is called first to ensure it is never |
| 599 // bypassed. | 575 // bypassed. |
| 600 const bool is_initial_stability_log_required = | 576 const bool is_initial_stability_log_required = |
| 601 ProvidersHaveInitialStabilityMetrics() || | 577 ProvidersHaveInitialStabilityMetrics() || |
| 602 !clean_exit_beacon_.exited_cleanly(); | 578 !clean_exit_beacon_.exited_cleanly(); |
| 603 bool has_initial_stability_log = false; | 579 bool has_initial_stability_log = false; |
| 604 if (is_initial_stability_log_required) { | 580 if (is_initial_stability_log_required) { |
| 605 // If the previous session didn't exit cleanly, or if any provider | 581 // If the previous session didn't exit cleanly, or if any provider |
| 606 // explicitly requests it, prepare an initial stability log - | 582 // explicitly requests it, prepare an initial stability log - |
| 607 // provided UMA is enabled. | 583 // provided UMA is enabled. |
| 608 if (state_manager_->IsMetricsReportingEnabled()) { | 584 if (state_manager_->IsMetricsReportingEnabled()) { |
| 609 has_initial_stability_log = PrepareInitialStabilityLog(previous_version); | 585 has_initial_stability_log = PrepareInitialStabilityLog(previous_version); |
| 610 if (!has_initial_stability_log) | 586 if (!has_initial_stability_log) |
| 611 IncrementPrefValue(prefs::kStabilityDeferredCount); | 587 provider.LogStabilityLogDeferred(); |
| 612 } | 588 } |
| 613 } | 589 } |
| 614 | 590 |
| 615 // If the version changed, but no initial stability log was generated, clear | 591 // If the version changed, but no initial stability log was generated, clear |
| 616 // the stability stats from the previous version (so that they don't get | 592 // the stability stats from the previous version (so that they don't get |
| 617 // attributed to the current version). This could otherwise happen due to a | 593 // attributed to the current version). This could otherwise happen due to a |
| 618 // number of different edge cases, such as if the last version crashed before | 594 // number of different edge cases, such as if the last version crashed before |
| 619 // it could save off a system profile or if UMA reporting is disabled (which | 595 // it could save off a system profile or if UMA reporting is disabled (which |
| 620 // normally results in stats being accumulated). | 596 // normally results in stats being accumulated). |
| 621 if (version_changed && !has_initial_stability_log) { | 597 if (version_changed && !has_initial_stability_log) { |
| 622 ClearSavedStabilityMetrics(); | 598 ClearSavedStabilityMetrics(); |
| 623 IncrementPrefValue(prefs::kStabilityDiscardCount); | 599 provider.LogStabilityDataDiscarded(); |
| 624 } | 600 } |
| 625 | 601 |
| 626 // If the version changed, the system profile is obsolete and needs to be | 602 // If the version changed, the system profile is obsolete and needs to be |
| 627 // cleared. This is to avoid the stability data misattribution that could | 603 // cleared. This is to avoid the stability data misattribution that could |
| 628 // occur if the current version crashed before saving its own system profile. | 604 // occur if the current version crashed before saving its own system profile. |
| 629 // Note however this clearing occurs only after preparing the initial | 605 // Note however this clearing occurs only after preparing the initial |
| 630 // stability log, an operation that requires the previous version's system | 606 // stability log, an operation that requires the previous version's system |
| 631 // profile. At this point, stability metrics pertaining to the previous | 607 // profile. At this point, stability metrics pertaining to the previous |
| 632 // version have been cleared. | 608 // version have been cleared. |
| 633 if (version_changed) { | 609 if (version_changed) { |
|
Alexei Svitkine (slow)
2017/02/17 16:02:23
Nit: No {}
Steven Holte
2017/02/17 20:21:32
Done.
| |
| 634 local_state_->ClearPref(prefs::kStabilitySavedSystemProfile); | 610 recorder.ClearEnvironmentFromPrefs(); |
| 635 local_state_->ClearPref(prefs::kStabilitySavedSystemProfileHash); | |
| 636 } | 611 } |
| 637 | 612 |
| 638 // Update session ID. | 613 // Update session ID. |
| 639 ++session_id_; | 614 ++session_id_; |
| 640 local_state_->SetInteger(prefs::kMetricsSessionID, session_id_); | 615 local_state_->SetInteger(prefs::kMetricsSessionID, session_id_); |
| 641 | 616 |
| 642 // Stability bookkeeping | 617 // Notify stability metrics providers about the launch. |
| 643 IncrementPrefValue(prefs::kStabilityLaunchCount); | 618 provider.LogLaunch(); |
| 644 | |
| 645 SetExecutionPhase(ExecutionPhase::START_METRICS_RECORDING, local_state_); | 619 SetExecutionPhase(ExecutionPhase::START_METRICS_RECORDING, local_state_); |
| 646 | 620 provider.CheckLastSessionEndCompleted(); |
| 647 if (!local_state_->GetBoolean(prefs::kStabilitySessionEndCompleted)) { | |
| 648 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); | |
| 649 // This is marked false when we get a WM_ENDSESSION. | |
| 650 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true); | |
| 651 } | |
| 652 | 621 |
| 653 // Call GetUptimes() for the first time, thus allowing all later calls | 622 // Call GetUptimes() for the first time, thus allowing all later calls |
| 654 // to record incremental uptimes accurately. | 623 // to record incremental uptimes accurately. |
| 655 base::TimeDelta ignored_uptime_parameter; | 624 base::TimeDelta ignored_uptime_parameter; |
| 656 base::TimeDelta startup_uptime; | 625 base::TimeDelta startup_uptime; |
| 657 GetUptimes(local_state_, &startup_uptime, &ignored_uptime_parameter); | 626 GetUptimes(local_state_, &startup_uptime, &ignored_uptime_parameter); |
| 658 DCHECK_EQ(0, startup_uptime.InMicroseconds()); | 627 DCHECK_EQ(0, startup_uptime.InMicroseconds()); |
| 659 | 628 |
| 660 // Bookkeeping for the uninstall metrics. | 629 // Bookkeeping for the uninstall metrics. |
| 661 IncrementLongPrefsValue(prefs::kUninstallLaunchCount); | 630 IncrementLongPrefsValue(prefs::kUninstallLaunchCount); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 CreateLog(MetricsLog::INITIAL_STABILITY_LOG)); | 927 CreateLog(MetricsLog::INITIAL_STABILITY_LOG)); |
| 959 | 928 |
| 960 // Do not call NotifyOnDidCreateMetricsLog here because the stability | 929 // Do not call NotifyOnDidCreateMetricsLog here because the stability |
| 961 // log describes stats from the _previous_ session. | 930 // log describes stats from the _previous_ session. |
| 962 std::string system_profile_app_version; | 931 std::string system_profile_app_version; |
| 963 if (!initial_stability_log->LoadSavedEnvironmentFromPrefs( | 932 if (!initial_stability_log->LoadSavedEnvironmentFromPrefs( |
| 964 &system_profile_app_version)) { | 933 &system_profile_app_version)) { |
| 965 return false; | 934 return false; |
| 966 } | 935 } |
| 967 if (system_profile_app_version != prefs_previous_version) | 936 if (system_profile_app_version != prefs_previous_version) |
| 968 IncrementPrefValue(prefs::kStabilityVersionMismatchCount); | 937 StabilityMetricsProvider(local_state_).LogStabilityVersionMismatch(); |
| 969 | 938 |
| 970 log_manager_.PauseCurrentLog(); | 939 log_manager_.PauseCurrentLog(); |
| 971 log_manager_.BeginLoggingWithLog(std::move(initial_stability_log)); | 940 log_manager_.BeginLoggingWithLog(std::move(initial_stability_log)); |
| 972 | 941 |
| 973 // Note: Some stability providers may record stability stats via histograms, | 942 // Note: Some stability providers may record stability stats via histograms, |
| 974 // so this call has to be after BeginLoggingWithLog(). | 943 // so this call has to be after BeginLoggingWithLog(). |
| 975 log_manager_.current_log()->RecordStabilityMetrics( | 944 log_manager_.current_log()->RecordStabilityMetrics( |
| 976 metrics_providers_, base::TimeDelta(), base::TimeDelta()); | 945 metrics_providers_, base::TimeDelta(), base::TimeDelta()); |
| 977 RecordCurrentStabilityHistograms(); | 946 RecordCurrentStabilityHistograms(); |
| 978 | 947 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1089 DVLOG(1) << "Stopping upload_scheduler_"; | 1058 DVLOG(1) << "Stopping upload_scheduler_"; |
| 1090 upload_scheduler_->Stop(); | 1059 upload_scheduler_->Stop(); |
| 1091 } | 1060 } |
| 1092 upload_scheduler_->UploadFinished(server_is_healthy); | 1061 upload_scheduler_->UploadFinished(server_is_healthy); |
| 1093 } else { | 1062 } else { |
| 1094 scheduler_->UploadFinished(server_is_healthy, | 1063 scheduler_->UploadFinished(server_is_healthy, |
| 1095 log_manager_.has_unsent_logs()); | 1064 log_manager_.has_unsent_logs()); |
| 1096 } | 1065 } |
| 1097 } | 1066 } |
| 1098 | 1067 |
| 1099 void MetricsService::IncrementPrefValue(const char* path) { | |
| 1100 int value = local_state_->GetInteger(path); | |
| 1101 local_state_->SetInteger(path, value + 1); | |
| 1102 } | |
| 1103 | |
| 1104 void MetricsService::IncrementLongPrefsValue(const char* path) { | 1068 void MetricsService::IncrementLongPrefsValue(const char* path) { |
| 1105 int64_t value = local_state_->GetInt64(path); | 1069 int64_t value = local_state_->GetInt64(path); |
| 1106 local_state_->SetInt64(path, value + 1); | 1070 local_state_->SetInt64(path, value + 1); |
| 1107 } | 1071 } |
| 1108 | 1072 |
| 1109 bool MetricsService::UmaMetricsProperlyShutdown() { | 1073 bool MetricsService::UmaMetricsProperlyShutdown() { |
| 1110 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || | 1074 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || |
| 1111 clean_shutdown_status_ == NEED_TO_SHUTDOWN); | 1075 clean_shutdown_status_ == NEED_TO_SHUTDOWN); |
| 1112 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; | 1076 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; |
| 1113 } | 1077 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 } | 1209 } |
| 1246 | 1210 |
| 1247 void MetricsService::LogCleanShutdown(bool end_completed) { | 1211 void MetricsService::LogCleanShutdown(bool end_completed) { |
| 1248 DCHECK(thread_checker_.CalledOnValidThread()); | 1212 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1249 // Redundant setting to assure that we always reset this value at shutdown | 1213 // Redundant setting to assure that we always reset this value at shutdown |
| 1250 // (and that we don't use some alternate path, and not call LogCleanShutdown). | 1214 // (and that we don't use some alternate path, and not call LogCleanShutdown). |
| 1251 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | 1215 clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
| 1252 client_->OnLogCleanShutdown(); | 1216 client_->OnLogCleanShutdown(); |
| 1253 clean_exit_beacon_.WriteBeaconValue(true); | 1217 clean_exit_beacon_.WriteBeaconValue(true); |
| 1254 SetExecutionPhase(ExecutionPhase::SHUTDOWN_COMPLETE, local_state_); | 1218 SetExecutionPhase(ExecutionPhase::SHUTDOWN_COMPLETE, local_state_); |
| 1255 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, end_completed); | 1219 StabilityMetricsProvider(local_state_).MarkSessionEndCompleted(end_completed); |
| 1256 } | 1220 } |
| 1257 | 1221 |
| 1258 } // namespace metrics | 1222 } // namespace metrics |
| OLD | NEW |