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_CORE_DATA_USE_AMORTIZER_H_ | |
| 6 #define COMPONENTS_DATA_USAGE_CORE_DATA_USE_AMORTIZER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 | |
| 13 namespace data_usage { | |
| 14 | |
| 15 struct DataUse; | |
| 16 | |
| 17 // Class that takes in DataUse and amortizes any extra data usage overhead | |
| 18 // across DataUse objects. | |
| 19 class DataUseAmortizer { | |
| 20 public: | |
| 21 typedef base::Callback<void(scoped_ptr<DataUse>)> DataUseConsumerCallback; | |
| 22 | |
| 23 virtual ~DataUseAmortizer() {} | |
| 24 | |
| 25 // Amortizes overhead into |data_use|, then passes the it to |callback| once | |
| 26 // amortization is complete. Amortizers that perform buffering may combine | |
| 27 // together |data_use| objects with the same |callback| if the |data_use| | |
| 28 // objects are identical in all ways but their byte counts. | |
| 29 virtual void AmortizeDataUse(scoped_ptr<DataUse> data_use, | |
| 30 const DataUseConsumerCallback& callback) = 0; | |
| 31 | |
| 32 // Notifies the DataUseAmortizer that some extra bytes have happened that | |
|
bengr
2015/11/10 18:12:51
Be clearer than "have happened."
sclittle
2015/11/11 02:10:08
Done.
| |
| 33 // aren't associated with any DataUse objects (e.g. off-the-record traffic). | |
| 34 virtual void OnExtraBytes(int64_t extra_tx_bytes, int64_t extra_rx_bytes) = 0; | |
| 35 }; | |
| 36 | |
| 37 } // namespace data_usage | |
| 38 | |
| 39 #endif // COMPONENTS_DATA_USAGE_CORE_DATA_USE_AMORTIZER_H_ | |
| OLD | NEW |