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

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

Issue 103943006: Let MetricsService know about some Android Activities (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding more activities, addressing comments Created 6 years, 12 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 | Annotate | Revision Log
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();
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 static_cast<MetricsLog*>(log_manager_.current_log()); 1281 static_cast<MetricsLog*>(log_manager_.current_log());
1270 DCHECK(current_log); 1282 DCHECK(current_log);
1271 std::vector<chrome_variations::ActiveGroupId> synthetic_trials; 1283 std::vector<chrome_variations::ActiveGroupId> synthetic_trials;
1272 GetCurrentSyntheticFieldTrials(&synthetic_trials); 1284 GetCurrentSyntheticFieldTrials(&synthetic_trials);
1273 current_log->RecordEnvironment(plugins_, google_update_metrics_, 1285 current_log->RecordEnvironment(plugins_, google_update_metrics_,
1274 synthetic_trials); 1286 synthetic_trials);
1275 PrefService* pref = g_browser_process->local_state(); 1287 PrefService* pref = g_browser_process->local_state();
1276 current_log->RecordStabilityMetrics(GetIncrementalUptime(pref), 1288 current_log->RecordStabilityMetrics(GetIncrementalUptime(pref),
1277 MetricsLog::ONGOING_LOG); 1289 MetricsLog::ONGOING_LOG);
1278 1290
1291 #if defined(OS_ANDROID)
1292 RecordAndroidStabilityHistograms();
1293 #endif // defined(OS_ANDROID)
1279 RecordCurrentHistograms(); 1294 RecordCurrentHistograms();
1280 1295
1281 log_manager_.FinishCurrentLog(); 1296 log_manager_.FinishCurrentLog();
1282 } 1297 }
1283 1298
1284 void MetricsService::PushPendingLogsToPersistentStorage() { 1299 void MetricsService::PushPendingLogsToPersistentStorage() {
1285 if (state_ < SENDING_INITIAL_STABILITY_LOG) 1300 if (state_ < SENDING_INITIAL_STABILITY_LOG)
1286 return; // We didn't and still don't have time to get plugin list etc. 1301 return; // We didn't and still don't have time to get plugin list etc.
1287 1302
1288 if (log_manager_.has_staged_log()) { 1303 if (log_manager_.has_staged_log()) {
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 if (local_state) { 2033 if (local_state) {
2019 const PrefService::Preference* uma_pref = 2034 const PrefService::Preference* uma_pref =
2020 local_state->FindPreference(prefs::kMetricsReportingEnabled); 2035 local_state->FindPreference(prefs::kMetricsReportingEnabled);
2021 if (uma_pref) { 2036 if (uma_pref) {
2022 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 2037 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
2023 DCHECK(success); 2038 DCHECK(success);
2024 } 2039 }
2025 } 2040 }
2026 return result; 2041 return result;
2027 } 2042 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698