OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/data_usage/android/traffic_stats_amortizer.h" | 5 #include "components/data_usage/android/traffic_stats_amortizer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | |
10 #include <string> | 9 #include <string> |
| 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/metrics/histogram_base.h" | 16 #include "base/metrics/histogram_base.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
18 #include "base/test/histogram_tester.h" | 18 #include "base/test/histogram_tester.h" |
19 #include "base/test/simple_test_tick_clock.h" | 19 #include "base/test/simple_test_tick_clock.h" |
20 #include "base/time/tick_clock.h" | 20 #include "base/time/tick_clock.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(MockTimerWithTickClock); | 101 DISALLOW_COPY_AND_ASSIGN(MockTimerWithTickClock); |
102 }; | 102 }; |
103 | 103 |
104 // A TrafficStatsAmortizer for testing that allows for tests to simulate the | 104 // A TrafficStatsAmortizer for testing that allows for tests to simulate the |
105 // byte counts returned from TrafficStats. | 105 // byte counts returned from TrafficStats. |
106 class TestTrafficStatsAmortizer : public TrafficStatsAmortizer { | 106 class TestTrafficStatsAmortizer : public TrafficStatsAmortizer { |
107 public: | 107 public: |
108 TestTrafficStatsAmortizer(scoped_ptr<base::TickClock> tick_clock, | 108 TestTrafficStatsAmortizer(scoped_ptr<base::TickClock> tick_clock, |
109 scoped_ptr<base::Timer> traffic_stats_query_timer) | 109 scoped_ptr<base::Timer> traffic_stats_query_timer) |
110 : TrafficStatsAmortizer(tick_clock.Pass(), | 110 : TrafficStatsAmortizer(std::move(tick_clock), |
111 traffic_stats_query_timer.Pass(), | 111 std::move(traffic_stats_query_timer), |
112 kTrafficStatsQueryDelay, | 112 kTrafficStatsQueryDelay, |
113 kMaxAmortizationDelay, | 113 kMaxAmortizationDelay, |
114 kMaxDataUseBufferSize), | 114 kMaxDataUseBufferSize), |
115 next_traffic_stats_available_(false), | 115 next_traffic_stats_available_(false), |
116 next_traffic_stats_tx_bytes_(-1), | 116 next_traffic_stats_tx_bytes_(-1), |
117 next_traffic_stats_rx_bytes_(-1) {} | 117 next_traffic_stats_rx_bytes_(-1) {} |
118 | 118 |
119 ~TestTrafficStatsAmortizer() override {} | 119 ~TestTrafficStatsAmortizer() override {} |
120 | 120 |
121 void SetNextTrafficStats(bool available, int64_t tx_bytes, int64_t rx_bytes) { | 121 void SetNextTrafficStats(bool available, int64_t tx_bytes, int64_t rx_bytes) { |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 1000 * kExpectedBufSize, 1); | 669 1000 * kExpectedBufSize, 1); |
670 histogram_tester.ExpectUniqueSample(kAmortizationDelayHistogram, 0, 1); | 670 histogram_tester.ExpectUniqueSample(kAmortizationDelayHistogram, 0, 1); |
671 histogram_tester.ExpectUniqueSample(kBufferSizeOnFlushHistogram, | 671 histogram_tester.ExpectUniqueSample(kBufferSizeOnFlushHistogram, |
672 kExpectedBufSize, 1); | 672 kExpectedBufSize, 1); |
673 } | 673 } |
674 | 674 |
675 } // namespace | 675 } // namespace |
676 | 676 |
677 } // namespace android | 677 } // namespace android |
678 } // namespace data_usage | 678 } // namespace data_usage |
OLD | NEW |