OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/cronet/histogram_manager.h" | 5 #include "components/cronet/histogram_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/metrics/histogram_samples.h" | 12 #include "base/metrics/histogram_samples.h" |
| 13 #include "base/metrics/statistics_recorder.h" |
13 #include "components/metrics/histogram_encoder.h" | 14 #include "components/metrics/histogram_encoder.h" |
14 | 15 |
15 namespace cronet { | 16 namespace cronet { |
16 | 17 |
17 // TODO(rtenneti): move g_histogram_manager into java code. | 18 // TODO(rtenneti): move g_histogram_manager into java code. |
18 static base::LazyInstance<HistogramManager>::Leaky | 19 static base::LazyInstance<HistogramManager>::Leaky |
19 g_histogram_manager = LAZY_INSTANCE_INITIALIZER; | 20 g_histogram_manager = LAZY_INSTANCE_INITIALIZER; |
20 | 21 |
21 HistogramManager::HistogramManager() : histogram_snapshot_manager_(this) { | 22 HistogramManager::HistogramManager() : histogram_snapshot_manager_(this) { |
22 } | 23 } |
(...skipping 24 matching lines...) Expand all Loading... |
47 } | 48 } |
48 | 49 |
49 void HistogramManager::InconsistencyDetectedInLoggedCount(int amount) { | 50 void HistogramManager::InconsistencyDetectedInLoggedCount(int amount) { |
50 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser.Cronet", | 51 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser.Cronet", |
51 std::abs(amount)); | 52 std::abs(amount)); |
52 } | 53 } |
53 | 54 |
54 bool HistogramManager::GetDeltas(std::vector<uint8_t>* data) { | 55 bool HistogramManager::GetDeltas(std::vector<uint8_t>* data) { |
55 // Clear the protobuf between calls. | 56 // Clear the protobuf between calls. |
56 uma_proto_.Clear(); | 57 uma_proto_.Clear(); |
| 58 // "false" to StatisticsRecorder::begin() indicates to *not* include |
| 59 // histograms held in persistent storage on the assumption that they will be |
| 60 // visible to the recipient through other means. |
57 histogram_snapshot_manager_.PrepareDeltas( | 61 histogram_snapshot_manager_.PrepareDeltas( |
| 62 base::StatisticsRecorder::begin(false), base::StatisticsRecorder::end(), |
58 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); | 63 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); |
59 int32_t data_size = uma_proto_.ByteSize(); | 64 int32_t data_size = uma_proto_.ByteSize(); |
60 data->resize(data_size); | 65 data->resize(data_size); |
61 if (uma_proto_.SerializeToArray(&(*data)[0], data_size)) | 66 if (uma_proto_.SerializeToArray(&(*data)[0], data_size)) |
62 return true; | 67 return true; |
63 data->clear(); | 68 data->clear(); |
64 return false; | 69 return false; |
65 } | 70 } |
66 | 71 |
67 } // namespace cronet | 72 } // namespace cronet |
OLD | NEW |