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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 #include "chrome/browser/chrome_notification_types.h" | 185 #include "chrome/browser/chrome_notification_types.h" |
186 #include "chrome/browser/io_thread.h" | 186 #include "chrome/browser/io_thread.h" |
187 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" | 187 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" |
188 #include "chrome/browser/metrics/compression_utils.h" | 188 #include "chrome/browser/metrics/compression_utils.h" |
189 #include "chrome/browser/metrics/gpu_metrics_provider.h" | 189 #include "chrome/browser/metrics/gpu_metrics_provider.h" |
190 #include "chrome/browser/metrics/metrics_log.h" | 190 #include "chrome/browser/metrics/metrics_log.h" |
191 #include "chrome/browser/metrics/metrics_state_manager.h" | 191 #include "chrome/browser/metrics/metrics_state_manager.h" |
192 #include "chrome/browser/metrics/network_metrics_provider.h" | 192 #include "chrome/browser/metrics/network_metrics_provider.h" |
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/chrome_constants.h" | |
196 #include "chrome/common/pref_names.h" | 195 #include "chrome/common/pref_names.h" |
197 #include "chrome/common/variations/variations_util.h" | 196 #include "chrome/common/variations/variations_util.h" |
198 #include "components/metrics/metrics_log_base.h" | 197 #include "components/metrics/metrics_log_base.h" |
199 #include "components/metrics/metrics_log_manager.h" | 198 #include "components/metrics/metrics_log_manager.h" |
200 #include "components/metrics/metrics_pref_names.h" | 199 #include "components/metrics/metrics_pref_names.h" |
201 #include "components/metrics/metrics_reporting_scheduler.h" | 200 #include "components/metrics/metrics_reporting_scheduler.h" |
202 #include "components/metrics/metrics_service_client.h" | 201 #include "components/metrics/metrics_service_client.h" |
203 #include "components/variations/entropy_provider.h" | 202 #include "components/variations/entropy_provider.h" |
204 #include "content/public/browser/child_process_data.h" | 203 #include "content/public/browser/child_process_data.h" |
205 #include "content/public/browser/render_process_host.h" | 204 #include "content/public/browser/render_process_host.h" |
206 #include "content/public/browser/user_metrics.h" | 205 #include "content/public/browser/user_metrics.h" |
207 #include "net/base/load_flags.h" | 206 #include "net/base/load_flags.h" |
208 #include "net/url_request/url_fetcher.h" | 207 #include "net/url_request/url_fetcher.h" |
209 | 208 |
210 #if defined(ENABLE_PLUGINS) | 209 #if defined(ENABLE_PLUGINS) |
211 // TODO(asvitkine): Move this out of MetricsService. | 210 // TODO(asvitkine): Move this out of MetricsService. |
212 #include "chrome/browser/metrics/plugin_metrics_provider.h" | 211 #include "chrome/browser/metrics/plugin_metrics_provider.h" |
213 #endif | 212 #endif |
214 | 213 |
215 #if defined(OS_CHROMEOS) | 214 #if defined(OS_CHROMEOS) |
216 #include "chrome/browser/chromeos/settings/cros_settings.h" | 215 #include "chrome/browser/chromeos/settings/cros_settings.h" |
217 #include "chromeos/system/statistics_provider.h" | 216 #include "chromeos/system/statistics_provider.h" |
218 #endif | 217 #endif |
219 | 218 |
220 #if defined(OS_WIN) | 219 #if defined(OS_WIN) |
221 #include <windows.h> // Needed for STATUS_* codes | |
222 #include "base/win/registry.h" | |
223 #include "chrome/browser/metrics/google_update_metrics_provider_win.h" | 220 #include "chrome/browser/metrics/google_update_metrics_provider_win.h" |
224 #endif | 221 #endif |
225 | 222 |
226 #if defined(OS_ANDROID) | 223 #if defined(OS_ANDROID) |
227 // TODO(asvitkine): Move this out of MetricsService. | 224 // TODO(asvitkine): Move this out of MetricsService. |
228 #include "chrome/browser/metrics/android_metrics_provider.h" | 225 #include "chrome/browser/metrics/android_metrics_provider.h" |
229 #endif | 226 #endif |
230 | 227 |
231 using base::Time; | 228 using base::Time; |
232 using content::BrowserThread; | 229 using content::BrowserThread; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 IncrementPrefValue(prefs::kStabilityBreakpadRegistrationSuccess); | 648 IncrementPrefValue(prefs::kStabilityBreakpadRegistrationSuccess); |
652 } | 649 } |
653 | 650 |
654 void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { | 651 void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { |
655 if (!has_debugger) | 652 if (!has_debugger) |
656 IncrementPrefValue(prefs::kStabilityDebuggerNotPresent); | 653 IncrementPrefValue(prefs::kStabilityDebuggerNotPresent); |
657 else | 654 else |
658 IncrementPrefValue(prefs::kStabilityDebuggerPresent); | 655 IncrementPrefValue(prefs::kStabilityDebuggerPresent); |
659 } | 656 } |
660 | 657 |
661 #if defined(OS_WIN) | |
662 void MetricsService::CountBrowserCrashDumpAttempts() { | |
663 // Open the registry key for iteration. | |
664 base::win::RegKey regkey; | |
665 if (regkey.Open(HKEY_CURRENT_USER, | |
666 chrome::kBrowserCrashDumpAttemptsRegistryPath, | |
667 KEY_ALL_ACCESS) != ERROR_SUCCESS) { | |
668 return; | |
669 } | |
670 | |
671 // The values we're interested in counting are all prefixed with the version. | |
672 base::string16 chrome_version(base::ASCIIToUTF16(chrome::kChromeVersion)); | |
673 | |
674 // Track a list of values to delete. We don't modify the registry key while | |
675 // we're iterating over its values. | |
676 typedef std::vector<base::string16> StringVector; | |
677 StringVector to_delete; | |
678 | |
679 // Iterate over the values in the key counting dumps with and without crashes. | |
680 // We directly walk the values instead of using RegistryValueIterator in order | |
681 // to read all of the values as DWORDS instead of strings. | |
682 base::string16 name; | |
683 DWORD value = 0; | |
684 int dumps_with_crash = 0; | |
685 int dumps_with_no_crash = 0; | |
686 for (int i = regkey.GetValueCount() - 1; i >= 0; --i) { | |
687 if (regkey.GetValueNameAt(i, &name) == ERROR_SUCCESS && | |
688 StartsWith(name, chrome_version, false) && | |
689 regkey.ReadValueDW(name.c_str(), &value) == ERROR_SUCCESS) { | |
690 to_delete.push_back(name); | |
691 if (value == 0) | |
692 ++dumps_with_no_crash; | |
693 else | |
694 ++dumps_with_crash; | |
695 } | |
696 } | |
697 | |
698 // Delete the registry keys we've just counted. | |
699 for (StringVector::iterator i = to_delete.begin(); i != to_delete.end(); ++i) | |
700 regkey.DeleteValue(i->c_str()); | |
701 | |
702 // Capture the histogram samples. | |
703 if (dumps_with_crash != 0) | |
704 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithCrash", dumps_with_crash); | |
705 if (dumps_with_no_crash != 0) | |
706 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithNoCrash", dumps_with_no_crash); | |
707 int total_dumps = dumps_with_crash + dumps_with_no_crash; | |
708 if (total_dumps != 0) | |
709 UMA_HISTOGRAM_COUNTS("Chrome.BrowserCrashDumpAttempts", total_dumps); | |
710 } | |
711 #endif // defined(OS_WIN) | |
712 | |
713 //------------------------------------------------------------------------------ | 658 //------------------------------------------------------------------------------ |
714 // private methods | 659 // private methods |
715 //------------------------------------------------------------------------------ | 660 //------------------------------------------------------------------------------ |
716 | 661 |
717 | 662 |
718 //------------------------------------------------------------------------------ | 663 //------------------------------------------------------------------------------ |
719 // Initialization methods | 664 // Initialization methods |
720 | 665 |
721 void MetricsService::InitializeMetricsState() { | 666 void MetricsService::InitializeMetricsState() { |
722 PrefService* pref = g_browser_process->local_state(); | 667 PrefService* pref = g_browser_process->local_state(); |
(...skipping 25 matching lines...) Expand all Loading... |
748 // Update session ID. | 693 // Update session ID. |
749 ++session_id_; | 694 ++session_id_; |
750 pref->SetInteger(prefs::kMetricsSessionID, session_id_); | 695 pref->SetInteger(prefs::kMetricsSessionID, session_id_); |
751 | 696 |
752 // Stability bookkeeping | 697 // Stability bookkeeping |
753 IncrementPrefValue(prefs::kStabilityLaunchCount); | 698 IncrementPrefValue(prefs::kStabilityLaunchCount); |
754 | 699 |
755 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); | 700 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); |
756 SetExecutionPhase(START_METRICS_RECORDING); | 701 SetExecutionPhase(START_METRICS_RECORDING); |
757 | 702 |
758 #if defined(OS_WIN) | |
759 CountBrowserCrashDumpAttempts(); | |
760 #endif // defined(OS_WIN) | |
761 | |
762 if (!pref->GetBoolean(prefs::kStabilitySessionEndCompleted)) { | 703 if (!pref->GetBoolean(prefs::kStabilitySessionEndCompleted)) { |
763 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); | 704 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); |
764 // This is marked false when we get a WM_ENDSESSION. | 705 // This is marked false when we get a WM_ENDSESSION. |
765 pref->SetBoolean(prefs::kStabilitySessionEndCompleted, true); | 706 pref->SetBoolean(prefs::kStabilitySessionEndCompleted, true); |
766 } | 707 } |
767 | 708 |
768 // Call GetUptimes() for the first time, thus allowing all later calls | 709 // Call GetUptimes() for the first time, thus allowing all later calls |
769 // to record incremental uptimes accurately. | 710 // to record incremental uptimes accurately. |
770 base::TimeDelta ignored_uptime_parameter; | 711 base::TimeDelta ignored_uptime_parameter; |
771 base::TimeDelta startup_uptime; | 712 base::TimeDelta startup_uptime; |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 } | 1467 } |
1527 | 1468 |
1528 void MetricsService::RecordCurrentState(PrefService* pref) { | 1469 void MetricsService::RecordCurrentState(PrefService* pref) { |
1529 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); | 1470 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); |
1530 | 1471 |
1531 #if defined(ENABLE_PLUGINS) | 1472 #if defined(ENABLE_PLUGINS) |
1532 plugin_metrics_provider_->RecordPluginChanges(); | 1473 plugin_metrics_provider_->RecordPluginChanges(); |
1533 #endif | 1474 #endif |
1534 } | 1475 } |
1535 | 1476 |
OLD | NEW |