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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h

Issue 778463002: Wrapped data reduction proxy initialization into its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@network-delegate
Patch Set: Updated test Created 5 years, 11 months 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
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h
index 33502e9c1896a5ddf9c4e2d91c335ad7be56751f..5e159e7e66ac9f431c177a635b734b0cba5ca258 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h
@@ -6,8 +6,8 @@
#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_USAGE_STATS_H_
#include "base/callback.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/prefs/pref_member.h"
+#include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
@@ -23,6 +23,9 @@ class ProxyServer;
namespace data_reduction_proxy {
+class DataReductionProxySettings;
+
+// TODO(bengr): Rename as DataReductionProxyBypassStats.
class DataReductionProxyUsageStats
: public net::NetworkChangeNotifier::NetworkChangeObserver {
public:
@@ -42,22 +45,19 @@ class DataReductionProxyUsageStats
bool is_primary,
const net::HttpResponseHeaders* headers);
- // MessageLoopProxy instance is owned by io_thread. |params| outlives
- // this class instance.
+ // |params| outlives this class instance. |settings| provides a hook to inform
+ // the user that the Data Reduction Proxy is unreachable, which occurs on the
+ // UI thread, hence the |ui_task_runner|. |settings| and |params| must not be
+ // null.
DataReductionProxyUsageStats(
DataReductionProxyParams* params,
- const scoped_refptr<base::MessageLoopProxy>& ui_thread_proxy);
- ~DataReductionProxyUsageStats() override;
+ DataReductionProxySettings* settings,
+ const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner);
- // Sets the callback to be called on the UI thread when the unavailability
- // status has changed.
- void set_unavailable_callback(
- const base::Callback<void(bool)>& unavailable_callback) {
- unavailable_callback_ = unavailable_callback;
- }
+ ~DataReductionProxyUsageStats() override;
- // Callback intended to be called from |ChromeNetworkDelegate| when a
- // request completes. This method is used to gather usage stats.
+ // Callback intended to be called from |DataReductionProxyNetworkDelegate|
+ // when a request completes. This method is used to gather usage stats.
void OnUrlRequestCompleted(const net::URLRequest* request, bool started);
// Records the last bypass reason to |bypass_type_| and sets
@@ -119,10 +119,6 @@ class DataReductionProxyUsageStats
void OnNetworkChanged(
net::NetworkChangeNotifier::ConnectionType type) override;
- // Called when request counts change. Resets counts if they exceed thresholds,
- // and calls MaybeNotifyUnavailability otherwise.
- void OnRequestCountChanged();
-
// Clears request counts unconditionally.
void ClearRequestCounts();
@@ -134,13 +130,21 @@ class DataReductionProxyUsageStats
void NotifyUnavailabilityIfChanged();
void NotifyUnavailabilityOnUIThread(bool unavailable);
+ void RecordBypassedBytes(
+ DataReductionProxyBypassType bypass_type,
+ BypassedBytesType bypassed_bytes_type,
+ int64 content_length);
+
DataReductionProxyParams* data_reduction_proxy_params_;
+
+ DataReductionProxySettings* settings_;
+
// The last reason for bypass as determined by
// MaybeBypassProxyAndPrepareToRetry
DataReductionProxyBypassType last_bypass_type_;
// True if the last request triggered the current bypass.
bool triggering_request_;
- const scoped_refptr<base::MessageLoopProxy> ui_thread_proxy_;
+ const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
// The following 2 fields are used to determine if data reduction proxy is
// unreachable. We keep a count of requests which should go through
@@ -160,14 +164,6 @@ class DataReductionProxyUsageStats
base::ThreadChecker thread_checker_;
- void RecordBypassedBytes(
- DataReductionProxyBypassType bypass_type,
- BypassedBytesType bypassed_bytes_type,
- int64 content_length);
-
- // Called when the unavailability status has changed. Runs on the UI thread.
- base::Callback<void(bool)> unavailable_callback_;
-
DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats);
};

Powered by Google App Engine
This is Rietveld 408576698