Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h |
index ed39307396757cbd62b4cf32bf1840dc250fa113..0f9aed735a04237cdb7133a42ba474510be3f455 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h |
@@ -14,6 +14,7 @@ |
#include "base/single_thread_task_runner.h" |
#include "base/threading/non_thread_safe.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h" |
+#include "net/url_request/url_fetcher_delegate.h" |
class GURL; |
class PrefService; |
@@ -24,11 +25,16 @@ class TimeDelta; |
} |
namespace net { |
+class URLFetcher; |
class URLRequestContextGetter; |
+class URLRequestStatus; |
} |
namespace data_reduction_proxy { |
+typedef base::Callback<void(const std::string&, const net::URLRequestStatus&)> |
+ FetcherResponseCallback; |
+ |
class DataReductionProxyCompressionStats; |
class DataReductionProxyIOData; |
class DataReductionProxyServiceObserver; |
@@ -36,7 +42,8 @@ class DataReductionProxySettings; |
// Contains and initializes all Data Reduction Proxy objects that have a |
// lifetime based on the UI thread. |
-class DataReductionProxyService : public base::NonThreadSafe { |
+class DataReductionProxyService : public base::NonThreadSafe, |
+ public net::URLFetcherDelegate { |
public: |
// The caller must ensure that |settings| and |request_context| remain alive |
// for the lifetime of the |DataReductionProxyService| instance. This instance |
@@ -49,7 +56,7 @@ class DataReductionProxyService : public base::NonThreadSafe { |
net::URLRequestContextGetter* request_context_getter, |
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); |
- virtual ~DataReductionProxyService(); |
+ ~DataReductionProxyService() override; |
// Sets the DataReductionProxyIOData weak pointer. |
void SetIOData(base::WeakPtr<DataReductionProxyIOData> io_data); |
@@ -60,6 +67,12 @@ class DataReductionProxyService : public base::NonThreadSafe { |
// final step in initialization. |
bool Initialized() const; |
+ // Requests the given |secure_proxy_check_url|. Upon completion, returns the |
+ // results to the caller via the |fetcher_callback|. Virtualized for unit |
+ // testing. |
+ virtual void SecureProxyCheck(const GURL& secure_proxy_check_url, |
+ FetcherResponseCallback fetcher_callback); |
+ |
// Constructs compression stats. This should not be called if a valid |
// compression stats is passed into the constructor. |
void EnableCompressionStatisticsLogging( |
@@ -101,9 +114,22 @@ class DataReductionProxyService : public base::NonThreadSafe { |
base::WeakPtr<DataReductionProxyService> GetWeakPtr(); |
+ protected: |
+ // Virtualized for testing. Returns a fetcher to check if it is permitted to |
+ // use the secure proxy. |
+ virtual net::URLFetcher* GetURLFetcherForSecureProxyCheck( |
+ const GURL& secure_proxy_check_url); |
+ |
private: |
+ // net::URLFetcherDelegate: |
+ void OnURLFetchComplete(const net::URLFetcher* source) override; |
+ |
net::URLRequestContextGetter* url_request_context_getter_; |
+ // The URLFetcher being used for the secure proxy check. |
+ scoped_ptr<net::URLFetcher> fetcher_; |
+ FetcherResponseCallback fetcher_callback_; |
+ |
// Tracks compression statistics to be displayed to the user. |
scoped_ptr<DataReductionProxyCompressionStats> compression_stats_; |