| 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);
|
| };
|
|
|
|
|