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>)> |
| 22 AmortizationCompleteCallback; |
| 23 |
| 24 virtual ~DataUseAmortizer() {} |
| 25 |
| 26 // Amortizes overhead into |data_use|, then passes the it to |callback| once |
| 27 // amortization is complete. Amortizers that perform buffering may combine |
| 28 // together |data_use| objects with the same |callback| if the |data_use| |
| 29 // objects are identical in all ways but their byte counts. |
| 30 virtual void AmortizeDataUse( |
| 31 scoped_ptr<DataUse> data_use, |
| 32 const AmortizationCompleteCallback& callback) = 0; |
| 33 |
| 34 // Notifies the DataUseAmortizer that some extra bytes have been transferred |
| 35 // that aren't associated with any DataUse objects (e.g. off-the-record |
| 36 // traffic). |
| 37 virtual void OnExtraBytes(int64_t extra_tx_bytes, int64_t extra_rx_bytes) = 0; |
| 38 }; |
| 39 |
| 40 } // namespace data_usage |
| 41 |
| 42 #endif // COMPONENTS_DATA_USAGE_CORE_DATA_USE_AMORTIZER_H_ |
OLD | NEW |