Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h |
index ac7f758172f14015fafd4dceb9428f948a6e066a..21d244a624d582900c2539f31704c9c63f171028 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h |
@@ -64,28 +64,37 @@ class DataReductionProxyConfig |
: public net::URLFetcherDelegate, |
public net::NetworkChangeNotifier::IPAddressObserver { |
public: |
- // DataReductionProxyConfig will take ownership of |params|. |
- DataReductionProxyConfig(scoped_ptr<DataReductionProxyParams> params); |
- ~DataReductionProxyConfig() override; |
- |
- // Initializes the Data Reduction Proxy config with an |io_task_runner|, |
- // |net_log|, a |UrlRequestContextGetter| for canary probes, a |
- // |DataReductionProxyConfigurator| for setting the proxy configuration, and a |
- // |DataReductionProxyEventStore| for logging event changes. The caller must |
- // ensure that all parameters remain alive for the lifetime of the |
- // |DataReductionProxyConfig| instance. |
- void InitDataReductionProxyConfig( |
+ // The caller must ensure that all parameters remain alive for the lifetime |
+ // of the |DataReductionProxyConfig| instance, with the exception of |params| |
+ // which this instance will own. |
+ DataReductionProxyConfig( |
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
net::NetLog* net_log, |
- net::URLRequestContextGetter* url_request_context_getter, |
+ scoped_ptr<DataReductionProxyParams> params, |
DataReductionProxyConfigurator* configurator, |
DataReductionProxyEventStore* event_store); |
+ ~DataReductionProxyConfig() override; |
// Returns the underlying |DataReductionProxyParams| instance. |
DataReductionProxyParams* params() const { |
return params_.get(); |
} |
+ // Initializes the Data Reduction Proxy with a |URLRequestContextGetter|. The |
+ // caller must ensure that this parameter remains alive for the lifetime of |
+ // the |DataReductionProxyConfig| instance. |
+ void InitURLRequestContext(net::URLRequestContextGetter* context); |
+ |
+ // This method expects to run on the UI thread. It permits the data reduction |
+ // proxy configuration to change based on changes initiated by the user. |
+ virtual void SetProxyPrefs(bool enabled, |
+ bool alternative_enabled, |
+ bool at_startup); |
+ |
+ // Permits changing the underlying |DataReductionProxyConfig| without running |
+ // the initialization loop. |
+ void ResetParamsForTest(scoped_ptr<DataReductionProxyParams> params); |
+ |
protected: |
// Virtualized for testing. Returns a fetcher for the probe to check if OK for |
// the proxy to use TLS. |
@@ -96,9 +105,8 @@ class DataReductionProxyConfig |
// configuration only if |enabled| and |alternative_enabled| are true. If |
// |restricted| is true, only enable the fallback proxy. |at_startup| is true |
// when this method is called from InitDataReductionProxySettings. |
- virtual void SetProxyConfigs(bool enabled, |
+ void SetProxyPrefsOnIOThread(bool enabled, |
bool alternative_enabled, |
- bool restricted, |
bool at_startup); |
// Writes a warning to the log that is used in backend processing of |
@@ -116,6 +124,7 @@ class DataReductionProxyConfig |
private: |
friend class DataReductionProxyConfigTest; |
+ friend class MockDataReductionProxyConfig; |
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, |
TestOnIPAddressChanged); |
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, TestSetProxyConfigs); |
@@ -128,6 +137,15 @@ class DataReductionProxyConfig |
// NetworkChangeNotifier::IPAddressObserver: |
void OnIPAddressChanged() override; |
+ // Performs initialization on the IO thread. |
+ void InitOnIOThread(); |
+ |
+ // Sets the Data Reduction Proxy configuration. |
+ virtual void SetProxyConfigs(bool enabled, |
+ bool alternative_enabled, |
+ bool restricted, |
+ bool at_startup); |
+ |
// Adds the default proxy bypass rules for the Data Reduction Proxy. |
void AddDefaultProxyBypassRules(); |