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 // Implementation of helper classes to aggregate the collected in-memory | |
17 // stats to persistent storage. | |
18 #include "aggregator.h" | |
19 | |
20 namespace stats_report { | |
21 | |
22 bool MetricsAggregator::AggregateMetrics() { | |
23 if (!StartAggregation()) | |
24 return false; | |
25 | |
26 MetricIterator it(coll_), end; | |
27 for (; it != end; ++it) { | |
28 MetricBase *metric = *it; | |
29 DCHECK(NULL != metric); | |
30 | |
31 switch (metric->type()) { | |
32 case kCountType: | |
33 Aggregate(metric->AsCount()); | |
34 break; | |
35 case kTimingType: | |
36 Aggregate(metric->AsTiming()); | |
37 break; | |
38 case kIntegerType: | |
39 Aggregate(metric->AsInteger()); | |
40 break; | |
41 case kBoolType: | |
42 Aggregate(metric->AsBool()); | |
43 break; | |
44 default: | |
45 DCHECK(false && "Impossible metric type"); | |
46 break; | |
47 } | |
48 } | |
49 | |
50 // done, close up | |
51 EndAggregation(); | |
52 | |
53 return true; | |
54 } | |
55 | |
56 MetricsAggregator::MetricsAggregator() : coll_(g_global_metrics) { | |
57 DCHECK(coll_.initialized()); | |
58 } | |
59 | |
60 MetricsAggregator::MetricsAggregator(const MetricCollection &coll) | |
61 : coll_(coll) { | |
62 DCHECK(coll_.initialized()); | |
63 } | |
64 | |
65 MetricsAggregator::~MetricsAggregator() { | |
66 } | |
67 | |
68 bool MetricsAggregator::StartAggregation() { | |
69 // nothing | |
70 return true; | |
71 } | |
72 | |
73 void MetricsAggregator::EndAggregation() { | |
74 // nothing | |
75 } | |
76 | |
77 } // namespace stats_report | |
OLD | NEW |