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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 bool is_initial_stability_log_required = | |
Alexei Svitkine (slow)
2016/10/20 16:47:26
Nit: const
manzagop (departed)
2016/10/20 18:38:37
Done.
| |
588 !clean_exit_beacon_.exited_cleanly() || | |
589 ProvidersHaveInitialStabilityMetrics(); | |
587 bool has_initial_stability_log = false; | 590 bool has_initial_stability_log = false; |
588 bool providers_have_initial_stability_metrics = | 591 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 | 592 // TODO(rtenneti): On windows, consider saving/getting execution_phase from |
593 // the registry. | 593 // the registry. |
594 int execution_phase = | 594 int execution_phase = |
595 local_state_->GetInteger(prefs::kStabilityExecutionPhase); | 595 local_state_->GetInteger(prefs::kStabilityExecutionPhase); |
596 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", | 596 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", |
597 execution_phase); | 597 execution_phase); |
598 | 598 |
599 // If the previous session didn't exit cleanly, or if any provider | 599 // If the previous session didn't exit cleanly, or if any provider |
600 // explicitly requests it, prepare an initial stability log - | 600 // explicitly requests it, prepare an initial stability log - |
601 // provided UMA is enabled. | 601 // provided UMA is enabled. |
602 if (state_manager_->IsMetricsReportingEnabled()) { | 602 if (state_manager_->IsMetricsReportingEnabled()) { |
603 has_initial_stability_log = PrepareInitialStabilityLog(previous_version); | 603 has_initial_stability_log = PrepareInitialStabilityLog(previous_version); |
604 if (!has_initial_stability_log) | 604 if (!has_initial_stability_log) |
605 IncrementPrefValue(prefs::kStabilityDeferredCount); | 605 IncrementPrefValue(prefs::kStabilityDeferredCount); |
606 } | 606 } |
607 } | 607 } |
608 | 608 |
609 // If no initial stability log was generated and there was a version upgrade, | 609 // 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 | 610 // 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 | 611 // 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 | 612 // 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 | 613 // it could save off a system profile or if UMA reporting is disabled (which |
614 // normally results in stats being accumulated). | 614 // normally results in stats being accumulated). |
615 if (!has_initial_stability_log && version_changed) { | 615 if (version_changed && !has_initial_stability_log) { |
616 ClearSavedStabilityMetrics(); | 616 ClearSavedStabilityMetrics(); |
617 IncrementPrefValue(prefs::kStabilityDiscardCount); | 617 IncrementPrefValue(prefs::kStabilityDiscardCount); |
618 } | 618 } |
619 | 619 |
620 // If the version changed, the system profile is obsolete and needs to be | |
621 // cleared. | |
Alexei Svitkine (slow)
2016/10/20 16:47:26
I think I do agree with this logic, but the commen
manzagop (departed)
2016/10/20 18:38:37
Done.
| |
622 if (version_changed) { | |
623 local_state->ClearPref(prefs::kStabilitySavedSystemProfile); | |
624 local_state->ClearPref(prefs::kStabilitySavedSystemProfileHash); | |
625 } | |
626 | |
620 // Update session ID. | 627 // Update session ID. |
621 ++session_id_; | 628 ++session_id_; |
622 local_state_->SetInteger(prefs::kMetricsSessionID, session_id_); | 629 local_state_->SetInteger(prefs::kMetricsSessionID, session_id_); |
623 | 630 |
624 // Stability bookkeeping | 631 // Stability bookkeeping |
625 IncrementPrefValue(prefs::kStabilityLaunchCount); | 632 IncrementPrefValue(prefs::kStabilityLaunchCount); |
626 | 633 |
627 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); | 634 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); |
628 SetExecutionPhase(START_METRICS_RECORDING, local_state_); | 635 SetExecutionPhase(START_METRICS_RECORDING, local_state_); |
629 | 636 |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1208 base::Time::Now().ToTimeT()); | 1215 base::Time::Now().ToTimeT()); |
1209 } | 1216 } |
1210 | 1217 |
1211 void MetricsService::SkipAndDiscardUpload() { | 1218 void MetricsService::SkipAndDiscardUpload() { |
1212 log_manager_.DiscardStagedLog(); | 1219 log_manager_.DiscardStagedLog(); |
1213 scheduler_->UploadCancelled(); | 1220 scheduler_->UploadCancelled(); |
1214 log_upload_in_progress_ = false; | 1221 log_upload_in_progress_ = false; |
1215 } | 1222 } |
1216 | 1223 |
1217 } // namespace metrics | 1224 } // namespace metrics |
OLD | NEW |