OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/metrics/histogram_delta_serialization.h" | 5 #include "base/metrics/histogram_delta_serialization.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram_base.h" | 8 #include "base/metrics/histogram_base.h" |
9 #include "base/metrics/histogram_snapshot_manager.h" | 9 #include "base/metrics/histogram_snapshot_manager.h" |
| 10 #include "base/metrics/statistics_recorder.h" |
10 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
11 #include "base/pickle.h" | 12 #include "base/pickle.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 // Create or find existing histogram and add the samples from pickle. | 19 // Create or find existing histogram and add the samples from pickle. |
19 // Silently returns when seeing any data problem in the pickle. | 20 // Silently returns when seeing any data problem in the pickle. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 inconsistent_snapshot_histogram_ = | 54 inconsistent_snapshot_histogram_ = |
54 Histogram::FactoryGet( | 55 Histogram::FactoryGet( |
55 "Histogram.InconsistentSnapshot" + caller_name, 1, 1000000, 50, | 56 "Histogram.InconsistentSnapshot" + caller_name, 1, 1000000, 50, |
56 HistogramBase::kUmaTargetedHistogramFlag); | 57 HistogramBase::kUmaTargetedHistogramFlag); |
57 } | 58 } |
58 | 59 |
59 HistogramDeltaSerialization::~HistogramDeltaSerialization() { | 60 HistogramDeltaSerialization::~HistogramDeltaSerialization() { |
60 } | 61 } |
61 | 62 |
62 void HistogramDeltaSerialization::PrepareAndSerializeDeltas( | 63 void HistogramDeltaSerialization::PrepareAndSerializeDeltas( |
63 std::vector<std::string>* serialized_deltas) { | 64 std::vector<std::string>* serialized_deltas, |
| 65 bool include_persistent) { |
64 DCHECK(thread_checker_.CalledOnValidThread()); | 66 DCHECK(thread_checker_.CalledOnValidThread()); |
65 | 67 |
66 serialized_deltas_ = serialized_deltas; | 68 serialized_deltas_ = serialized_deltas; |
67 // Note: Before serializing, we set the kIPCSerializationSourceFlag for all | 69 // Note: Before serializing, we set the kIPCSerializationSourceFlag for all |
68 // the histograms, so that the receiving process can distinguish them from the | 70 // the histograms, so that the receiving process can distinguish them from the |
69 // local histograms. | 71 // local histograms. |
70 histogram_snapshot_manager_.PrepareDeltas( | 72 histogram_snapshot_manager_.PrepareDeltas( |
| 73 StatisticsRecorder::begin(include_persistent), StatisticsRecorder::end(), |
71 Histogram::kIPCSerializationSourceFlag, Histogram::kNoFlags); | 74 Histogram::kIPCSerializationSourceFlag, Histogram::kNoFlags); |
72 serialized_deltas_ = NULL; | 75 serialized_deltas_ = NULL; |
73 } | 76 } |
74 | 77 |
75 // static | 78 // static |
76 void HistogramDeltaSerialization::DeserializeAndAddSamples( | 79 void HistogramDeltaSerialization::DeserializeAndAddSamples( |
77 const std::vector<std::string>& serialized_deltas) { | 80 const std::vector<std::string>& serialized_deltas) { |
78 for (std::vector<std::string>::const_iterator it = serialized_deltas.begin(); | 81 for (std::vector<std::string>::const_iterator it = serialized_deltas.begin(); |
79 it != serialized_deltas.end(); ++it) { | 82 it != serialized_deltas.end(); ++it) { |
80 Pickle pickle(it->data(), checked_cast<int>(it->size())); | 83 Pickle pickle(it->data(), checked_cast<int>(it->size())); |
(...skipping 30 matching lines...) Expand all Loading... |
111 } | 114 } |
112 | 115 |
113 void HistogramDeltaSerialization::InconsistencyDetectedInLoggedCount( | 116 void HistogramDeltaSerialization::InconsistencyDetectedInLoggedCount( |
114 int amount) { | 117 int amount) { |
115 DCHECK(thread_checker_.CalledOnValidThread()); | 118 DCHECK(thread_checker_.CalledOnValidThread()); |
116 | 119 |
117 inconsistent_snapshot_histogram_->Add(std::abs(amount)); | 120 inconsistent_snapshot_histogram_->Add(std::abs(amount)); |
118 } | 121 } |
119 | 122 |
120 } // namespace base | 123 } // namespace base |
OLD | NEW |