| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 #include "base/threading/thread.h" | 180 #include "base/threading/thread.h" |
| 181 #include "base/threading/thread_restrictions.h" | 181 #include "base/threading/thread_restrictions.h" |
| 182 #include "base/tracked_objects.h" | 182 #include "base/tracked_objects.h" |
| 183 #include "base/values.h" | 183 #include "base/values.h" |
| 184 #include "chrome/browser/browser_process.h" | 184 #include "chrome/browser/browser_process.h" |
| 185 #include "chrome/browser/chrome_notification_types.h" | 185 #include "chrome/browser/chrome_notification_types.h" |
| 186 #include "chrome/browser/io_thread.h" | 186 #include "chrome/browser/io_thread.h" |
| 187 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" | 187 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" |
| 188 #include "chrome/browser/metrics/gpu_metrics_provider.h" | 188 #include "chrome/browser/metrics/gpu_metrics_provider.h" |
| 189 #include "chrome/browser/metrics/metrics_log.h" | 189 #include "chrome/browser/metrics/metrics_log.h" |
| 190 #include "chrome/browser/metrics/metrics_state_manager.h" | |
| 191 #include "chrome/browser/metrics/network_metrics_provider.h" | 190 #include "chrome/browser/metrics/network_metrics_provider.h" |
| 192 #include "chrome/browser/metrics/omnibox_metrics_provider.h" | 191 #include "chrome/browser/metrics/omnibox_metrics_provider.h" |
| 193 #include "chrome/browser/metrics/tracking_synchronizer.h" | 192 #include "chrome/browser/metrics/tracking_synchronizer.h" |
| 194 #include "chrome/common/pref_names.h" | 193 #include "chrome/common/pref_names.h" |
| 195 #include "chrome/common/variations/variations_util.h" | 194 #include "chrome/common/variations/variations_util.h" |
| 196 #include "components/metrics/metrics_log_base.h" | 195 #include "components/metrics/metrics_log_base.h" |
| 197 #include "components/metrics/metrics_log_manager.h" | 196 #include "components/metrics/metrics_log_manager.h" |
| 198 #include "components/metrics/metrics_log_uploader.h" | 197 #include "components/metrics/metrics_log_uploader.h" |
| 199 #include "components/metrics/metrics_pref_names.h" | 198 #include "components/metrics/metrics_pref_names.h" |
| 200 #include "components/metrics/metrics_reporting_scheduler.h" | 199 #include "components/metrics/metrics_reporting_scheduler.h" |
| 201 #include "components/metrics/metrics_service_client.h" | 200 #include "components/metrics/metrics_service_client.h" |
| 201 #include "components/metrics/metrics_state_manager.h" |
| 202 #include "components/variations/entropy_provider.h" | 202 #include "components/variations/entropy_provider.h" |
| 203 | 203 |
| 204 #if defined(ENABLE_PLUGINS) | 204 #if defined(ENABLE_PLUGINS) |
| 205 // TODO(asvitkine): Move this out of MetricsService. | 205 // TODO(asvitkine): Move this out of MetricsService. |
| 206 #include "chrome/browser/metrics/plugin_metrics_provider.h" | 206 #include "chrome/browser/metrics/plugin_metrics_provider.h" |
| 207 #endif | 207 #endif |
| 208 | 208 |
| 209 #if defined(OS_WIN) | 209 #if defined(OS_WIN) |
| 210 #include "chrome/browser/metrics/google_update_metrics_provider_win.h" | 210 #include "chrome/browser/metrics/google_update_metrics_provider_win.h" |
| 211 #endif | 211 #endif |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 metrics::MetricsStateManager::RegisterPrefs(registry); | 311 metrics::MetricsStateManager::RegisterPrefs(registry); |
| 312 | 312 |
| 313 registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); | 313 registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); |
| 314 registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); | 314 registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); |
| 315 registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); | 315 registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); |
| 316 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); | 316 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); |
| 317 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 317 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
| 318 registry->RegisterIntegerPref(prefs::kStabilityExecutionPhase, | 318 registry->RegisterIntegerPref(prefs::kStabilityExecutionPhase, |
| 319 UNINITIALIZED_PHASE); | 319 UNINITIALIZED_PHASE); |
| 320 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); | 320 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); |
| 321 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); | 321 registry->RegisterIntegerPref(metrics::prefs::kMetricsSessionID, -1); |
| 322 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 322 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
| 323 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); | 323 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); |
| 324 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); | 324 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); |
| 325 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0); | 325 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0); |
| 326 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess, | 326 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess, |
| 327 0); | 327 0); |
| 328 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); | 328 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); |
| 329 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); | 329 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); |
| 330 | 330 |
| 331 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile, | 331 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 622 |
| 623 //------------------------------------------------------------------------------ | 623 //------------------------------------------------------------------------------ |
| 624 // Initialization methods | 624 // Initialization methods |
| 625 | 625 |
| 626 void MetricsService::InitializeMetricsState() { | 626 void MetricsService::InitializeMetricsState() { |
| 627 local_state_->SetString(prefs::kStabilityStatsVersion, | 627 local_state_->SetString(prefs::kStabilityStatsVersion, |
| 628 client_->GetVersionString()); | 628 client_->GetVersionString()); |
| 629 local_state_->SetInt64(prefs::kStabilityStatsBuildTime, | 629 local_state_->SetInt64(prefs::kStabilityStatsBuildTime, |
| 630 MetricsLog::GetBuildTime()); | 630 MetricsLog::GetBuildTime()); |
| 631 | 631 |
| 632 session_id_ = local_state_->GetInteger(prefs::kMetricsSessionID); | 632 session_id_ = local_state_->GetInteger(metrics::prefs::kMetricsSessionID); |
| 633 | 633 |
| 634 if (!local_state_->GetBoolean(prefs::kStabilityExitedCleanly)) { | 634 if (!local_state_->GetBoolean(prefs::kStabilityExitedCleanly)) { |
| 635 IncrementPrefValue(prefs::kStabilityCrashCount); | 635 IncrementPrefValue(prefs::kStabilityCrashCount); |
| 636 // Reset flag, and wait until we call LogNeedForCleanShutdown() before | 636 // Reset flag, and wait until we call LogNeedForCleanShutdown() before |
| 637 // monitoring. | 637 // monitoring. |
| 638 local_state_->SetBoolean(prefs::kStabilityExitedCleanly, true); | 638 local_state_->SetBoolean(prefs::kStabilityExitedCleanly, true); |
| 639 | 639 |
| 640 // TODO(rtenneti): On windows, consider saving/getting execution_phase from | 640 // TODO(rtenneti): On windows, consider saving/getting execution_phase from |
| 641 // the registry. | 641 // the registry. |
| 642 int execution_phase = | 642 int execution_phase = |
| 643 local_state_->GetInteger(prefs::kStabilityExecutionPhase); | 643 local_state_->GetInteger(prefs::kStabilityExecutionPhase); |
| 644 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", | 644 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", |
| 645 execution_phase); | 645 execution_phase); |
| 646 | 646 |
| 647 // If the previous session didn't exit cleanly, then prepare an initial | 647 // If the previous session didn't exit cleanly, then prepare an initial |
| 648 // stability log if UMA is enabled. | 648 // stability log if UMA is enabled. |
| 649 if (state_manager_->IsMetricsReportingEnabled()) | 649 if (state_manager_->IsMetricsReportingEnabled()) |
| 650 PrepareInitialStabilityLog(); | 650 PrepareInitialStabilityLog(); |
| 651 } | 651 } |
| 652 | 652 |
| 653 // Update session ID. | 653 // Update session ID. |
| 654 ++session_id_; | 654 ++session_id_; |
| 655 local_state_->SetInteger(prefs::kMetricsSessionID, session_id_); | 655 local_state_->SetInteger(metrics::prefs::kMetricsSessionID, session_id_); |
| 656 | 656 |
| 657 // Stability bookkeeping | 657 // Stability bookkeeping |
| 658 IncrementPrefValue(prefs::kStabilityLaunchCount); | 658 IncrementPrefValue(prefs::kStabilityLaunchCount); |
| 659 | 659 |
| 660 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); | 660 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); |
| 661 SetExecutionPhase(START_METRICS_RECORDING, local_state_); | 661 SetExecutionPhase(START_METRICS_RECORDING, local_state_); |
| 662 | 662 |
| 663 if (!local_state_->GetBoolean(prefs::kStabilitySessionEndCompleted)) { | 663 if (!local_state_->GetBoolean(prefs::kStabilitySessionEndCompleted)) { |
| 664 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); | 664 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); |
| 665 // This is marked false when we get a WM_ENDSESSION. | 665 // This is marked false when we get a WM_ENDSESSION. |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 RecordCurrentState(local_state_); | 1331 RecordCurrentState(local_state_); |
| 1332 } | 1332 } |
| 1333 | 1333 |
| 1334 void MetricsService::RecordCurrentState(PrefService* pref) { | 1334 void MetricsService::RecordCurrentState(PrefService* pref) { |
| 1335 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); | 1335 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); |
| 1336 | 1336 |
| 1337 #if defined(ENABLE_PLUGINS) | 1337 #if defined(ENABLE_PLUGINS) |
| 1338 plugin_metrics_provider_->RecordPluginChanges(); | 1338 plugin_metrics_provider_->RecordPluginChanges(); |
| 1339 #endif | 1339 #endif |
| 1340 } | 1340 } |
| OLD | NEW |