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

Unified Diff: chrome_frame/crash_metrics.cc

Issue 2776010: Move the crash metrics to the crash reproting lib to avoid a back dependency ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_frame/crash_metrics.h ('k') | chrome_frame/crash_reporting/crash_metrics.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/crash_metrics.cc
===================================================================
--- chrome_frame/crash_metrics.cc (revision 49520)
+++ chrome_frame/crash_metrics.cc (working copy)
@@ -1,92 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome_frame/crash_metrics.h"
-
-#include "base/histogram.h"
-#include "base/registry.h"
-#include "chrome_frame/utils.h"
-
-static const wchar_t kChromeFrameMetricsKey[] =
- L"Software\\Google\\ChromeFrameMetrics";
-
-base::LazyInstance<CrashMetricsReporter>
- g_crash_metrics_instance_(base::LINKER_INITIALIZED);
-
-wchar_t* CrashMetricsReporter::g_metric_names[LAST_METRIC] = {
- L"navigationcount",
- L"crashcount",
- L"chrome_frame_navigationcount",
- L"sessionid",
-};
-
-CrashMetricsReporter* CrashMetricsReporter::GetInstance() {
- return &g_crash_metrics_instance_.Get();
-}
-
-bool CrashMetricsReporter::SetMetric(Metric metric, int value) {
- DCHECK(metric >= NAVIGATION_COUNT && metric <= LAST_METRIC);
-
- RegKey metric_key;
- if (metric_key.Create(HKEY_CURRENT_USER, kChromeFrameMetricsKey,
- KEY_SET_VALUE)) {
- if (metric_key.WriteValue(g_metric_names[metric], value)) {
- return true;
- } else {
- DLOG(ERROR) << "Failed to read ChromeFrame metric:"
- << g_metric_names[metric];
- }
- } else {
- DLOG(ERROR) << "Failed to create ChromeFrame metrics key";
- }
- return false;
-}
-
-int CrashMetricsReporter::GetMetric(Metric metric) {
- DCHECK(metric >= NAVIGATION_COUNT && metric <= LAST_METRIC);
-
- int ret = 0;
- RegKey metric_key;
- if (metric_key.Open(HKEY_CURRENT_USER, kChromeFrameMetricsKey,
- KEY_QUERY_VALUE)) {
- int value = 0;
- if (metric_key.ReadValueDW(g_metric_names[metric],
- reinterpret_cast<DWORD*>(&value))) {
- ret = value;
- }
- }
- return ret;
-}
-
-int CrashMetricsReporter::IncrementMetric(Metric metric) {
- DCHECK(metric >= NAVIGATION_COUNT && metric <= LAST_METRIC);
- int metric_value = GetMetric(metric);
- metric_value++;
- SetMetric(metric, metric_value);
- return metric_value;
-}
-
-void CrashMetricsReporter::RecordCrashMetrics() {
- int navigation_count = GetMetric(NAVIGATION_COUNT);
- if (navigation_count > 0) {
- THREAD_SAFE_UMA_HISTOGRAM_COUNTS("ChromeFrame.HostNavigationCount",
- navigation_count);
- SetMetric(NAVIGATION_COUNT, 0);
- }
-
- int chrome_frame_navigation_count = GetMetric(CHROME_FRAME_NAVIGATION_COUNT);
- if (chrome_frame_navigation_count > 0) {
- THREAD_SAFE_UMA_HISTOGRAM_COUNTS("ChromeFrame.CFNavigationCount",
- chrome_frame_navigation_count);
- SetMetric(CHROME_FRAME_NAVIGATION_COUNT, 0);
- }
-
- int crash_count = GetMetric(CRASH_COUNT);
- if (crash_count > 0) {
- THREAD_SAFE_UMA_HISTOGRAM_COUNTS("ChromeFrame.HostCrashCount",
- crash_count);
- SetMetric(CRASH_COUNT, 0);
- }
-}
-
« no previous file with comments | « chrome_frame/crash_metrics.h ('k') | chrome_frame/crash_reporting/crash_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698