Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: components/data_usage/core/data_use_amortizer.h

Issue 1390993005: Amortize data usage using TrafficStats on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_use_buffering
Patch Set: Fixed nit Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698