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/tracking_synchronizer.h" | 193 #include "chrome/browser/metrics/tracking_synchronizer.h" |
194 #include "chrome/common/chrome_constants.h" | 194 #include "chrome/common/chrome_constants.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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); | 326 registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); |
330 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); | 327 registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); |
331 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 328 registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
332 registry->RegisterIntegerPref(prefs::kStabilityExecutionPhase, | 329 registry->RegisterIntegerPref(prefs::kStabilityExecutionPhase, |
333 UNINITIALIZED_PHASE); | 330 UNINITIALIZED_PHASE); |
334 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); | 331 registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); |
335 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); | 332 registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); |
336 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 333 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
337 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); | 334 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); |
338 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); | 335 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); |
339 registry->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); | |
340 registry->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); | |
341 registry->RegisterIntegerPref(prefs::kStabilityExtensionRendererCrashCount, | |
342 0); | |
343 registry->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); | |
344 registry->RegisterIntegerPref(prefs::kStabilityChildProcessCrashCount, 0); | |
345 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0); | 336 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0); |
346 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess, | 337 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess, |
347 0); | 338 0); |
348 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); | 339 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); |
349 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); | 340 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); |
350 #if defined(OS_CHROMEOS) | 341 #if defined(OS_CHROMEOS) |
351 registry->RegisterIntegerPref(prefs::kStabilityOtherUserCrashCount, 0); | 342 registry->RegisterIntegerPref(prefs::kStabilityOtherUserCrashCount, 0); |
352 registry->RegisterIntegerPref(prefs::kStabilityKernelCrashCount, 0); | 343 registry->RegisterIntegerPref(prefs::kStabilityKernelCrashCount, 0); |
353 registry->RegisterIntegerPref(prefs::kStabilitySystemUncleanShutdownCount, 0); | 344 registry->RegisterIntegerPref(prefs::kStabilitySystemUncleanShutdownCount, 0); |
354 #endif // OS_CHROMEOS | 345 #endif // OS_CHROMEOS |
355 | 346 |
356 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile, | 347 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile, |
357 std::string()); | 348 std::string()); |
358 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfileHash, | 349 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfileHash, |
359 std::string()); | 350 std::string()); |
360 | 351 |
361 registry->RegisterListPref(metrics::prefs::kMetricsInitialLogs); | 352 registry->RegisterListPref(metrics::prefs::kMetricsInitialLogs); |
362 registry->RegisterListPref(metrics::prefs::kMetricsOngoingLogs); | 353 registry->RegisterListPref(metrics::prefs::kMetricsOngoingLogs); |
363 | 354 |
364 registry->RegisterInt64Pref(prefs::kInstallDate, 0); | 355 registry->RegisterInt64Pref(prefs::kInstallDate, 0); |
365 registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0); | |
366 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); | 356 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); |
367 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); | 357 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); |
368 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); | 358 registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); |
369 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); | 359 registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); |
370 | 360 |
| 361 // TODO(asvitkine): Move this out of here. |
| 362 ChromeStabilityMetricsProvider::RegisterPrefs(registry); |
| 363 |
371 #if defined(OS_ANDROID) | 364 #if defined(OS_ANDROID) |
372 // TODO(asvitkine): Move this out of here. | 365 // TODO(asvitkine): Move this out of here. |
373 AndroidMetricsProvider::RegisterPrefs(registry); | 366 AndroidMetricsProvider::RegisterPrefs(registry); |
374 #endif // defined(OS_ANDROID) | 367 #endif // defined(OS_ANDROID) |
375 | 368 |
376 #if defined(ENABLE_PLUGINS) | 369 #if defined(ENABLE_PLUGINS) |
377 // TODO(asvitkine): Move this out of here. | 370 // TODO(asvitkine): Move this out of here. |
378 PluginMetricsProvider::RegisterPrefs(registry); | 371 PluginMetricsProvider::RegisterPrefs(registry); |
379 #endif | 372 #endif |
380 } | 373 } |
(...skipping 40 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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 RecordCurrentState(pref); | 1493 RecordCurrentState(pref); |
1518 } | 1494 } |
1519 | 1495 |
1520 void MetricsService::RecordCurrentState(PrefService* pref) { | 1496 void MetricsService::RecordCurrentState(PrefService* pref) { |
1521 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); | 1497 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); |
1522 | 1498 |
1523 #if defined(ENABLE_PLUGINS) | 1499 #if defined(ENABLE_PLUGINS) |
1524 plugin_metrics_provider_->RecordPluginChanges(); | 1500 plugin_metrics_provider_->RecordPluginChanges(); |
1525 #endif | 1501 #endif |
1526 } | 1502 } |
1527 | |
OLD | NEW |