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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 if (exit_code == STATUS_GUARD_PAGE_VIOLATION) | 318 if (exit_code == STATUS_GUARD_PAGE_VIOLATION) |
319 return 0x1FCF7EC3; // Randomly picked number. | 319 return 0x1FCF7EC3; // Randomly picked number. |
320 #endif | 320 #endif |
321 | 321 |
322 return std::abs(exit_code); | 322 return std::abs(exit_code); |
323 } | 323 } |
324 | 324 |
325 void MarkAppCleanShutdownAndCommit() { | 325 void MarkAppCleanShutdownAndCommit() { |
326 PrefService* pref = g_browser_process->local_state(); | 326 PrefService* pref = g_browser_process->local_state(); |
327 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); | 327 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); |
328 pref->SetInteger(prefs::kStabilityExecutionPhase, | |
329 MetricsService::CLEAN_SHUTDOWN); | |
328 // Start writing right away (write happens on a different thread). | 330 // Start writing right away (write happens on a different thread). |
329 pref->CommitPendingWrite(); | 331 pref->CommitPendingWrite(); |
330 } | 332 } |
331 | 333 |
332 } // namespace | 334 } // namespace |
333 | 335 |
334 // static | 336 // static |
335 MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = | 337 MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = |
336 MetricsService::CLEANLY_SHUTDOWN; | 338 MetricsService::CLEANLY_SHUTDOWN; |
337 | 339 |
340 MetricsService::ExecutionPhase MetricsService::execution_phase_ = | |
341 MetricsService::CLEAN_SHUTDOWN; | |
342 | |
338 // This is used to quickly log stats from child process related notifications in | 343 // This is used to quickly log stats from child process related notifications in |
339 // MetricsService::child_stats_buffer_. The buffer's contents are transferred | 344 // MetricsService::child_stats_buffer_. The buffer's contents are transferred |
340 // out when Local State is periodically saved. The information is then | 345 // out when Local State is periodically saved. The information is then |
341 // reported to the UMA server on next launch. | 346 // reported to the UMA server on next launch. |
342 struct MetricsService::ChildProcessStats { | 347 struct MetricsService::ChildProcessStats { |
343 public: | 348 public: |
344 explicit ChildProcessStats(int process_type) | 349 explicit ChildProcessStats(int process_type) |
345 : process_launches(0), | 350 : process_launches(0), |
346 process_crashes(0), | 351 process_crashes(0), |
347 instances(0), | 352 instances(0), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 DCHECK(IsSingleThreaded()); | 403 DCHECK(IsSingleThreaded()); |
399 registry->RegisterStringPref(prefs::kMetricsClientID, std::string()); | 404 registry->RegisterStringPref(prefs::kMetricsClientID, std::string()); |
400 registry->RegisterIntegerPref(prefs::kMetricsLowEntropySource, | 405 registry->RegisterIntegerPref(prefs::kMetricsLowEntropySource, |
401 kLowEntropySourceNotSet); | 406 kLowEntropySourceNotSet); |
402 registry->RegisterInt64Pref(prefs::kMetricsClientIDTimestamp, 0); | 407 registry->RegisterInt64Pref(prefs::kMetricsClientIDTimestamp, 0); |
403 registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); | 408 registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); |
404 registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); | 409 registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); |
405 registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); | 410 registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); |
406 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); | 411 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); |
407 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 412 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
413 registry->RegisterIntegerPref(prefs::kStabilityExecutionPhase, | |
414 CLEAN_SHUTDOWN); | |
408 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); | 415 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); |
409 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); | 416 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); |
410 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 417 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
411 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); | 418 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); |
412 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); | 419 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); |
413 registry->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); | 420 registry->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); |
414 registry->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); | 421 registry->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); |
415 registry->RegisterIntegerPref(prefs::kStabilityExtensionRendererCrashCount, | 422 registry->RegisterIntegerPref(prefs::kStabilityExtensionRendererCrashCount, |
416 0); | 423 0); |
417 registry->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); | 424 registry->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); |
(...skipping 16 matching lines...) Expand all Loading... | |
434 registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0); | 441 registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0); |
435 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); | 442 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); |
436 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); | 443 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); |
437 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); | 444 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); |
438 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); | 445 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); |
439 } | 446 } |
440 | 447 |
441 // static | 448 // static |
442 void MetricsService::DiscardOldStabilityStats(PrefService* local_state) { | 449 void MetricsService::DiscardOldStabilityStats(PrefService* local_state) { |
443 local_state->SetBoolean(prefs::kStabilityExitedCleanly, true); | 450 local_state->SetBoolean(prefs::kStabilityExitedCleanly, true); |
451 local_state->SetInteger(prefs::kStabilityExecutionPhase, CLEAN_SHUTDOWN); | |
444 local_state->SetBoolean(prefs::kStabilitySessionEndCompleted, true); | 452 local_state->SetBoolean(prefs::kStabilitySessionEndCompleted, true); |
445 | 453 |
446 local_state->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); | 454 local_state->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); |
447 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); | 455 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); |
448 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); | 456 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); |
449 local_state->SetInteger(prefs::kStabilityDebuggerPresent, 0); | 457 local_state->SetInteger(prefs::kStabilityDebuggerPresent, 0); |
450 local_state->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); | 458 local_state->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); |
451 | 459 |
452 local_state->SetInteger(prefs::kStabilityLaunchCount, 0); | 460 local_state->SetInteger(prefs::kStabilityLaunchCount, 0); |
453 local_state->SetInteger(prefs::kStabilityCrashCount, 0); | 461 local_state->SetInteger(prefs::kStabilityCrashCount, 0); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
761 // Persisting logs closes the current log, so start recording a new log | 769 // Persisting logs closes the current log, so start recording a new log |
762 // immediately to capture any background work that might be done before the | 770 // immediately to capture any background work that might be done before the |
763 // process is killed. | 771 // process is killed. |
764 OpenNewLog(); | 772 OpenNewLog(); |
765 } | 773 } |
766 } | 774 } |
767 | 775 |
768 void MetricsService::OnAppEnterForeground() { | 776 void MetricsService::OnAppEnterForeground() { |
769 PrefService* pref = g_browser_process->local_state(); | 777 PrefService* pref = g_browser_process->local_state(); |
770 pref->SetBoolean(prefs::kStabilityExitedCleanly, false); | 778 pref->SetBoolean(prefs::kStabilityExitedCleanly, false); |
779 pref->SetInteger(prefs::kStabilityExecutionPhase, execution_phase_); | |
771 | 780 |
772 StartSchedulerIfNecessary(); | 781 StartSchedulerIfNecessary(); |
773 } | 782 } |
774 #else | 783 #else |
775 void MetricsService::LogNeedForCleanShutdown() { | 784 void MetricsService::LogNeedForCleanShutdown() { |
776 PrefService* pref = g_browser_process->local_state(); | 785 PrefService* pref = g_browser_process->local_state(); |
777 pref->SetBoolean(prefs::kStabilityExitedCleanly, false); | 786 pref->SetBoolean(prefs::kStabilityExitedCleanly, false); |
787 pref->SetInteger(prefs::kStabilityExecutionPhase, execution_phase_); | |
778 // Redundant setting to be sure we call for a clean shutdown. | 788 // Redundant setting to be sure we call for a clean shutdown. |
779 clean_shutdown_status_ = NEED_TO_SHUTDOWN; | 789 clean_shutdown_status_ = NEED_TO_SHUTDOWN; |
780 } | 790 } |
781 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 791 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
782 | 792 |
783 void MetricsService::RecordBreakpadRegistration(bool success) { | 793 void MetricsService::RecordBreakpadRegistration(bool success) { |
784 if (!success) | 794 if (!success) |
785 IncrementPrefValue(prefs::kStabilityBreakpadRegistrationFail); | 795 IncrementPrefValue(prefs::kStabilityBreakpadRegistrationFail); |
786 else | 796 else |
787 IncrementPrefValue(prefs::kStabilityBreakpadRegistrationSuccess); | 797 IncrementPrefValue(prefs::kStabilityBreakpadRegistrationSuccess); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 // Stability bookkeeping | 898 // Stability bookkeeping |
889 IncrementPrefValue(prefs::kStabilityLaunchCount); | 899 IncrementPrefValue(prefs::kStabilityLaunchCount); |
890 | 900 |
891 if (!pref->GetBoolean(prefs::kStabilityExitedCleanly)) { | 901 if (!pref->GetBoolean(prefs::kStabilityExitedCleanly)) { |
892 IncrementPrefValue(prefs::kStabilityCrashCount); | 902 IncrementPrefValue(prefs::kStabilityCrashCount); |
893 // Reset flag, and wait until we call LogNeedForCleanShutdown() before | 903 // Reset flag, and wait until we call LogNeedForCleanShutdown() before |
894 // monitoring. | 904 // monitoring. |
895 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); | 905 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); |
896 } | 906 } |
897 | 907 |
908 // TODO(rtenneti): On windows, consider saving/getting execution_phase from | |
909 // the registry. | |
910 int execution_phase = pref->GetInteger(prefs::kStabilityExecutionPhase); | |
911 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.ExecutionPhase", execution_phase); | |
912 pref->SetInteger(prefs::kStabilityExecutionPhase, CLEAN_SHUTDOWN); | |
jar (doing other things)
2013/10/26 02:09:21
Perhaps this block from lines 908 to 912 should be
ramant (doing other things)
2013/10/26 03:29:35
Done.
| |
913 | |
898 #if defined(OS_WIN) | 914 #if defined(OS_WIN) |
899 CountBrowserCrashDumpAttempts(); | 915 CountBrowserCrashDumpAttempts(); |
900 #endif // defined(OS_WIN) | 916 #endif // defined(OS_WIN) |
901 | 917 |
902 if (!pref->GetBoolean(prefs::kStabilitySessionEndCompleted)) { | 918 if (!pref->GetBoolean(prefs::kStabilitySessionEndCompleted)) { |
903 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); | 919 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); |
904 // This is marked false when we get a WM_ENDSESSION. | 920 // This is marked false when we get a WM_ENDSESSION. |
905 pref->SetBoolean(prefs::kStabilitySessionEndCompleted, true); | 921 pref->SetBoolean(prefs::kStabilitySessionEndCompleted, true); |
906 } | 922 } |
907 | 923 |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1628 | 1644 |
1629 void MetricsService::LogCleanShutdown() { | 1645 void MetricsService::LogCleanShutdown() { |
1630 // Redundant hack to write pref ASAP. | 1646 // Redundant hack to write pref ASAP. |
1631 MarkAppCleanShutdownAndCommit(); | 1647 MarkAppCleanShutdownAndCommit(); |
1632 | 1648 |
1633 // Redundant setting to assure that we always reset this value at shutdown | 1649 // Redundant setting to assure that we always reset this value at shutdown |
1634 // (and that we don't use some alternate path, and not call LogCleanShutdown). | 1650 // (and that we don't use some alternate path, and not call LogCleanShutdown). |
1635 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | 1651 clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
1636 | 1652 |
1637 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); | 1653 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); |
1654 PrefService* pref = g_browser_process->local_state(); | |
1655 pref->SetInteger(prefs::kStabilityExecutionPhase, | |
1656 MetricsService::CLEAN_SHUTDOWN); | |
1638 } | 1657 } |
1639 | 1658 |
1640 #if defined(OS_CHROMEOS) | 1659 #if defined(OS_CHROMEOS) |
1641 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { | 1660 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { |
1642 if (crash_type == "user") | 1661 if (crash_type == "user") |
1643 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount); | 1662 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount); |
1644 else if (crash_type == "kernel") | 1663 else if (crash_type == "kernel") |
1645 IncrementPrefValue(prefs::kStabilityKernelCrashCount); | 1664 IncrementPrefValue(prefs::kStabilityKernelCrashCount); |
1646 else if (crash_type == "uncleanshutdown") | 1665 else if (crash_type == "uncleanshutdown") |
1647 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount); | 1666 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1813 if (local_state) { | 1832 if (local_state) { |
1814 const PrefService::Preference* uma_pref = | 1833 const PrefService::Preference* uma_pref = |
1815 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1834 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1816 if (uma_pref) { | 1835 if (uma_pref) { |
1817 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1836 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1818 DCHECK(success); | 1837 DCHECK(success); |
1819 } | 1838 } |
1820 } | 1839 } |
1821 return result; | 1840 return result; |
1822 } | 1841 } |
OLD | NEW |