Index: components/data_usage/core/data_use_aggregator.h |
diff --git a/components/data_usage/core/data_use_aggregator.h b/components/data_usage/core/data_use_aggregator.h |
index 36d8ef09016c01c11fa1e8f58ae2af1b21cd7f50..50bb36ede988215a42fb9fa319bbc95d7da95735 100644 |
--- a/components/data_usage/core/data_use_aggregator.h |
+++ b/components/data_usage/core/data_use_aggregator.h |
@@ -12,7 +12,6 @@ |
#include "base/macros.h" |
#include "base/memory/scoped_ptr.h" |
-#include "base/memory/scoped_vector.h" |
#include "base/memory/weak_ptr.h" |
#include "base/observer_list.h" |
#include "base/threading/thread_checker.h" |
@@ -24,6 +23,7 @@ class URLRequest; |
namespace data_usage { |
+class DataUseAmortizer; |
class DataUseAnnotator; |
struct DataUse; |
@@ -41,9 +41,12 @@ class DataUseAggregator |
const std::vector<const DataUse*>& data_use_sequence) = 0; |
}; |
- // Constructs a new DataUseAggregator with the given |annotator|. A NULL |
- // annotator will be treated as a no-op annotator. |
- explicit DataUseAggregator(scoped_ptr<DataUseAnnotator> annotator); |
+ // Constructs a new DataUseAggregator with the given |annotator| and |
+ // |amortizer|. A NULL |annotator| will be treated as a no-op annotator, and a |
+ // NULL |amortizer| will be treated as a no-op amortizer. |
+ DataUseAggregator(scoped_ptr<DataUseAnnotator> annotator, |
+ scoped_ptr<DataUseAmortizer> amortizer); |
+ |
~DataUseAggregator() override; |
void AddObserver(Observer* observer); |
@@ -73,20 +76,18 @@ class DataUseAggregator |
void SetMccMncForTests(const std::string& mcc_mnc); |
private: |
- // Appends |data_use| to the buffer of unreported data use and prepares to |
- // notify observers. |
- void AppendDataUse(scoped_ptr<DataUse> data_use); |
+ // Passes |data_use| to |amortizer_| if it exists, or calls |
+ // OnAmortizationComplete directly if |amortizer_| doesn't exist. |
+ void PassDataUseToAmortizer(scoped_ptr<DataUse> data_use); |
- // Flush any buffered data use and notify observers. |
- void FlushBufferedDataUse(); |
+ // Notifies observers with the data use from |amortized_data_use|. |
+ void OnAmortizationComplete(scoped_ptr<DataUse> amortized_data_use); |
base::ThreadChecker thread_checker_; |
scoped_ptr<DataUseAnnotator> annotator_; |
+ scoped_ptr<DataUseAmortizer> amortizer_; |
base::ObserverList<Observer> observer_list_; |
- // Buffer of unreported data use. |
- ScopedVector<DataUse> buffered_data_use_; |
- |
// Current connection type as notified by NetworkChangeNotifier. |
net::NetworkChangeNotifier::ConnectionType connection_type_; |
@@ -95,15 +96,6 @@ class DataUseAggregator |
// even if the current active network is not a cellular network. |
std::string mcc_mnc_; |
- // The total amount of off-the-record data usage that has happened since the |
- // last time the buffer was flushed. |
- int64_t off_the_record_tx_bytes_since_last_flush_; |
- int64_t off_the_record_rx_bytes_since_last_flush_; |
- |
- // Indicates if a FlushBufferedDataUse() callback has been posted to run later |
- // on the IO thread. |
- bool is_flush_pending_; |
- |
base::WeakPtrFactory<DataUseAggregator> weak_ptr_factory_; |
DISALLOW_COPY_AND_ASSIGN(DataUseAggregator); |