| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h
|
| index 370ff80118f496973e54a8422448bd38e170994f..8c4f5cef019f1af26c864ae20a0d3954855dad0d 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h
|
| @@ -6,46 +6,101 @@
|
| #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIGURATOR_H_
|
|
|
| #include <string>
|
| +#include <vector>
|
|
|
| -#include "base/macros.h"
|
| +#include "base/gtest_prod_util.h"
|
| +#include "base/task_runner.h"
|
| +#include "net/proxy/proxy_config.h"
|
| +
|
| +namespace base {
|
| +class SequencedTaskRunner;
|
| +}
|
| +
|
| +namespace net {
|
| +class NetLog;
|
| +class ProxyInfo;
|
| +class ProxyService;
|
| +}
|
| +
|
| +class PrefService;
|
|
|
| namespace data_reduction_proxy {
|
|
|
| -// Interface for enabling and disabling the data reduction proxy configuration,
|
| -// and for adding bypass rules. This is the interface that is used to set the
|
| -// networking configuration that causes traffic to be proxied.
|
| +class DataReductionProxyEventStore;
|
| +
|
| class DataReductionProxyConfigurator {
|
| public:
|
| - DataReductionProxyConfigurator() {}
|
| - virtual ~DataReductionProxyConfigurator() {}
|
| -
|
| - // Enable the data reduction proxy. If |primary_restricted|, the
|
| - // |primary_origin| may not be used. If |fallback_restricted|, the
|
| - // |fallback_origin| may not be used. If both are restricted, then the
|
| - // proxy configuration will be the same as when |Disable()| is called.
|
| - // If |ssl_origin| is non-empty, it will be used used for HTTPS traffic.
|
| + // Check whether the |proxy_rules| contain any of the data reduction proxies.
|
| + static bool ContainsDataReductionProxy(
|
| + const net::ProxyConfig::ProxyRules& proxy_rules);
|
| +
|
| + // Constructs a configurator. |network_task_runner| should be the task runner
|
| + // for running network operations, |net_log| and |event_store| are used to
|
| + // track network and Data Reduction Proxy events respectively, must not be
|
| + // null, and must outlive this instance.
|
| + DataReductionProxyConfigurator(
|
| + scoped_refptr<base::SequencedTaskRunner> network_task_runner,
|
| + net::NetLog* net_log,
|
| + data_reduction_proxy::DataReductionProxyEventStore* event_store);
|
| +
|
| + virtual ~DataReductionProxyConfigurator();
|
| +
|
| + void set_net_log(net::NetLog* net_log) {
|
| + DCHECK(!net_log_);
|
| + net_log_ = net_log;
|
| + DCHECK(net_log_);
|
| + }
|
| +
|
| + // Constructs a proxy configuration suitable for enabling the Data Reduction
|
| + // proxy.
|
| virtual void Enable(bool primary_restricted,
|
| bool fallback_restricted,
|
| const std::string& primary_origin,
|
| const std::string& fallback_origin,
|
| - const std::string& ssl_origin) = 0;
|
| + const std::string& ssl_origin);
|
|
|
| - // Disable the data reduction proxy.
|
| - virtual void Disable() = 0;
|
| + // Constructs a proxy configuration suitable for disabling the Data Reduction
|
| + // proxy.
|
| + virtual void Disable();
|
|
|
| // Adds a host pattern to bypass. This should follow the same syntax used
|
| // in net::ProxyBypassRules; that is, a hostname pattern, a hostname suffix
|
| // pattern, an IP literal, a CIDR block, or the magic string '<local>'.
|
| // Bypass settings persist for the life of this object and are applied
|
| // each time the proxy is enabled, but are not updated while it is enabled.
|
| - virtual void AddHostPatternToBypass(const std::string& pattern) = 0;
|
| + virtual void AddHostPatternToBypass(const std::string& pattern);
|
|
|
| // Adds a URL pattern to bypass the proxy. The base implementation strips
|
| // everything in |pattern| after the first single slash and then treats it
|
| // as a hostname pattern.
|
| - virtual void AddURLPatternToBypass(const std::string& pattern) = 0;
|
| + virtual void AddURLPatternToBypass(const std::string& pattern);
|
| +
|
| + // Updates the config for use on the IO thread.
|
| + void UpdateProxyConfigOnIOThread(const net::ProxyConfig& config);
|
| +
|
| + // Returns the current data reduction proxy config, even if it is not the
|
| + // effective configuration used by the proxy service.
|
| + const net::ProxyConfig& GetProxyConfigOnIOThread() const;
|
|
|
| private:
|
| + FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, TestBypassList);
|
| +
|
| + // Used for updating the proxy config on the IO thread.
|
| + scoped_refptr<base::SequencedTaskRunner> network_task_runner_;
|
| +
|
| + // Rules for bypassing the Data Reduction Proxy.
|
| + std::vector<std::string> bypass_rules_;
|
| +
|
| + // The Data Reduction Proxy's configuration. This contains the list of
|
| + // acceptable data reduction proxies and bypass rules. It should be accessed
|
| + // only on the IO thread.
|
| + net::ProxyConfig config_;
|
| +
|
| + // Used for logging of network- and Data Reduction Proxy-related events.
|
| + net::NetLog* net_log_;
|
| + data_reduction_proxy::DataReductionProxyEventStore*
|
| + data_reduction_proxy_event_store_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(DataReductionProxyConfigurator);
|
| };
|
|
|
|
|