Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: chrome/browser/metrics/metrics_service.cc

Issue 28283002: Track execution phase of browser process when we log if the broswer has (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed jar's comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 pref->SetInteger(prefs::kMetricsSessionID, session_id_); 896 pref->SetInteger(prefs::kMetricsSessionID, session_id_);
887 897
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);
906
907 // TODO(rtenneti): On windows, consider saving/getting execution_phase from
908 // the registry.
909 int execution_phase = pref->GetInteger(prefs::kStabilityExecutionPhase);
910 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.ExecutionPhase",
911 execution_phase);
912 pref->SetInteger(prefs::kStabilityExecutionPhase, CLEAN_SHUTDOWN);
896 } 913 }
897 914
898 #if defined(OS_WIN) 915 #if defined(OS_WIN)
899 CountBrowserCrashDumpAttempts(); 916 CountBrowserCrashDumpAttempts();
900 #endif // defined(OS_WIN) 917 #endif // defined(OS_WIN)
901 918
902 if (!pref->GetBoolean(prefs::kStabilitySessionEndCompleted)) { 919 if (!pref->GetBoolean(prefs::kStabilitySessionEndCompleted)) {
903 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); 920 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount);
904 // This is marked false when we get a WM_ENDSESSION. 921 // This is marked false when we get a WM_ENDSESSION.
905 pref->SetBoolean(prefs::kStabilitySessionEndCompleted, true); 922 pref->SetBoolean(prefs::kStabilitySessionEndCompleted, true);
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 1650
1634 void MetricsService::LogCleanShutdown() { 1651 void MetricsService::LogCleanShutdown() {
1635 // Redundant hack to write pref ASAP. 1652 // Redundant hack to write pref ASAP.
1636 MarkAppCleanShutdownAndCommit(); 1653 MarkAppCleanShutdownAndCommit();
1637 1654
1638 // Redundant setting to assure that we always reset this value at shutdown 1655 // Redundant setting to assure that we always reset this value at shutdown
1639 // (and that we don't use some alternate path, and not call LogCleanShutdown). 1656 // (and that we don't use some alternate path, and not call LogCleanShutdown).
1640 clean_shutdown_status_ = CLEANLY_SHUTDOWN; 1657 clean_shutdown_status_ = CLEANLY_SHUTDOWN;
1641 1658
1642 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); 1659 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true);
1660 PrefService* pref = g_browser_process->local_state();
1661 pref->SetInteger(prefs::kStabilityExecutionPhase,
1662 MetricsService::CLEAN_SHUTDOWN);
1643 } 1663 }
1644 1664
1645 #if defined(OS_CHROMEOS) 1665 #if defined(OS_CHROMEOS)
1646 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { 1666 void MetricsService::LogChromeOSCrash(const std::string &crash_type) {
1647 if (crash_type == "user") 1667 if (crash_type == "user")
1648 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount); 1668 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount);
1649 else if (crash_type == "kernel") 1669 else if (crash_type == "kernel")
1650 IncrementPrefValue(prefs::kStabilityKernelCrashCount); 1670 IncrementPrefValue(prefs::kStabilityKernelCrashCount);
1651 else if (crash_type == "uncleanshutdown") 1671 else if (crash_type == "uncleanshutdown")
1652 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount); 1672 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 if (local_state) { 1838 if (local_state) {
1819 const PrefService::Preference* uma_pref = 1839 const PrefService::Preference* uma_pref =
1820 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1840 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1821 if (uma_pref) { 1841 if (uma_pref) {
1822 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1842 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1823 DCHECK(success); 1843 DCHECK(success);
1824 } 1844 }
1825 } 1845 }
1826 return result; 1846 return result;
1827 } 1847 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698