Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: components/metrics/metrics_service.cc

Issue 2428413005: Revise system profile prefs clearing (Closed)
Patch Set: Update LoadSavedEnvironmentFromPrefs's comment Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/metrics/metrics_log_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 577
578 session_id_ = local_state_->GetInteger(prefs::kMetricsSessionID); 578 session_id_ = local_state_->GetInteger(prefs::kMetricsSessionID);
579 579
580 if (!clean_exit_beacon_.exited_cleanly()) { 580 if (!clean_exit_beacon_.exited_cleanly()) {
581 IncrementPrefValue(prefs::kStabilityCrashCount); 581 IncrementPrefValue(prefs::kStabilityCrashCount);
582 // Reset flag, and wait until we call LogNeedForCleanShutdown() before 582 // Reset flag, and wait until we call LogNeedForCleanShutdown() before
583 // monitoring. 583 // monitoring.
584 clean_exit_beacon_.WriteBeaconValue(true); 584 clean_exit_beacon_.WriteBeaconValue(true);
585 } 585 }
586 586
587 // ProvidersHaveInitialStabilityMetrics is called first to ensure it is never
588 // bypassed.
589 const bool is_initial_stability_log_required =
590 ProvidersHaveInitialStabilityMetrics() ||
591 !clean_exit_beacon_.exited_cleanly();
587 bool has_initial_stability_log = false; 592 bool has_initial_stability_log = false;
588 bool providers_have_initial_stability_metrics = 593 if (is_initial_stability_log_required) {
589 ProvidersHaveInitialStabilityMetrics();
590 if (!clean_exit_beacon_.exited_cleanly() ||
591 providers_have_initial_stability_metrics) {
592 // TODO(rtenneti): On windows, consider saving/getting execution_phase from 594 // TODO(rtenneti): On windows, consider saving/getting execution_phase from
593 // the registry. 595 // the registry.
594 int execution_phase = 596 int execution_phase =
595 local_state_->GetInteger(prefs::kStabilityExecutionPhase); 597 local_state_->GetInteger(prefs::kStabilityExecutionPhase);
596 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", 598 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase",
597 execution_phase); 599 execution_phase);
598 600
599 // If the previous session didn't exit cleanly, or if any provider 601 // If the previous session didn't exit cleanly, or if any provider
600 // explicitly requests it, prepare an initial stability log - 602 // explicitly requests it, prepare an initial stability log -
601 // provided UMA is enabled. 603 // provided UMA is enabled.
602 if (state_manager_->IsMetricsReportingEnabled()) { 604 if (state_manager_->IsMetricsReportingEnabled()) {
603 has_initial_stability_log = PrepareInitialStabilityLog(previous_version); 605 has_initial_stability_log = PrepareInitialStabilityLog(previous_version);
604 if (!has_initial_stability_log) 606 if (!has_initial_stability_log)
605 IncrementPrefValue(prefs::kStabilityDeferredCount); 607 IncrementPrefValue(prefs::kStabilityDeferredCount);
606 } 608 }
607 } 609 }
608 610
609 // If no initial stability log was generated and there was a version upgrade, 611 // If the version changed, but no initial stability log was generated, clear
610 // clear the stability stats from the previous version (so that they don't get 612 // the stability stats from the previous version (so that they don't get
611 // attributed to the current version). This could otherwise happen due to a 613 // attributed to the current version). This could otherwise happen due to a
612 // number of different edge cases, such as if the last version crashed before 614 // number of different edge cases, such as if the last version crashed before
613 // it could save off a system profile or if UMA reporting is disabled (which 615 // it could save off a system profile or if UMA reporting is disabled (which
614 // normally results in stats being accumulated). 616 // normally results in stats being accumulated).
615 if (!has_initial_stability_log && version_changed) { 617 if (version_changed && !has_initial_stability_log) {
616 ClearSavedStabilityMetrics(); 618 ClearSavedStabilityMetrics();
617 IncrementPrefValue(prefs::kStabilityDiscardCount); 619 IncrementPrefValue(prefs::kStabilityDiscardCount);
618 } 620 }
619 621
622 // If the version changed, the system profile is obsolete and needs to be
623 // cleared. This is to avoid the stability data misattribution that could
624 // occur if the current version crashed before saving its own system profile.
625 // Note however this clearing occurs only after preparing the initial
626 // stability log, an operation that requires the previous version's system
627 // profile. At this point, stability metrics pertaining to the previous
628 // version have been cleared.
629 if (version_changed) {
630 local_state_->ClearPref(prefs::kStabilitySavedSystemProfile);
631 local_state_->ClearPref(prefs::kStabilitySavedSystemProfileHash);
632 }
633
620 // Update session ID. 634 // Update session ID.
621 ++session_id_; 635 ++session_id_;
622 local_state_->SetInteger(prefs::kMetricsSessionID, session_id_); 636 local_state_->SetInteger(prefs::kMetricsSessionID, session_id_);
623 637
624 // Stability bookkeeping 638 // Stability bookkeeping
625 IncrementPrefValue(prefs::kStabilityLaunchCount); 639 IncrementPrefValue(prefs::kStabilityLaunchCount);
626 640
627 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); 641 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_);
628 SetExecutionPhase(START_METRICS_RECORDING, local_state_); 642 SetExecutionPhase(START_METRICS_RECORDING, local_state_);
629 643
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 base::Time::Now().ToTimeT()); 1222 base::Time::Now().ToTimeT());
1209 } 1223 }
1210 1224
1211 void MetricsService::SkipAndDiscardUpload() { 1225 void MetricsService::SkipAndDiscardUpload() {
1212 log_manager_.DiscardStagedLog(); 1226 log_manager_.DiscardStagedLog();
1213 scheduler_->UploadCancelled(); 1227 scheduler_->UploadCancelled();
1214 log_upload_in_progress_ = false; 1228 log_upload_in_progress_ = false;
1215 } 1229 }
1216 1230
1217 } // namespace metrics 1231 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_log_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698