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

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

Issue 292433015: Refactor MetricsLogChromeOS to ChromeOSMetricsProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fixes Created 6 years, 7 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 #include "net/base/load_flags.h" 203 #include "net/base/load_flags.h"
204 #include "net/url_request/url_fetcher.h" 204 #include "net/url_request/url_fetcher.h"
205 205
206 #if defined(ENABLE_PLUGINS) 206 #if defined(ENABLE_PLUGINS)
207 // TODO(asvitkine): Move this out of MetricsService. 207 // TODO(asvitkine): Move this out of MetricsService.
208 #include "chrome/browser/metrics/plugin_metrics_provider.h" 208 #include "chrome/browser/metrics/plugin_metrics_provider.h"
209 #endif 209 #endif
210 210
211 #if defined(OS_CHROMEOS) 211 #if defined(OS_CHROMEOS)
212 #include "chrome/browser/chromeos/settings/cros_settings.h" 212 #include "chrome/browser/chromeos/settings/cros_settings.h"
213 #include "chrome/browser/metrics/chromeos_metrics_provider.h"
213 #include "chromeos/system/statistics_provider.h" 214 #include "chromeos/system/statistics_provider.h"
214 #endif 215 #endif
215 216
216 #if defined(OS_WIN) 217 #if defined(OS_WIN)
217 #include "chrome/browser/metrics/google_update_metrics_provider_win.h" 218 #include "chrome/browser/metrics/google_update_metrics_provider_win.h"
218 #endif 219 #endif
219 220
220 #if defined(OS_ANDROID) 221 #if defined(OS_ANDROID)
221 // TODO(asvitkine): Move this out of MetricsService. 222 // TODO(asvitkine): Move this out of MetricsService.
222 #include "chrome/browser/metrics/android_metrics_provider.h" 223 #include "chrome/browser/metrics/android_metrics_provider.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); 330 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true);
330 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); 331 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1);
331 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); 332 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0);
332 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); 333 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0);
333 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); 334 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0);
334 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0); 335 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0);
335 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess, 336 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess,
336 0); 337 0);
337 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); 338 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0);
338 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); 339 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0);
339 #if defined(OS_CHROMEOS)
340 registry->RegisterIntegerPref(prefs::kStabilityOtherUserCrashCount, 0);
341 registry->RegisterIntegerPref(prefs::kStabilityKernelCrashCount, 0);
342 registry->RegisterIntegerPref(prefs::kStabilitySystemUncleanShutdownCount, 0);
343 #endif // OS_CHROMEOS
344 340
345 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile, 341 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile,
346 std::string()); 342 std::string());
347 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfileHash, 343 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfileHash,
348 std::string()); 344 std::string());
349 345
350 registry->RegisterListPref(metrics::prefs::kMetricsInitialLogs); 346 registry->RegisterListPref(metrics::prefs::kMetricsInitialLogs);
351 registry->RegisterListPref(metrics::prefs::kMetricsOngoingLogs); 347 registry->RegisterListPref(metrics::prefs::kMetricsOngoingLogs);
352 348
353 registry->RegisterInt64Pref(prefs::kInstallDate, 0); 349 registry->RegisterInt64Pref(prefs::kInstallDate, 0);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider>( 410 RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider>(
415 google_update_metrics_provider_)); 411 google_update_metrics_provider_));
416 #endif 412 #endif
417 413
418 #if defined(ENABLE_PLUGINS) 414 #if defined(ENABLE_PLUGINS)
419 plugin_metrics_provider_ = new PluginMetricsProvider( 415 plugin_metrics_provider_ = new PluginMetricsProvider(
420 g_browser_process->local_state()); 416 g_browser_process->local_state());
421 RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider>( 417 RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider>(
422 plugin_metrics_provider_)); 418 plugin_metrics_provider_));
423 #endif 419 #endif
420
421 #if defined(OS_CHROMEOS)
422 RegisterMetricsProvider(
423 scoped_ptr<metrics::MetricsProvider>(new ChromeOSMetricsProvider));
424 #endif
424 } 425 }
425 426
426 MetricsService::~MetricsService() { 427 MetricsService::~MetricsService() {
427 DisableRecording(); 428 DisableRecording();
428 } 429 }
429 430
430 void MetricsService::InitializeMetricsRecordingState() { 431 void MetricsService::InitializeMetricsRecordingState() {
431 InitializeMetricsState(); 432 InitializeMetricsState();
432 433
433 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, 434 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload,
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 816
816 void MetricsService::RemoveObserver(MetricsServiceObserver* observer) { 817 void MetricsService::RemoveObserver(MetricsServiceObserver* observer) {
817 DCHECK(thread_checker_.CalledOnValidThread()); 818 DCHECK(thread_checker_.CalledOnValidThread());
818 observers_.RemoveObserver(observer); 819 observers_.RemoveObserver(observer);
819 } 820 }
820 821
821 void MetricsService::NotifyOnDidCreateMetricsLog() { 822 void MetricsService::NotifyOnDidCreateMetricsLog() {
822 DCHECK(thread_checker_.CalledOnValidThread()); 823 DCHECK(thread_checker_.CalledOnValidThread());
823 FOR_EACH_OBSERVER( 824 FOR_EACH_OBSERVER(
824 MetricsServiceObserver, observers_, OnDidCreateMetricsLog()); 825 MetricsServiceObserver, observers_, OnDidCreateMetricsLog());
826 for (size_t i = 0; i < metrics_providers_.size(); ++i)
827 metrics_providers_[i]->OnDidCreateMetricsLog();
825 } 828 }
826 829
827 //------------------------------------------------------------------------------ 830 //------------------------------------------------------------------------------
828 // State save methods 831 // State save methods
829 832
830 void MetricsService::ScheduleNextStateSave() { 833 void MetricsService::ScheduleNextStateSave() {
831 state_saver_factory_.InvalidateWeakPtrs(); 834 state_saver_factory_.InvalidateWeakPtrs();
832 835
833 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, 836 base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
834 base::Bind(&MetricsService::SaveLocalState, 837 base::Bind(&MetricsService::SaveLocalState,
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 // Redundant setting to assure that we always reset this value at shutdown 1398 // Redundant setting to assure that we always reset this value at shutdown
1396 // (and that we don't use some alternate path, and not call LogCleanShutdown). 1399 // (and that we don't use some alternate path, and not call LogCleanShutdown).
1397 clean_shutdown_status_ = CLEANLY_SHUTDOWN; 1400 clean_shutdown_status_ = CLEANLY_SHUTDOWN;
1398 1401
1399 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); 1402 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true);
1400 PrefService* pref = g_browser_process->local_state(); 1403 PrefService* pref = g_browser_process->local_state();
1401 pref->SetInteger(prefs::kStabilityExecutionPhase, 1404 pref->SetInteger(prefs::kStabilityExecutionPhase,
1402 MetricsService::SHUTDOWN_COMPLETE); 1405 MetricsService::SHUTDOWN_COMPLETE);
1403 } 1406 }
1404 1407
1405 #if defined(OS_CHROMEOS)
1406 void MetricsService::LogChromeOSCrash(const std::string &crash_type) {
1407 if (crash_type == "user")
1408 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount);
1409 else if (crash_type == "kernel")
1410 IncrementPrefValue(prefs::kStabilityKernelCrashCount);
1411 else if (crash_type == "uncleanshutdown")
1412 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount);
1413 else
1414 NOTREACHED() << "Unexpected Chrome OS crash type " << crash_type;
1415 // Wake up metrics logs sending if necessary now that new
1416 // log data is available.
1417 HandleIdleSinceLastTransmission(false);
1418 }
1419 #endif // OS_CHROMEOS
1420
1421 void MetricsService::LogPluginLoadingError(const base::FilePath& plugin_path) { 1408 void MetricsService::LogPluginLoadingError(const base::FilePath& plugin_path) {
1422 #if defined(ENABLE_PLUGINS) 1409 #if defined(ENABLE_PLUGINS)
1423 // TODO(asvitkine): Move this out of here. 1410 // TODO(asvitkine): Move this out of here.
1424 plugin_metrics_provider_->LogPluginLoadingError(plugin_path); 1411 plugin_metrics_provider_->LogPluginLoadingError(plugin_path);
1425 #endif 1412 #endif
1426 } 1413 }
1427 1414
1428 bool MetricsService::ShouldLogEvents() { 1415 bool MetricsService::ShouldLogEvents() {
1429 // We simply don't log events to UMA if there is a single incognito 1416 // We simply don't log events to UMA if there is a single incognito
1430 // session visible. The problem is that we always notify using the orginal 1417 // session visible. The problem is that we always notify using the orginal
(...skipping 11 matching lines...) Expand all
1442 RecordCurrentState(pref); 1429 RecordCurrentState(pref);
1443 } 1430 }
1444 1431
1445 void MetricsService::RecordCurrentState(PrefService* pref) { 1432 void MetricsService::RecordCurrentState(PrefService* pref) {
1446 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); 1433 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT());
1447 1434
1448 #if defined(ENABLE_PLUGINS) 1435 #if defined(ENABLE_PLUGINS)
1449 plugin_metrics_provider_->RecordPluginChanges(); 1436 plugin_metrics_provider_->RecordPluginChanges();
1450 #endif 1437 #endif
1451 } 1438 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/browser/metrics/metrics_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698