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

Side by Side Diff: chrome_frame/crash_reporting/crash_metrics.cc

Issue 3836005: Move pe_image and registry from base to base/win and use the namespace. It re... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome_frame/chrome_tab.cc ('k') | chrome_frame/policy_settings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome_frame/crash_reporting/crash_metrics.h" 5 #include "chrome_frame/crash_reporting/crash_metrics.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/registry.h" 8 #include "base/win/registry.h"
9 #include "chrome_frame/utils.h" 9 #include "chrome_frame/utils.h"
10 10
11 static const wchar_t kChromeFrameMetricsKey[] = 11 static const wchar_t kChromeFrameMetricsKey[] =
12 L"Software\\Google\\ChromeFrameMetrics"; 12 L"Software\\Google\\ChromeFrameMetrics";
13 13
14 base::LazyInstance<CrashMetricsReporter> 14 base::LazyInstance<CrashMetricsReporter>
15 g_crash_metrics_instance_(base::LINKER_INITIALIZED); 15 g_crash_metrics_instance_(base::LINKER_INITIALIZED);
16 16
17 wchar_t* CrashMetricsReporter::g_metric_names[LAST_METRIC] = { 17 wchar_t* CrashMetricsReporter::g_metric_names[LAST_METRIC] = {
18 L"navigationcount", 18 L"navigationcount",
19 L"crashcount", 19 L"crashcount",
20 L"chrome_frame_navigationcount", 20 L"chrome_frame_navigationcount",
21 L"sessionid", 21 L"sessionid",
22 }; 22 };
23 23
24 CrashMetricsReporter* CrashMetricsReporter::GetInstance() { 24 CrashMetricsReporter* CrashMetricsReporter::GetInstance() {
25 return &g_crash_metrics_instance_.Get(); 25 return &g_crash_metrics_instance_.Get();
26 } 26 }
27 27
28 bool CrashMetricsReporter::SetMetric(Metric metric, int value) { 28 bool CrashMetricsReporter::SetMetric(Metric metric, int value) {
29 DCHECK(metric >= NAVIGATION_COUNT && metric <= LAST_METRIC); 29 DCHECK(metric >= NAVIGATION_COUNT && metric <= LAST_METRIC);
30 30
31 RegKey metric_key; 31 base::win::RegKey metric_key;
32 if (metric_key.Create(HKEY_CURRENT_USER, kChromeFrameMetricsKey, 32 if (metric_key.Create(HKEY_CURRENT_USER, kChromeFrameMetricsKey,
33 KEY_SET_VALUE)) { 33 KEY_SET_VALUE)) {
34 if (metric_key.WriteValue(g_metric_names[metric], value)) { 34 if (metric_key.WriteValue(g_metric_names[metric], value)) {
35 return true; 35 return true;
36 } else { 36 } else {
37 DLOG(ERROR) << "Failed to read ChromeFrame metric:" 37 DLOG(ERROR) << "Failed to read ChromeFrame metric:"
38 << g_metric_names[metric]; 38 << g_metric_names[metric];
39 } 39 }
40 } else { 40 } else {
41 DLOG(ERROR) << "Failed to create ChromeFrame metrics key"; 41 DLOG(ERROR) << "Failed to create ChromeFrame metrics key";
42 } 42 }
43 return false; 43 return false;
44 } 44 }
45 45
46 int CrashMetricsReporter::GetMetric(Metric metric) { 46 int CrashMetricsReporter::GetMetric(Metric metric) {
47 DCHECK(metric >= NAVIGATION_COUNT && metric <= LAST_METRIC); 47 DCHECK(metric >= NAVIGATION_COUNT && metric <= LAST_METRIC);
48 48
49 int ret = 0; 49 int ret = 0;
50 RegKey metric_key; 50 base::win::RegKey metric_key;
51 if (metric_key.Open(HKEY_CURRENT_USER, kChromeFrameMetricsKey, 51 if (metric_key.Open(HKEY_CURRENT_USER, kChromeFrameMetricsKey,
52 KEY_QUERY_VALUE)) { 52 KEY_QUERY_VALUE)) {
53 int value = 0; 53 int value = 0;
54 if (metric_key.ReadValueDW(g_metric_names[metric], 54 if (metric_key.ReadValueDW(g_metric_names[metric],
55 reinterpret_cast<DWORD*>(&value))) { 55 reinterpret_cast<DWORD*>(&value))) {
56 ret = value; 56 ret = value;
57 } 57 }
58 } 58 }
59 return ret; 59 return ret;
60 } 60 }
(...skipping 22 matching lines...) Expand all
83 } 83 }
84 84
85 int crash_count = GetMetric(CRASH_COUNT); 85 int crash_count = GetMetric(CRASH_COUNT);
86 if (crash_count > 0) { 86 if (crash_count > 0) {
87 THREAD_SAFE_UMA_HISTOGRAM_COUNTS("ChromeFrame.HostCrashCount", 87 THREAD_SAFE_UMA_HISTOGRAM_COUNTS("ChromeFrame.HostCrashCount",
88 crash_count); 88 crash_count);
89 SetMetric(CRASH_COUNT, 0); 89 SetMetric(CRASH_COUNT, 0);
90 } 90 }
91 } 91 }
92 92
OLDNEW
« no previous file with comments | « chrome_frame/chrome_tab.cc ('k') | chrome_frame/policy_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698