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

Unified Diff: components/data_usage/core/data_use_aggregator.h

Issue 1456793003: Re-use callback objects in the DataUseAggregator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed WeakPtr threading issue. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/data_usage/core/data_use_aggregator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 50bb36ede988215a42fb9fa319bbc95d7da95735..54d4819cc09f52425e7784fc88223c728979373f 100644
--- a/components/data_usage/core/data_use_aggregator.h
+++ b/components/data_usage/core/data_use_aggregator.h
@@ -15,6 +15,8 @@
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/threading/thread_checker.h"
+#include "components/data_usage/core/data_use_amortizer.h"
+#include "components/data_usage/core/data_use_annotator.h"
#include "net/base/network_change_notifier.h"
namespace net {
@@ -23,8 +25,6 @@ class URLRequest;
namespace data_usage {
-class DataUseAmortizer;
-class DataUseAnnotator;
struct DataUse;
// Class that collects and aggregates network usage, reporting the usage to
@@ -96,6 +96,12 @@ class DataUseAggregator
// even if the current active network is not a cellular network.
std::string mcc_mnc_;
+ // As an optimization, re-use the same callbacks to avoid creating and
+ // allocating a new Callback object for each call into the |annotator_| or
+ // |amortizer_|. These callbacks are lazily initialized.
+ DataUseAnnotator::DataUseConsumerCallback annotation_callback_;
+ DataUseAmortizer::AmortizationCompleteCallback amortization_callback_;
+
base::WeakPtrFactory<DataUseAggregator> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DataUseAggregator);
« no previous file with comments | « no previous file | components/data_usage/core/data_use_aggregator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698