| Index: components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h
|
| diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h b/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h
|
| index 6c217b2f5768bdba67c736494cee83e2629dc718..3b8c62ac4c225f9b97646f979128208fce4b4e3c 100644
|
| --- a/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h
|
| +++ b/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h
|
| @@ -5,6 +5,7 @@
|
| #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_STATS_H_
|
| #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_STATS_H_
|
|
|
| +#include "base/callback.h"
|
| #include "base/message_loop/message_loop_proxy.h"
|
| #include "base/threading/thread_checker.h"
|
| #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
|
| @@ -23,19 +24,35 @@ class DataReductionProxyUsageStats
|
| base::MessageLoopProxy* io_thread_proxy);
|
| virtual ~DataReductionProxyUsageStats();
|
|
|
| - /**
|
| - * Callback intended to be called from |ChromeNetworkDelegate| when a
|
| - * request completes. This method is used to gather usage stats.
|
| - */
|
| - void OnUrlRequestCompleted(const net::URLRequest* request, bool started);
|
| + // 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;
|
| + }
|
|
|
| - /**
|
| - * Determines whether the data reduction proxy is unreachable.
|
| - * Returns true if data reduction proxy is unreachable.
|
| - */
|
| - bool isDataReductionProxyUnreachable();
|
| + // Callback intended to be called from |ChromeNetworkDelegate| when a
|
| + // request completes. This method is used to gather usage stats.
|
| + void OnUrlRequestCompleted(const net::URLRequest* request, bool started);
|
|
|
| private:
|
| + // NetworkChangeNotifier::NetworkChangeObserver:
|
| + virtual void OnNetworkChanged(
|
| + net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
|
| +
|
| + // Counts requests that went through the data reduction proxy and counts
|
| + // requests that were eligible to go through the proxy.
|
| + void IncrementRequestCounts(bool actual);
|
| + void ClearRequestCounts();
|
| +
|
| + // Checks if the availability status of the data reduction proxy has changed,
|
| + // and notifies the UIThread via NotifyUnavailabilityOnUIThread if so. The
|
| + // data reduction proxy is considered unavailable if and only if no requests
|
| + // went through the proxy but some eligible requests were service by other
|
| + // routes.
|
| + void MaybeNotifyUnavailability();
|
| + void NotifyUnavailabilityOnUIThread(bool unavailable);
|
| +
|
| DataReductionProxyParams* data_reduction_proxy_params_;
|
| base::MessageLoopProxy* ui_thread_proxy_;
|
| base::MessageLoopProxy* io_thread_proxy_;
|
| @@ -51,18 +68,18 @@ class DataReductionProxyUsageStats
|
| // Explicit bypasses are not part of this count. This is the desired behavior
|
| // since otherwise both counts would be identical.
|
| unsigned long eligible_num_requests_through_proxy_;
|
| - // Count of successfull requests through data reduction proxy.
|
| - unsigned long actual_num_requests_through_proxy_;
|
|
|
| - // NetworkChangeNotifier::NetworkChangeObserver:
|
| - virtual void OnNetworkChanged(
|
| - net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
|
| + // Count of successful requests through data reduction proxy.
|
| + unsigned long actual_num_requests_through_proxy_;
|
|
|
| - void IncRequestCountsOnUiThread(bool actual);
|
| - void ClearRequestCountsOnUiThread();
|
| + // Whether or not the data reduction proxy is unavailable.
|
| + bool unavailable_;
|
|
|
| base::ThreadChecker thread_checker_;
|
|
|
| + // Called when the unavailability status has changed. Runs on the UI thread.
|
| + base::Callback<void(bool)> unavailable_callback_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats);
|
| };
|
|
|
|
|