Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_DATA_USAGE_ANDROID_TRAFFIC_STATS_AMORTIZER_H_ | |
| 6 #define COMPONENTS_DATA_USAGE_ANDROID_TRAFFIC_STATS_AMORTIZER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "base/threading/thread_checker.h" | |
| 14 #include "components/data_usage/core/data_use.h" | |
| 15 #include "components/data_usage/core/data_use_amortizer.h" | |
| 16 | |
| 17 namespace data_usage { | |
| 18 namespace android { | |
| 19 | |
| 20 // Class that uses Android TrafficStats to amortize the data usage stats | |
| 21 // produced by the network stack. Should only be used on the IO thread. | |
| 22 class TrafficStatsAmortizer : public DataUseAmortizer { | |
| 23 public: | |
| 24 TrafficStatsAmortizer(); | |
| 25 ~TrafficStatsAmortizer() override; | |
| 26 | |
| 27 void Amortize(std::vector<DataUse>* data_use_sequence, | |
| 28 int64_t extra_tx_bytes, | |
| 29 int64_t extra_rx_bytes) override; | |
| 30 | |
| 31 protected: | |
| 32 // Virtual for testing. | |
| 33 virtual bool GetTrafficStatsTxBytes(int64_t* tx_bytes) const; | |
| 34 // Virtual for testing. | |
| 35 virtual bool GetTrafficStatsRxBytes(int64_t* rx_bytes) const; | |
| 36 | |
| 37 private: | |
| 38 void RefreshTrafficStats(); | |
| 39 | |
| 40 base::ThreadChecker thread_checker_; | |
| 41 | |
| 42 // Indicates whether or not |traffic_stats_tx_bytes_| and | |
| 43 // |traffic_stats_rx_bytes_| were available the last time they were refreshed. | |
| 44 bool are_traffic_stats_available_; | |
|
bengr
2015/10/12 21:33:08
were_... ?
| |
| 45 | |
| 46 int64_t traffic_stats_tx_bytes_; | |
| 47 int64_t traffic_stats_rx_bytes_; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(TrafficStatsAmortizer); | |
| 50 }; | |
| 51 | |
| 52 } // namespace android | |
| 53 } // namespace data_usage | |
| 54 | |
| 55 #endif // COMPONENTS_DATA_USAGE_ANDROID_TRAFFIC_STATS_AMORTIZER_H_ | |
| OLD | NEW |