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 "chrome/browser/chromeos/net/network_portal_detector_test_utils.h" | 5 #include "chrome/browser/chromeos/net/network_portal_detector_test_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> |
10 | 11 |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/metrics/histogram_base.h" | 13 #include "base/metrics/histogram_base.h" |
14 #include "base/metrics/histogram_samples.h" | 14 #include "base/metrics/histogram_samples.h" |
15 #include "base/metrics/statistics_recorder.h" | 15 #include "base/metrics/statistics_recorder.h" |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 | 18 |
19 EnumHistogramChecker::EnumHistogramChecker(const std::string& histogram, | 19 EnumHistogramChecker::EnumHistogramChecker(const std::string& histogram, |
20 int count, | 20 int count, |
21 base::HistogramSamples* base) | 21 base::HistogramSamples* base) |
22 : histogram_(histogram), expect_(count), base_(base) {} | 22 : histogram_(histogram), expect_(count), base_(base) {} |
(...skipping 14 matching lines...) Expand all Loading... |
37 base::HistogramBase* histogram = | 37 base::HistogramBase* histogram = |
38 base::StatisticsRecorder::FindHistogram(histogram_); | 38 base::StatisticsRecorder::FindHistogram(histogram_); |
39 if (!histogram) { | 39 if (!histogram) { |
40 if (!empty) { | 40 if (!empty) { |
41 LOG(ERROR) << "Non-empty expectations for " << histogram_ << " " | 41 LOG(ERROR) << "Non-empty expectations for " << histogram_ << " " |
42 << "which does not exists."; | 42 << "which does not exists."; |
43 return false; | 43 return false; |
44 } | 44 } |
45 return true; | 45 return true; |
46 } | 46 } |
47 scoped_ptr<base::HistogramSamples> samples = histogram->SnapshotSamples(); | 47 std::unique_ptr<base::HistogramSamples> samples = |
| 48 histogram->SnapshotSamples(); |
48 if (!samples.get()) { | 49 if (!samples.get()) { |
49 if (!empty) { | 50 if (!empty) { |
50 LOG(ERROR) << "Non-empty expectations for " << histogram_ << " " | 51 LOG(ERROR) << "Non-empty expectations for " << histogram_ << " " |
51 << "for which samples do not exist."; | 52 << "for which samples do not exist."; |
52 return false; | 53 return false; |
53 } | 54 } |
54 return true; | 55 return true; |
55 } | 56 } |
56 | 57 |
57 bool ok = true; | 58 bool ok = true; |
58 for (size_t i = 0; i < expect_.size(); ++i) { | 59 for (size_t i = 0; i < expect_.size(); ++i) { |
59 const int base = base_ ? base_->GetCount(i) : 0; | 60 const int base = base_ ? base_->GetCount(i) : 0; |
60 const int actual = samples->GetCount(i) - base; | 61 const int actual = samples->GetCount(i) - base; |
61 if (actual != expect_[i]) { | 62 if (actual != expect_[i]) { |
62 LOG(ERROR) << "Histogram: " << histogram_ << ", value #" << i << ", " | 63 LOG(ERROR) << "Histogram: " << histogram_ << ", value #" << i << ", " |
63 << "expected: " << expect_[i] << ", actual: " << actual; | 64 << "expected: " << expect_[i] << ", actual: " << actual; |
64 ok = false; | 65 ok = false; |
65 } | 66 } |
66 } | 67 } |
67 return ok; | 68 return ok; |
68 } | 69 } |
69 | 70 |
70 } // namespace chromeos | 71 } // namespace chromeos |
OLD | NEW |