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