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 | 10 // A MetricsService instance is typically created at application startup. It |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 #include "chrome/browser/extensions/extension_service.h" | 171 #include "chrome/browser/extensions/extension_service.h" |
172 #include "chrome/browser/extensions/process_map.h" | 172 #include "chrome/browser/extensions/process_map.h" |
173 #include "chrome/browser/io_thread.h" | 173 #include "chrome/browser/io_thread.h" |
174 #include "chrome/browser/memory_details.h" | 174 #include "chrome/browser/memory_details.h" |
175 #include "chrome/browser/metrics/metrics_log.h" | 175 #include "chrome/browser/metrics/metrics_log.h" |
176 #include "chrome/browser/metrics/metrics_log_serializer.h" | 176 #include "chrome/browser/metrics/metrics_log_serializer.h" |
177 #include "chrome/browser/metrics/metrics_reporting_scheduler.h" | 177 #include "chrome/browser/metrics/metrics_reporting_scheduler.h" |
178 #include "chrome/browser/metrics/tracking_synchronizer.h" | 178 #include "chrome/browser/metrics/tracking_synchronizer.h" |
179 #include "chrome/browser/net/http_pipelining_compatibility_client.h" | 179 #include "chrome/browser/net/http_pipelining_compatibility_client.h" |
180 #include "chrome/browser/net/network_stats.h" | 180 #include "chrome/browser/net/network_stats.h" |
| 181 #include "chrome/browser/prefs/pref_registry_simple.h" |
181 #include "chrome/browser/prefs/pref_service.h" | 182 #include "chrome/browser/prefs/pref_service.h" |
182 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 183 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
183 #include "chrome/browser/profiles/profile.h" | 184 #include "chrome/browser/profiles/profile.h" |
184 #include "chrome/browser/search_engines/template_url_service.h" | 185 #include "chrome/browser/search_engines/template_url_service.h" |
185 #include "chrome/browser/ui/browser_list.h" | 186 #include "chrome/browser/ui/browser_list.h" |
186 #include "chrome/browser/ui/browser_otr_state.h" | 187 #include "chrome/browser/ui/browser_otr_state.h" |
187 #include "chrome/common/child_process_logging.h" | 188 #include "chrome/common/child_process_logging.h" |
188 #include "chrome/common/chrome_notification_types.h" | 189 #include "chrome/common/chrome_notification_types.h" |
189 #include "chrome/common/chrome_result_codes.h" | 190 #include "chrome/common/chrome_result_codes.h" |
190 #include "chrome/common/chrome_switches.h" | 191 #include "chrome/common/chrome_switches.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 } | 428 } |
428 | 429 |
429 private: | 430 private: |
430 ~MetricsMemoryDetails() {} | 431 ~MetricsMemoryDetails() {} |
431 | 432 |
432 base::Closure callback_; | 433 base::Closure callback_; |
433 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetails); | 434 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetails); |
434 }; | 435 }; |
435 | 436 |
436 // static | 437 // static |
437 void MetricsService::RegisterPrefs(PrefServiceSimple* local_state) { | 438 void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { |
438 DCHECK(IsSingleThreaded()); | 439 DCHECK(IsSingleThreaded()); |
439 local_state->RegisterStringPref(prefs::kMetricsClientID, ""); | 440 registry->RegisterStringPref(prefs::kMetricsClientID, ""); |
440 local_state->RegisterIntegerPref(prefs::kMetricsLowEntropySource, | 441 registry->RegisterIntegerPref(prefs::kMetricsLowEntropySource, |
441 kLowEntropySourceNotSet); | 442 kLowEntropySourceNotSet); |
442 local_state->RegisterInt64Pref(prefs::kMetricsClientIDTimestamp, 0); | 443 registry->RegisterInt64Pref(prefs::kMetricsClientIDTimestamp, 0); |
443 local_state->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); | 444 registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); |
444 local_state->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); | 445 registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); |
445 local_state->RegisterStringPref(prefs::kStabilityStatsVersion, ""); | 446 registry->RegisterStringPref(prefs::kStabilityStatsVersion, ""); |
446 local_state->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); | 447 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); |
447 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 448 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
448 local_state->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); | 449 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); |
449 local_state->RegisterIntegerPref(prefs::kMetricsSessionID, -1); | 450 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); |
450 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 451 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
451 local_state->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); | 452 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); |
452 local_state->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, | 453 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); |
453 0); | 454 registry->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); |
454 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); | 455 registry->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); |
455 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); | 456 registry->RegisterIntegerPref(prefs::kStabilityExtensionRendererCrashCount, |
456 local_state->RegisterIntegerPref(prefs::kStabilityExtensionRendererCrashCount, | 457 0); |
457 0); | 458 registry->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); |
458 local_state->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); | 459 registry->RegisterIntegerPref(prefs::kStabilityChildProcessCrashCount, 0); |
459 local_state->RegisterIntegerPref(prefs::kStabilityChildProcessCrashCount, 0); | 460 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0); |
460 local_state->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, | 461 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess, |
461 0); | 462 0); |
462 local_state->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess, | 463 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); |
463 0); | 464 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); |
464 local_state->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); | |
465 local_state->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); | |
466 #if defined(OS_CHROMEOS) | 465 #if defined(OS_CHROMEOS) |
467 local_state->RegisterIntegerPref(prefs::kStabilityOtherUserCrashCount, 0); | 466 registry->RegisterIntegerPref(prefs::kStabilityOtherUserCrashCount, 0); |
468 local_state->RegisterIntegerPref(prefs::kStabilityKernelCrashCount, 0); | 467 registry->RegisterIntegerPref(prefs::kStabilityKernelCrashCount, 0); |
469 local_state->RegisterIntegerPref(prefs::kStabilitySystemUncleanShutdownCount, | 468 registry->RegisterIntegerPref(prefs::kStabilitySystemUncleanShutdownCount, 0); |
470 0); | |
471 #endif // OS_CHROMEOS | 469 #endif // OS_CHROMEOS |
472 | 470 |
473 local_state->RegisterDictionaryPref(prefs::kProfileMetrics); | 471 registry->RegisterDictionaryPref(prefs::kProfileMetrics); |
474 local_state->RegisterIntegerPref(prefs::kNumKeywords, 0); | 472 registry->RegisterIntegerPref(prefs::kNumKeywords, 0); |
475 local_state->RegisterListPref(prefs::kMetricsInitialLogsXml); | 473 registry->RegisterListPref(prefs::kMetricsInitialLogsXml); |
476 local_state->RegisterListPref(prefs::kMetricsOngoingLogsXml); | 474 registry->RegisterListPref(prefs::kMetricsOngoingLogsXml); |
477 local_state->RegisterListPref(prefs::kMetricsInitialLogsProto); | 475 registry->RegisterListPref(prefs::kMetricsInitialLogsProto); |
478 local_state->RegisterListPref(prefs::kMetricsOngoingLogsProto); | 476 registry->RegisterListPref(prefs::kMetricsOngoingLogsProto); |
479 | 477 |
480 local_state->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0); | 478 registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0); |
481 local_state->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); | 479 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); |
482 local_state->RegisterInt64Pref(prefs::kUninstallMetricsInstallDate, 0); | 480 registry->RegisterInt64Pref(prefs::kUninstallMetricsInstallDate, 0); |
483 local_state->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); | 481 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); |
484 local_state->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); | 482 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); |
485 local_state->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); | 483 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); |
486 } | 484 } |
487 | 485 |
488 // static | 486 // static |
489 void MetricsService::DiscardOldStabilityStats(PrefService* local_state) { | 487 void MetricsService::DiscardOldStabilityStats(PrefService* local_state) { |
490 local_state->SetBoolean(prefs::kStabilityExitedCleanly, true); | 488 local_state->SetBoolean(prefs::kStabilityExitedCleanly, true); |
491 local_state->SetBoolean(prefs::kStabilitySessionEndCompleted, true); | 489 local_state->SetBoolean(prefs::kStabilitySessionEndCompleted, true); |
492 | 490 |
493 local_state->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); | 491 local_state->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); |
494 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); | 492 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); |
495 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); | 493 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); |
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 if (local_state) { | 1940 if (local_state) { |
1943 const PrefService::Preference* uma_pref = | 1941 const PrefService::Preference* uma_pref = |
1944 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1942 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1945 if (uma_pref) { | 1943 if (uma_pref) { |
1946 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1944 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1947 DCHECK(success); | 1945 DCHECK(success); |
1948 } | 1946 } |
1949 } | 1947 } |
1950 return result; | 1948 return result; |
1951 } | 1949 } |
OLD | NEW |