OLD | NEW |
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 #include "chrome/browser/metrics/omnibox_metrics_provider.h" | 193 #include "chrome/browser/metrics/omnibox_metrics_provider.h" |
194 #include "chrome/browser/metrics/tracking_synchronizer.h" | 194 #include "chrome/browser/metrics/tracking_synchronizer.h" |
195 #include "chrome/common/pref_names.h" | 195 #include "chrome/common/pref_names.h" |
196 #include "chrome/common/variations/variations_util.h" | 196 #include "chrome/common/variations/variations_util.h" |
197 #include "components/metrics/metrics_log_base.h" | 197 #include "components/metrics/metrics_log_base.h" |
198 #include "components/metrics/metrics_log_manager.h" | 198 #include "components/metrics/metrics_log_manager.h" |
199 #include "components/metrics/metrics_pref_names.h" | 199 #include "components/metrics/metrics_pref_names.h" |
200 #include "components/metrics/metrics_reporting_scheduler.h" | 200 #include "components/metrics/metrics_reporting_scheduler.h" |
201 #include "components/metrics/metrics_service_client.h" | 201 #include "components/metrics/metrics_service_client.h" |
202 #include "components/variations/entropy_provider.h" | 202 #include "components/variations/entropy_provider.h" |
203 #include "content/public/browser/child_process_data.h" | |
204 #include "content/public/browser/render_process_host.h" | |
205 #include "content/public/browser/user_metrics.h" | |
206 #include "net/base/load_flags.h" | 203 #include "net/base/load_flags.h" |
207 #include "net/url_request/url_fetcher.h" | 204 #include "net/url_request/url_fetcher.h" |
208 | 205 |
209 #if defined(ENABLE_PLUGINS) | 206 #if defined(ENABLE_PLUGINS) |
210 // TODO(asvitkine): Move this out of MetricsService. | 207 // TODO(asvitkine): Move this out of MetricsService. |
211 #include "chrome/browser/metrics/plugin_metrics_provider.h" | 208 #include "chrome/browser/metrics/plugin_metrics_provider.h" |
212 #endif | 209 #endif |
213 | 210 |
214 #if defined(OS_CHROMEOS) | 211 #if defined(OS_CHROMEOS) |
215 #include "chrome/browser/chromeos/settings/cros_settings.h" | 212 #include "chrome/browser/chromeos/settings/cros_settings.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); | 324 registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); |
328 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); | 325 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); |
329 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 326 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
330 registry->RegisterIntegerPref(prefs::kStabilityExecutionPhase, | 327 registry->RegisterIntegerPref(prefs::kStabilityExecutionPhase, |
331 UNINITIALIZED_PHASE); | 328 UNINITIALIZED_PHASE); |
332 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); | 329 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); |
333 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); | 330 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); |
334 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 331 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
335 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); | 332 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); |
336 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); | 333 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); |
337 registry->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); | |
338 registry->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); | |
339 registry->RegisterIntegerPref(prefs::kStabilityExtensionRendererCrashCount, | |
340 0); | |
341 registry->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); | |
342 registry->RegisterIntegerPref(prefs::kStabilityChildProcessCrashCount, 0); | |
343 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0); | 334 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0); |
344 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess, | 335 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess, |
345 0); | 336 0); |
346 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); | 337 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); |
347 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); | 338 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); |
348 #if defined(OS_CHROMEOS) | 339 #if defined(OS_CHROMEOS) |
349 registry->RegisterIntegerPref(prefs::kStabilityOtherUserCrashCount, 0); | 340 registry->RegisterIntegerPref(prefs::kStabilityOtherUserCrashCount, 0); |
350 registry->RegisterIntegerPref(prefs::kStabilityKernelCrashCount, 0); | 341 registry->RegisterIntegerPref(prefs::kStabilityKernelCrashCount, 0); |
351 registry->RegisterIntegerPref(prefs::kStabilitySystemUncleanShutdownCount, 0); | 342 registry->RegisterIntegerPref(prefs::kStabilitySystemUncleanShutdownCount, 0); |
352 #endif // OS_CHROMEOS | 343 #endif // OS_CHROMEOS |
353 | 344 |
354 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile, | 345 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile, |
355 std::string()); | 346 std::string()); |
356 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfileHash, | 347 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfileHash, |
357 std::string()); | 348 std::string()); |
358 | 349 |
359 registry->RegisterListPref(metrics::prefs::kMetricsInitialLogs); | 350 registry->RegisterListPref(metrics::prefs::kMetricsInitialLogs); |
360 registry->RegisterListPref(metrics::prefs::kMetricsOngoingLogs); | 351 registry->RegisterListPref(metrics::prefs::kMetricsOngoingLogs); |
361 | 352 |
362 registry->RegisterInt64Pref(prefs::kInstallDate, 0); | 353 registry->RegisterInt64Pref(prefs::kInstallDate, 0); |
363 registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0); | |
364 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); | 354 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); |
365 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); | 355 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); |
366 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); | 356 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); |
367 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); | 357 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); |
368 | 358 |
| 359 // TODO(asvitkine): Move this out of here. |
| 360 ChromeStabilityMetricsProvider::RegisterPrefs(registry); |
| 361 |
369 #if defined(OS_ANDROID) | 362 #if defined(OS_ANDROID) |
370 // TODO(asvitkine): Move this out of here. | 363 // TODO(asvitkine): Move this out of here. |
371 AndroidMetricsProvider::RegisterPrefs(registry); | 364 AndroidMetricsProvider::RegisterPrefs(registry); |
372 #endif // defined(OS_ANDROID) | 365 #endif // defined(OS_ANDROID) |
373 | 366 |
374 #if defined(ENABLE_PLUGINS) | 367 #if defined(ENABLE_PLUGINS) |
375 // TODO(asvitkine): Move this out of here. | 368 // TODO(asvitkine): Move this out of here. |
376 PluginMetricsProvider::RegisterPrefs(registry); | 369 PluginMetricsProvider::RegisterPrefs(registry); |
377 #endif | 370 #endif |
378 } | 371 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider>( | 414 RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider>( |
422 google_update_metrics_provider_)); | 415 google_update_metrics_provider_)); |
423 #endif | 416 #endif |
424 | 417 |
425 #if defined(ENABLE_PLUGINS) | 418 #if defined(ENABLE_PLUGINS) |
426 plugin_metrics_provider_ = new PluginMetricsProvider( | 419 plugin_metrics_provider_ = new PluginMetricsProvider( |
427 g_browser_process->local_state()); | 420 g_browser_process->local_state()); |
428 RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider>( | 421 RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider>( |
429 plugin_metrics_provider_)); | 422 plugin_metrics_provider_)); |
430 #endif | 423 #endif |
431 | |
432 BrowserChildProcessObserver::Add(this); | |
433 } | 424 } |
434 | 425 |
435 MetricsService::~MetricsService() { | 426 MetricsService::~MetricsService() { |
436 DisableRecording(); | 427 DisableRecording(); |
437 | |
438 BrowserChildProcessObserver::Remove(this); | |
439 } | 428 } |
440 | 429 |
441 void MetricsService::InitializeMetricsRecordingState() { | 430 void MetricsService::InitializeMetricsRecordingState() { |
442 InitializeMetricsState(); | 431 InitializeMetricsState(); |
443 | 432 |
444 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, | 433 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, |
445 self_ptr_factory_.GetWeakPtr()); | 434 self_ptr_factory_.GetWeakPtr()); |
446 scheduler_.reset(new MetricsReportingScheduler(callback)); | 435 scheduler_.reset(new MetricsReportingScheduler(callback)); |
447 } | 436 } |
448 | 437 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 base::HistogramBase::Inconsistency problem) { | 545 base::HistogramBase::Inconsistency problem) { |
557 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique", | 546 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique", |
558 problem, base::HistogramBase::NEVER_EXCEEDED_VALUE); | 547 problem, base::HistogramBase::NEVER_EXCEEDED_VALUE); |
559 } | 548 } |
560 | 549 |
561 void MetricsService::InconsistencyDetectedInLoggedCount(int amount) { | 550 void MetricsService::InconsistencyDetectedInLoggedCount(int amount) { |
562 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser", | 551 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser", |
563 std::abs(amount)); | 552 std::abs(amount)); |
564 } | 553 } |
565 | 554 |
566 void MetricsService::BrowserChildProcessCrashed( | |
567 const content::ChildProcessData& data) { | |
568 // TODO(asvitkine): Move this into ChromeStabilityStatsProvider. | |
569 #if defined(ENABLE_PLUGINS) | |
570 // Exclude plugin crashes from the count below because we report them via | |
571 // a separate UMA metric. | |
572 if (PluginMetricsProvider::IsPluginProcess(data.process_type)) | |
573 return; | |
574 #endif | |
575 | |
576 IncrementPrefValue(prefs::kStabilityChildProcessCrashCount); | |
577 } | |
578 | |
579 void MetricsService::HandleIdleSinceLastTransmission(bool in_idle) { | 555 void MetricsService::HandleIdleSinceLastTransmission(bool in_idle) { |
580 // If there wasn't a lot of action, maybe the computer was asleep, in which | 556 // If there wasn't a lot of action, maybe the computer was asleep, in which |
581 // case, the log transmissions should have stopped. Here we start them up | 557 // case, the log transmissions should have stopped. Here we start them up |
582 // again. | 558 // again. |
583 if (!in_idle && idle_since_last_transmission_) | 559 if (!in_idle && idle_since_last_transmission_) |
584 StartSchedulerIfNecessary(); | 560 StartSchedulerIfNecessary(); |
585 idle_since_last_transmission_ = in_idle; | 561 idle_since_last_transmission_ = in_idle; |
586 } | 562 } |
587 | 563 |
588 void MetricsService::OnApplicationNotIdle() { | 564 void MetricsService::OnApplicationNotIdle() { |
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 RecordCurrentState(pref); | 1442 RecordCurrentState(pref); |
1467 } | 1443 } |
1468 | 1444 |
1469 void MetricsService::RecordCurrentState(PrefService* pref) { | 1445 void MetricsService::RecordCurrentState(PrefService* pref) { |
1470 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); | 1446 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); |
1471 | 1447 |
1472 #if defined(ENABLE_PLUGINS) | 1448 #if defined(ENABLE_PLUGINS) |
1473 plugin_metrics_provider_->RecordPluginChanges(); | 1449 plugin_metrics_provider_->RecordPluginChanges(); |
1474 #endif | 1450 #endif |
1475 } | 1451 } |
1476 | |
OLD | NEW |