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

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: Copyright Created 7 years 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 459
460 registry->RegisterListPref(prefs::kMetricsInitialLogs); 460 registry->RegisterListPref(prefs::kMetricsInitialLogs);
461 registry->RegisterListPref(prefs::kMetricsOngoingLogs); 461 registry->RegisterListPref(prefs::kMetricsOngoingLogs);
462 462
463 registry->RegisterInt64Pref(prefs::kInstallDate, 0); 463 registry->RegisterInt64Pref(prefs::kInstallDate, 0);
464 registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0); 464 registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0);
465 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); 465 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0);
466 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); 466 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0);
467 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); 467 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0);
468 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); 468 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0);
469
470 #if defined(OS_ANDROID)
471 RegisterPrefsAndroid(registry);
472 #endif // defined(OS_ANDROID)
469 } 473 }
470 474
471 // static 475 // static
472 void MetricsService::DiscardOldStabilityStats(PrefService* local_state) { 476 void MetricsService::DiscardOldStabilityStats(PrefService* local_state) {
473 local_state->SetBoolean(prefs::kStabilityExitedCleanly, true); 477 local_state->SetBoolean(prefs::kStabilityExitedCleanly, true);
474 local_state->SetInteger(prefs::kStabilityExecutionPhase, UNINITIALIZED_PHASE); 478 local_state->SetInteger(prefs::kStabilityExecutionPhase, UNINITIALIZED_PHASE);
475 local_state->SetBoolean(prefs::kStabilitySessionEndCompleted, true); 479 local_state->SetBoolean(prefs::kStabilitySessionEndCompleted, true);
476 480
477 local_state->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); 481 local_state->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
478 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); 482 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0);
479 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); 483 local_state->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0);
480 local_state->SetInteger(prefs::kStabilityDebuggerPresent, 0); 484 local_state->SetInteger(prefs::kStabilityDebuggerPresent, 0);
481 local_state->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); 485 local_state->SetInteger(prefs::kStabilityDebuggerNotPresent, 0);
482 486
483 local_state->SetInteger(prefs::kStabilityLaunchCount, 0); 487 local_state->SetInteger(prefs::kStabilityLaunchCount, 0);
484 local_state->SetInteger(prefs::kStabilityCrashCount, 0); 488 local_state->SetInteger(prefs::kStabilityCrashCount, 0);
485 489
486 local_state->SetInteger(prefs::kStabilityPageLoadCount, 0); 490 local_state->SetInteger(prefs::kStabilityPageLoadCount, 0);
487 local_state->SetInteger(prefs::kStabilityRendererCrashCount, 0); 491 local_state->SetInteger(prefs::kStabilityRendererCrashCount, 0);
488 local_state->SetInteger(prefs::kStabilityRendererHangCount, 0); 492 local_state->SetInteger(prefs::kStabilityRendererHangCount, 0);
489 493
490 local_state->SetInt64(prefs::kStabilityLaunchTimeSec, 0); 494 local_state->SetInt64(prefs::kStabilityLaunchTimeSec, 0);
491 local_state->SetInt64(prefs::kStabilityLastTimestampSec, 0); 495 local_state->SetInt64(prefs::kStabilityLastTimestampSec, 0);
492 496
493 local_state->ClearPref(prefs::kStabilityPluginStats); 497 local_state->ClearPref(prefs::kStabilityPluginStats);
494 498
495 local_state->ClearPref(prefs::kMetricsInitialLogs); 499 local_state->ClearPref(prefs::kMetricsInitialLogs);
496 local_state->ClearPref(prefs::kMetricsOngoingLogs); 500 local_state->ClearPref(prefs::kMetricsOngoingLogs);
501
502 #if defined(OS_ANDROID)
503 DiscardOldStabilityStatsAndroid(local_state);
504 #endif // defined(OS_ANDROID)
497 } 505 }
498 506
499 MetricsService::MetricsService() 507 MetricsService::MetricsService()
500 : recording_active_(false), 508 : recording_active_(false),
501 reporting_active_(false), 509 reporting_active_(false),
502 test_mode_active_(false), 510 test_mode_active_(false),
503 state_(INITIALIZED), 511 state_(INITIALIZED),
504 low_entropy_source_(kLowEntropySourceNotSet), 512 low_entropy_source_(kLowEntropySourceNotSet),
505 idle_since_last_transmission_(false), 513 idle_since_last_transmission_(false),
506 next_window_id_(0), 514 next_window_id_(0),
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 } 928 }
921 929
922 // Update session ID 930 // Update session ID
923 session_id_ = pref->GetInteger(prefs::kMetricsSessionID); 931 session_id_ = pref->GetInteger(prefs::kMetricsSessionID);
924 ++session_id_; 932 ++session_id_;
925 pref->SetInteger(prefs::kMetricsSessionID, session_id_); 933 pref->SetInteger(prefs::kMetricsSessionID, session_id_);
926 934
927 // Stability bookkeeping 935 // Stability bookkeeping
928 IncrementPrefValue(prefs::kStabilityLaunchCount); 936 IncrementPrefValue(prefs::kStabilityLaunchCount);
929 937
938 #if defined(OS_ANDROID)
939 RecordAndroidStabilityPrefs();
940 #endif // defined(OS_ANDROID)
Ilya Sherman 2013/12/16 23:54:59 I think this line needs to be moved after Alexei's
gone 2013/12/17 01:34:31 I guess something definitely has to be done for th
941
930 if (!pref->GetBoolean(prefs::kStabilityExitedCleanly)) { 942 if (!pref->GetBoolean(prefs::kStabilityExitedCleanly)) {
931 IncrementPrefValue(prefs::kStabilityCrashCount); 943 IncrementPrefValue(prefs::kStabilityCrashCount);
932 // Reset flag, and wait until we call LogNeedForCleanShutdown() before 944 // Reset flag, and wait until we call LogNeedForCleanShutdown() before
933 // monitoring. 945 // monitoring.
934 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); 946 pref->SetBoolean(prefs::kStabilityExitedCleanly, true);
935 947
936 // TODO(rtenneti): On windows, consider saving/getting execution_phase from 948 // TODO(rtenneti): On windows, consider saving/getting execution_phase from
937 // the registry. 949 // the registry.
938 int execution_phase = pref->GetInteger(prefs::kStabilityExecutionPhase); 950 int execution_phase = pref->GetInteger(prefs::kStabilityExecutionPhase);
939 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", 951 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase",
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 static_cast<MetricsLog*>(log_manager_.current_log()); 1246 static_cast<MetricsLog*>(log_manager_.current_log());
1235 DCHECK(current_log); 1247 DCHECK(current_log);
1236 std::vector<chrome_variations::ActiveGroupId> synthetic_trials; 1248 std::vector<chrome_variations::ActiveGroupId> synthetic_trials;
1237 GetCurrentSyntheticFieldTrials(&synthetic_trials); 1249 GetCurrentSyntheticFieldTrials(&synthetic_trials);
1238 current_log->RecordEnvironment(plugins_, google_update_metrics_, 1250 current_log->RecordEnvironment(plugins_, google_update_metrics_,
1239 synthetic_trials); 1251 synthetic_trials);
1240 PrefService* pref = g_browser_process->local_state(); 1252 PrefService* pref = g_browser_process->local_state();
1241 current_log->RecordStabilityMetrics(GetIncrementalUptime(pref), 1253 current_log->RecordStabilityMetrics(GetIncrementalUptime(pref),
1242 MetricsLog::ONGOING_LOG); 1254 MetricsLog::ONGOING_LOG);
1243 1255
1256 #if defined(OS_ANDROID)
1257 RecordAndroidStabilityHistograms();
1258 #endif // defined(OS_ANDROID)
1244 RecordCurrentHistograms(); 1259 RecordCurrentHistograms();
1245 1260
1246 log_manager_.FinishCurrentLog(); 1261 log_manager_.FinishCurrentLog();
1247 } 1262 }
1248 1263
1249 void MetricsService::PushPendingLogsToPersistentStorage() { 1264 void MetricsService::PushPendingLogsToPersistentStorage() {
1250 if (state_ < INITIAL_LOG_READY) 1265 if (state_ < INITIAL_LOG_READY)
1251 return; // We didn't and still don't have time to get plugin list etc. 1266 return; // We didn't and still don't have time to get plugin list etc.
1252 1267
1253 if (log_manager_.has_staged_log()) { 1268 if (log_manager_.has_staged_log()) {
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 if (local_state) { 1947 if (local_state) {
1933 const PrefService::Preference* uma_pref = 1948 const PrefService::Preference* uma_pref =
1934 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1949 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1935 if (uma_pref) { 1950 if (uma_pref) {
1936 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1951 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1937 DCHECK(success); 1952 DCHECK(success);
1938 } 1953 }
1939 } 1954 }
1940 return result; 1955 return result;
1941 } 1956 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698