OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // This file defines a service that collects information about the user | |
6 // experience in order to help improve future versions of the app. | |
7 | |
8 #ifndef CHROME_FRAME_CRASH_METRICS_H_ | |
9 #define CHROME_FRAME_CRASH_METRICS_H_ | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/lazy_instance.h" | |
13 #include "base/thread_local.h" | |
14 | |
15 // This class provides functionality to track counters like successful page | |
16 // loads in the host browser, total number of crashes, page loads in chrome | |
17 // frame. | |
18 class CrashMetricsReporter { | |
19 public: | |
20 enum Metric { | |
21 NAVIGATION_COUNT, | |
22 CRASH_COUNT, | |
23 CHROME_FRAME_NAVIGATION_COUNT, | |
24 SESSION_ID, | |
25 LAST_METRIC, | |
26 }; | |
27 // Returns the global instance of this class. | |
28 static CrashMetricsReporter* GetInstance(); | |
29 | |
30 // The following function pair return/set/increment the specified user | |
31 // metrics value from the registry. These values are set under the | |
32 // following key:- | |
33 // HKCU\Software\\Google\\ChromeFrame\\UserMetrics | |
34 int GetMetric(Metric metric); | |
35 bool SetMetric(Metric metric, int value); | |
36 int IncrementMetric(Metric metric); | |
37 | |
38 // Records the crash metrics counters like navigation count, crash count. | |
39 void RecordCrashMetrics(); | |
40 | |
41 bool active() const { | |
42 return active_; | |
43 } | |
44 | |
45 void set_active(bool active) { | |
46 active_ = active; | |
47 } | |
48 | |
49 private: | |
50 friend struct base::DefaultLazyInstanceTraits<CrashMetricsReporter>; | |
51 | |
52 CrashMetricsReporter() | |
53 : active_(false) {} | |
54 virtual ~CrashMetricsReporter() {} | |
55 | |
56 // Indicates whether the crash metrics reporter instance is active. | |
57 bool active_; | |
58 | |
59 static wchar_t* g_metric_names[LAST_METRIC]; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(CrashMetricsReporter); | |
62 }; | |
63 | |
64 #endif // CHROME_FRAME_CRASH_METRICS_H_ | |
65 | |
OLD | NEW |