| 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 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 | 790 |
| 791 void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { | 791 void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { |
| 792 if (!has_debugger) | 792 if (!has_debugger) |
| 793 IncrementPrefValue(prefs::kStabilityDebuggerNotPresent); | 793 IncrementPrefValue(prefs::kStabilityDebuggerNotPresent); |
| 794 else | 794 else |
| 795 IncrementPrefValue(prefs::kStabilityDebuggerPresent); | 795 IncrementPrefValue(prefs::kStabilityDebuggerPresent); |
| 796 } | 796 } |
| 797 | 797 |
| 798 #if defined(OS_WIN) | 798 #if defined(OS_WIN) |
| 799 void MetricsService::CountBrowserCrashDumpAttempts() { | 799 void MetricsService::CountBrowserCrashDumpAttempts() { |
| 800 base::string16 key_str(chrome::kBrowserCrashDumpAttemptsRegistryPath); | 800 // Open the registry key for iteration. |
| 801 key_str += L"\\"; | |
| 802 key_str += UTF8ToWide(chrome::kChromeVersion); | |
| 803 | |
| 804 base::win::RegKey regkey; | 801 base::win::RegKey regkey; |
| 805 if (regkey.Open(HKEY_CURRENT_USER, | 802 if (regkey.Open(HKEY_CURRENT_USER, |
| 806 key_str.c_str(), | 803 chrome::kBrowserCrashDumpAttemptsRegistryPath, |
| 807 KEY_ALL_ACCESS) != ERROR_SUCCESS) { | 804 KEY_ALL_ACCESS) != ERROR_SUCCESS) { |
| 808 return; | 805 return; |
| 809 } | 806 } |
| 810 | 807 |
| 811 base::string16 temp_name; | 808 // The values we're interested in counting are all prefixed with the version. |
| 812 DWORD temp_value = 0; | 809 base::string16 chrome_version(base::ASCIIToUTF16(chrome::kChromeVersion)); |
| 813 int crash_dump_attempts = 0; | 810 |
| 811 // Track a list of values to delete. We don't modify the registry key while |
| 812 // we're iterating over its values. |
| 813 typedef std::vector<base::string16> StringVector; |
| 814 StringVector to_delete; |
| 815 |
| 816 // Iterate over the values in the key counting dumps with and without crashes. |
| 817 // We directly walk the values instead of using RegistryValueIterator in order |
| 818 // to read all of the values as DWORDS instead of strings. |
| 819 base::string16 name; |
| 820 DWORD value = 0; |
| 821 int dumps_with_crash = 0; |
| 822 int dumps_with_no_crash = 0; |
| 814 for (int i = regkey.GetValueCount() - 1; i >= 0; --i) { | 823 for (int i = regkey.GetValueCount() - 1; i >= 0; --i) { |
| 815 if (regkey.GetValueNameAt(i, &temp_name) == ERROR_SUCCESS && | 824 if (regkey.GetValueNameAt(i, &name) == ERROR_SUCCESS && |
| 816 regkey.ReadValueDW(temp_name.c_str(), &temp_value) == ERROR_SUCCESS) { | 825 StartsWith(name, chrome_version, false) && |
| 817 regkey.DeleteValue(temp_name.c_str()); | 826 regkey.ReadValueDW(name.c_str(), &value) == ERROR_SUCCESS) { |
| 818 if (temp_value != 0) | 827 to_delete.push_back(name); |
| 819 ++crash_dump_attempts; | 828 if (value == 0) |
| 829 ++dumps_with_no_crash; |
| 830 else |
| 831 ++dumps_with_crash; |
| 820 } | 832 } |
| 821 } | 833 } |
| 822 UMA_HISTOGRAM_COUNTS("Chrome.BrowserCrashDumpAttempts", crash_dump_attempts); | 834 |
| 835 // Delete the registry keys we've just counted. |
| 836 for (StringVector::iterator i = to_delete.begin(); i != to_delete.end(); ++i) |
| 837 regkey.DeleteValue(i->c_str()); |
| 838 |
| 839 // Capture the histogram samples. |
| 840 if (dumps_with_crash != 0) |
| 841 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithCrash", dumps_with_crash); |
| 842 if (dumps_with_no_crash != 0) |
| 843 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithNoCrash", dumps_with_no_crash); |
| 844 int total_dumps = dumps_with_crash + dumps_with_no_crash; |
| 845 if (total_dumps != 0) |
| 846 UMA_HISTOGRAM_COUNTS("Chrome.BrowserCrashDumpAttempts", total_dumps); |
| 823 } | 847 } |
| 824 #endif // defined(OS_WIN) | 848 #endif // defined(OS_WIN) |
| 825 | 849 |
| 826 //------------------------------------------------------------------------------ | 850 //------------------------------------------------------------------------------ |
| 827 // private methods | 851 // private methods |
| 828 //------------------------------------------------------------------------------ | 852 //------------------------------------------------------------------------------ |
| 829 | 853 |
| 830 | 854 |
| 831 //------------------------------------------------------------------------------ | 855 //------------------------------------------------------------------------------ |
| 832 // Initialization methods | 856 // Initialization methods |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 if (local_state) { | 1803 if (local_state) { |
| 1780 const PrefService::Preference* uma_pref = | 1804 const PrefService::Preference* uma_pref = |
| 1781 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1805 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
| 1782 if (uma_pref) { | 1806 if (uma_pref) { |
| 1783 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1807 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
| 1784 DCHECK(success); | 1808 DCHECK(success); |
| 1785 } | 1809 } |
| 1786 } | 1810 } |
| 1787 return result; | 1811 return result; |
| 1788 } | 1812 } |
| OLD | NEW |