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

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

Issue 137623002: Let MetricsService know about some Android Activities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert 0 to Histogram::kNoFlags Created 6 years, 11 months 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
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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 registry->RegisterListPref(prefs::kMetricsInitialLogs); 478 registry->RegisterListPref(prefs::kMetricsInitialLogs);
479 registry->RegisterListPref(prefs::kMetricsOngoingLogs); 479 registry->RegisterListPref(prefs::kMetricsOngoingLogs);
480 480
481 registry->RegisterInt64Pref(prefs::kInstallDate, 0); 481 registry->RegisterInt64Pref(prefs::kInstallDate, 0);
482 registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0); 482 registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0);
483 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); 483 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0);
484 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); 484 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0);
485 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); 485 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0);
486 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); 486 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0);
487
488 #if defined(OS_ANDROID)
489 RegisterPrefsAndroid(registry);
490 #endif // defined(OS_ANDROID)
487 } 491 }
488 492
489 // static 493 // static
490 void MetricsService::DiscardOldStabilityStats(PrefService* local_state) { 494 void MetricsService::DiscardOldStabilityStats(PrefService* local_state) {
491 local_state->SetBoolean(prefs::kStabilityExitedCleanly, true); 495 local_state->SetBoolean(prefs::kStabilityExitedCleanly, true);
492 local_state->SetInteger(prefs::kStabilityExecutionPhase, UNINITIALIZED_PHASE); 496 local_state->SetInteger(prefs::kStabilityExecutionPhase, UNINITIALIZED_PHASE);
493 local_state->SetBoolean(prefs::kStabilitySessionEndCompleted, true); 497 local_state->SetBoolean(prefs::kStabilitySessionEndCompleted, true);
494 498
495 local_state->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); 499 local_state->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
496 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); 500 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0);
497 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); 501 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0);
498 local_state->SetInteger(prefs::kStabilityDebuggerPresent, 0); 502 local_state->SetInteger(prefs::kStabilityDebuggerPresent, 0);
499 local_state->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); 503 local_state->SetInteger(prefs::kStabilityDebuggerNotPresent, 0);
500 504
501 local_state->SetInteger(prefs::kStabilityLaunchCount, 0); 505 local_state->SetInteger(prefs::kStabilityLaunchCount, 0);
502 local_state->SetInteger(prefs::kStabilityCrashCount, 0); 506 local_state->SetInteger(prefs::kStabilityCrashCount, 0);
503 507
504 local_state->SetInteger(prefs::kStabilityPageLoadCount, 0); 508 local_state->SetInteger(prefs::kStabilityPageLoadCount, 0);
505 local_state->SetInteger(prefs::kStabilityRendererCrashCount, 0); 509 local_state->SetInteger(prefs::kStabilityRendererCrashCount, 0);
506 local_state->SetInteger(prefs::kStabilityRendererHangCount, 0); 510 local_state->SetInteger(prefs::kStabilityRendererHangCount, 0);
507 511
508 local_state->SetInt64(prefs::kStabilityLaunchTimeSec, 0); 512 local_state->SetInt64(prefs::kStabilityLaunchTimeSec, 0);
509 local_state->SetInt64(prefs::kStabilityLastTimestampSec, 0); 513 local_state->SetInt64(prefs::kStabilityLastTimestampSec, 0);
510 514
511 local_state->ClearPref(prefs::kStabilityPluginStats); 515 local_state->ClearPref(prefs::kStabilityPluginStats);
512 516
513 local_state->ClearPref(prefs::kMetricsInitialLogs); 517 local_state->ClearPref(prefs::kMetricsInitialLogs);
514 local_state->ClearPref(prefs::kMetricsOngoingLogs); 518 local_state->ClearPref(prefs::kMetricsOngoingLogs);
519
520 #if defined(OS_ANDROID)
521 DiscardOldStabilityStatsAndroid(local_state);
522 #endif // defined(OS_ANDROID)
515 } 523 }
516 524
517 MetricsService::MetricsService() 525 MetricsService::MetricsService()
518 : recording_active_(false), 526 : recording_active_(false),
519 reporting_active_(false), 527 reporting_active_(false),
520 test_mode_active_(false), 528 test_mode_active_(false),
521 state_(INITIALIZED), 529 state_(INITIALIZED),
522 has_initial_stability_log_(false), 530 has_initial_stability_log_(false),
523 low_entropy_source_(kLowEntropySourceNotSet), 531 low_entropy_source_(kLowEntropySourceNotSet),
524 idle_since_last_transmission_(false), 532 idle_since_last_transmission_(false),
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 // old version with info that we upload. 949 // old version with info that we upload.
942 DiscardOldStabilityStats(pref); 950 DiscardOldStabilityStats(pref);
943 pref->SetString(prefs::kStabilityStatsVersion, 951 pref->SetString(prefs::kStabilityStatsVersion,
944 MetricsLog::GetVersionString()); 952 MetricsLog::GetVersionString());
945 pref->SetInt64(prefs::kStabilityStatsBuildTime, 953 pref->SetInt64(prefs::kStabilityStatsBuildTime,
946 MetricsLog::GetBuildTime()); 954 MetricsLog::GetBuildTime());
947 } 955 }
948 956
949 session_id_ = pref->GetInteger(prefs::kMetricsSessionID); 957 session_id_ = pref->GetInteger(prefs::kMetricsSessionID);
950 958
959 #if defined(OS_ANDROID)
960 RecordAndroidStabilityPrefs(pref);
961 #endif // defined(OS_ANDROID)
962
951 if (!pref->GetBoolean(prefs::kStabilityExitedCleanly)) { 963 if (!pref->GetBoolean(prefs::kStabilityExitedCleanly)) {
952 IncrementPrefValue(prefs::kStabilityCrashCount); 964 IncrementPrefValue(prefs::kStabilityCrashCount);
953 // Reset flag, and wait until we call LogNeedForCleanShutdown() before 965 // Reset flag, and wait until we call LogNeedForCleanShutdown() before
954 // monitoring. 966 // monitoring.
955 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); 967 pref->SetBoolean(prefs::kStabilityExitedCleanly, true);
956 968
957 // TODO(rtenneti): On windows, consider saving/getting execution_phase from 969 // TODO(rtenneti): On windows, consider saving/getting execution_phase from
958 // the registry. 970 // the registry.
959 int execution_phase = pref->GetInteger(prefs::kStabilityExecutionPhase); 971 int execution_phase = pref->GetInteger(prefs::kStabilityExecutionPhase);
960 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", 972 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase",
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 new MetricsLog(client_id_, session_id_)); 1541 new MetricsLog(client_id_, session_id_));
1530 if (!initial_stability_log->LoadSavedEnvironmentFromPrefs()) 1542 if (!initial_stability_log->LoadSavedEnvironmentFromPrefs())
1531 return; 1543 return;
1532 initial_stability_log->RecordStabilityMetrics(base::TimeDelta(), 1544 initial_stability_log->RecordStabilityMetrics(base::TimeDelta(),
1533 MetricsLog::INITIAL_LOG); 1545 MetricsLog::INITIAL_LOG);
1534 log_manager_.LoadPersistedUnsentLogs(); 1546 log_manager_.LoadPersistedUnsentLogs();
1535 1547
1536 log_manager_.PauseCurrentLog(); 1548 log_manager_.PauseCurrentLog();
1537 log_manager_.BeginLoggingWithLog(initial_stability_log.release(), 1549 log_manager_.BeginLoggingWithLog(initial_stability_log.release(),
1538 MetricsLog::INITIAL_LOG); 1550 MetricsLog::INITIAL_LOG);
1551 #if defined(OS_ANDROID)
1552 RecordAndroidStabilityHistograms(pref);
1553 RecordCurrentStabilityHistograms();
Alexei Svitkine (slow) 2014/01/22 21:14:19 The naming of these two functions is confusing. On
Kibeom Kim (inactive) 2014/01/24 19:45:09 Done.
1554 #endif // defined(OS_ANDROID)
1539 log_manager_.FinishCurrentLog(); 1555 log_manager_.FinishCurrentLog();
1540 log_manager_.ResumePausedLog(); 1556 log_manager_.ResumePausedLog();
1541 1557
1542 // Store unsent logs, including the stability log that was just saved, so 1558 // Store unsent logs, including the stability log that was just saved, so
1543 // that they're not lost in case of a crash before upload time. 1559 // that they're not lost in case of a crash before upload time.
1544 log_manager_.PersistUnsentLogs(); 1560 log_manager_.PersistUnsentLogs();
1545 1561
1546 has_initial_stability_log_ = true; 1562 has_initial_stability_log_ = true;
1547 } 1563 }
1548 1564
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 // We need to save the prefs, as page load count is a critical stat, and it 1772 // We need to save the prefs, as page load count is a critical stat, and it
1757 // might be lost due to a crash :-(. 1773 // might be lost due to a crash :-(.
1758 } 1774 }
1759 1775
1760 void MetricsService::LogRendererCrash(content::RenderProcessHost* host, 1776 void MetricsService::LogRendererCrash(content::RenderProcessHost* host,
1761 base::TerminationStatus status, 1777 base::TerminationStatus status,
1762 int exit_code) { 1778 int exit_code) {
1763 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); 1779 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
1764 ExtensionService* service = profile->GetExtensionService(); 1780 ExtensionService* service = profile->GetExtensionService();
1765 bool was_extension_process = 1781 bool was_extension_process =
1766 service && service->process_map()->Contains(host->GetID()); 1782 service && service->process_map()->Contains(host->GetID());
Kibeom Kim (inactive) 2014/01/24 19:45:09 these lines changes are just rebase.
1767 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || 1783 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED ||
1768 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { 1784 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) {
1769 if (was_extension_process) { 1785 if (was_extension_process) {
1770 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); 1786 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount);
1771 1787
1772 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Extension", 1788 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Extension",
1773 MapCrashExitCodeForHistogram(exit_code)); 1789 MapCrashExitCodeForHistogram(exit_code));
1774 } else { 1790 } else {
1775 IncrementPrefValue(prefs::kStabilityRendererCrashCount); 1791 IncrementPrefValue(prefs::kStabilityRendererCrashCount);
1776 1792
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 if (local_state) { 2035 if (local_state) {
2020 const PrefService::Preference* uma_pref = 2036 const PrefService::Preference* uma_pref =
2021 local_state->FindPreference(prefs::kMetricsReportingEnabled); 2037 local_state->FindPreference(prefs::kMetricsReportingEnabled);
2022 if (uma_pref) { 2038 if (uma_pref) {
2023 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 2039 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
2024 DCHECK(success); 2040 DCHECK(success);
2025 } 2041 }
2026 } 2042 }
2027 return result; 2043 return result;
2028 } 2044 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698