OLD | NEW |
| (Empty) |
1 // Copyright 2006-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 // | |
16 // Win32 aggregator, which aggregates counters to registry under a named | |
17 // Mutex lock. | |
18 #ifndef OMAHA_STATSREPORT_AGGREGATOR_WIN32_H__ | |
19 #define OMAHA_STATSREPORT_AGGREGATOR_WIN32_H__ | |
20 | |
21 #include "aggregator.h" | |
22 #include <atlbase.h> | |
23 #include <atlstr.h> | |
24 | |
25 namespace stats_report { | |
26 | |
27 class MetricsAggregatorWin32: public MetricsAggregator { | |
28 public: | |
29 /// @param coll the metrics collection to aggregate, most usually this | |
30 /// is g_global_metrics. | |
31 /// @param app_name name of the subkey under HKCU\Software\Google we | |
32 /// aggregate to. | |
33 MetricsAggregatorWin32(MetricCollection &coll, | |
34 const wchar_t *app_name); | |
35 | |
36 /// @param is_machine specifies the registry hive where the stats are | |
37 /// aggregated to. | |
38 MetricsAggregatorWin32(MetricCollection &coll, | |
39 const wchar_t *app_name, | |
40 bool is_machine); | |
41 virtual ~MetricsAggregatorWin32(); | |
42 | |
43 protected: | |
44 virtual bool StartAggregation(); | |
45 virtual void EndAggregation(); | |
46 | |
47 virtual void Aggregate(CountMetric &metric); | |
48 virtual void Aggregate(TimingMetric &metric); | |
49 virtual void Aggregate(IntegerMetric &metric); | |
50 virtual void Aggregate(BoolMetric &metric); | |
51 private: | |
52 enum { | |
53 /// Max length of time we wait for the mutex on StartAggregation. | |
54 kMaxMutexWaitMs = 1000, // 1 second for now | |
55 }; | |
56 | |
57 /// Ensures that *key is open, opening it if it's NULL | |
58 /// @return true on success, false on failure to open key | |
59 bool EnsureKey(const wchar_t *name, CRegKey *key); | |
60 | |
61 /// Mutex name for locking access to key | |
62 CString mutex_name_; | |
63 | |
64 /// Subkey name, as per constructor docs | |
65 CString key_name_; | |
66 | |
67 /// Handle to our subkey under HKCU\Software\Google | |
68 CRegKey key_; | |
69 | |
70 /// Subkeys under the above | |
71 /// @{ | |
72 CRegKey count_key_; | |
73 CRegKey timing_key_; | |
74 CRegKey integer_key_; | |
75 CRegKey bool_key_; | |
76 /// @} | |
77 | |
78 /// Specifies HKLM or HKCU, respectively. | |
79 bool is_machine_; | |
80 | |
81 DISALLOW_EVIL_CONSTRUCTORS(MetricsAggregatorWin32); | |
82 }; | |
83 | |
84 } // namespace stats_report | |
85 | |
86 #endif // OMAHA_STATSREPORT_AGGREGATOR_WIN32_H__ | |
OLD | NEW |