| 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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique.Cronet", | 46 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique.Cronet", |
| 47 problem, base::HistogramBase::NEVER_EXCEEDED_VALUE); | 47 problem, base::HistogramBase::NEVER_EXCEEDED_VALUE); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void HistogramManager::InconsistencyDetectedInLoggedCount(int amount) { | 50 void HistogramManager::InconsistencyDetectedInLoggedCount(int amount) { |
| 51 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser.Cronet", | 51 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser.Cronet", |
| 52 std::abs(amount)); | 52 std::abs(amount)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool HistogramManager::GetDeltas(std::vector<uint8_t>* data) { | 55 bool HistogramManager::GetDeltas(std::vector<uint8_t>* data) { |
| 56 // Clear the protobuf between calls. | 56 if (get_deltas_lock_.Try()) { |
| 57 uma_proto_.Clear(); | 57 base::AutoLock lock(get_deltas_lock_, base::AutoLock::AlreadyAcquired()); |
| 58 // "false" to StatisticsRecorder::begin() indicates to *not* include | 58 // Clear the protobuf between calls. |
| 59 // histograms held in persistent storage on the assumption that they will be | 59 uma_proto_.Clear(); |
| 60 // visible to the recipient through other means. | 60 // "false" to StatisticsRecorder::begin() indicates to *not* include |
| 61 histogram_snapshot_manager_.PrepareDeltas( | 61 // histograms held in persistent storage on the assumption that they will be |
| 62 base::StatisticsRecorder::begin(false), base::StatisticsRecorder::end(), | 62 // visible to the recipient through other means. |
| 63 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); | 63 histogram_snapshot_manager_.PrepareDeltas( |
| 64 int32_t data_size = uma_proto_.ByteSize(); | 64 base::StatisticsRecorder::begin(false), base::StatisticsRecorder::end(), |
| 65 data->resize(data_size); | 65 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); |
| 66 if (uma_proto_.SerializeToArray(&(*data)[0], data_size)) | 66 int32_t data_size = uma_proto_.ByteSize(); |
| 67 return true; | 67 data->resize(data_size); |
| 68 if (uma_proto_.SerializeToArray(&(*data)[0], data_size)) |
| 69 return true; |
| 70 } |
| 68 data->clear(); | 71 data->clear(); |
| 69 return false; | 72 return false; |
| 70 } | 73 } |
| 71 | 74 |
| 72 } // namespace cronet | 75 } // namespace cronet |
| OLD | NEW |