OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 #include "components/metrics/histogram_manager.h" | |
6 | |
7 #include <string> | |
8 #include <vector> | |
9 | |
10 #include "base/memory/singleton.h" | |
11 #include "base/metrics/histogram.h" | |
12 #include "base/metrics/histogram_samples.h" | |
13 #include "components/metrics/histogram_encoder.h" | |
14 | |
15 namespace metrics { | |
16 | |
17 HistogramManager::HistogramManager() : histogram_snapshot_manager_(this) { | |
18 } | |
19 | |
20 HistogramManager::~HistogramManager() { | |
21 } | |
22 | |
23 // static | |
24 HistogramManager* HistogramManager::GetInstance() { | |
25 return Singleton<HistogramManager>::get(); | |
26 } | |
27 | |
28 void HistogramManager::RecordDelta(const base::HistogramBase& histogram, | |
29 const base::HistogramSamples& snapshot) { | |
30 EncodeHistogramDelta(histogram.histogram_name(), snapshot, &uma_proto_); | |
31 } | |
32 | |
33 void HistogramManager::InconsistencyDetected( | |
34 base::HistogramBase::Inconsistency problem) { | |
35 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowser.Cronet", | |
36 problem, base::HistogramBase::NEVER_EXCEEDED_VALUE); | |
37 } | |
38 | |
39 void HistogramManager::UniqueInconsistencyDetected( | |
40 base::HistogramBase::Inconsistency problem) { | |
41 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique.Cronet", | |
42 problem, base::HistogramBase::NEVER_EXCEEDED_VALUE); | |
43 } | |
44 | |
45 void HistogramManager::InconsistencyDetectedInLoggedCount(int amount) { | |
46 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser.Cronet", | |
47 std::abs(amount)); | |
48 } | |
49 | |
50 std::vector<uint8> HistogramManager::GetDeltas() { | |
mef
2014/12/11 23:11:41
should this be HistogramManager::GetDeltas(std::ve
ramant (doing other things)
2014/12/12 02:43:05
Done.
| |
51 // Clear the protobuf between calls. | |
52 uma_proto_.Clear(); | |
53 histogram_snapshot_manager_.PrepareDeltas( | |
54 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); | |
55 int32_t data_size = uma_proto_.ByteSize(); | |
56 std::vector<uint8> data(data_size); | |
57 if (!uma_proto_.SerializeToArray(&data[0], data_size)) { | |
58 data.clear(); | |
59 } | |
60 return data; | |
61 } | |
62 | |
63 } // namespace metrics | |
OLD | NEW |