Chromium Code Reviews| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h |
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..47815bfc70d567d2a6eba5f30fc7953decb6f048 |
| --- /dev/null |
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h |
| @@ -0,0 +1,157 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| + |
|
mmenke
2015/01/09 21:09:50
nit: Should be one blank line here, not two.
bengr
2015/01/14 21:39:54
Done.
|
| +#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_IO_DATA_H_ |
| +#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_IO_DATA_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h" |
| +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h" |
| +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" |
| +#include "net/url_request/url_request_interceptor.h" |
| + |
| +namespace net { |
| +class URLRequestInterceptor; |
| +} |
| + |
| +namespace data_reduction_proxy { |
| + |
| +class DataReductionProxyDelegate; |
| + |
| +// Contains and initializes all Data Reduction Proxy objects that operate on |
| +// the IO thread. |
| +class DataReductionProxyIOData { |
| + public: |
| + // Constructs a DataReductionProxyIOData object and takes ownership of its |
| + // parameters. |params| contains information about the DNS names used by the |
| + // proxy, and allowable configurations. The |configurator| sets, modifies and |
| + // removes the Data Reduction Proxy configuration. |statistics_prefs| |
| + // maintains compression statistics during use of the proxy. The |event_store| |
| + // tracks Data Reduction Proxy-related events. |proxy_config_getter| |
| + // provides the current effective proxy configuration, which the Data |
| + // Reduction Proxy overrides sometimes. The |unavailable_callback| is called |
| + // when the Data Reduction Proxy is unavailable. |
| + DataReductionProxyIOData( |
| + const Client& client, |
| + scoped_ptr<DataReductionProxyParams> params, |
| + scoped_ptr<DataReductionProxyConfigurator> configurator, |
| + scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs, |
| + scoped_ptr<DataReductionProxyEventStore> event_store, |
| + DataReductionProxySettings* settings, |
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| + |
| + virtual ~DataReductionProxyIOData(); |
| + |
| + // Initializes preferences, including a preference to track whether the |
| + // data reduction proxy is enabled. |
| + void InitPrefsOnUIThread( |
| + PrefService* pref_service, |
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); |
| + |
| + // Destroys preferences other than the statistics preferences, and writes out |
| + // statistics preferences if necessary. |
| + void DestroyPrefsOnUIThread(); |
| + |
| + // Destroys the statistics preferences. |
| + void ShutdownStatisicsPrefsOnUIThread(); |
| + |
| + // Creates an interceptor suitable for following the Data Reduction Proxy |
| + // bypass protocol. |
| + net::URLRequestInterceptor* CreateInterceptor(); |
| + |
| + // Constructs statistics prefs. This is not necessary if a valid statistics |
| + // prefs is passed into the constructor. |
| + void EnableCompressionStatisticsLogging( |
| + PrefService* prefs, |
| + const base::TimeDelta& commit_delay); |
| + |
| + // Creates a NetworkDelegate suitable for carrying out the Data Reduction |
| + // Proxy protocol, including authenticating, establishing a handler to |
| + // override the current proxy configuration, and |
| + // gathering statistics for UMA. |
| + scoped_ptr<DataReductionProxyNetworkDelegate> CreateNetworkDelegate( |
| + scoped_ptr<net::NetworkDelegate> wrapped_network_delegate, |
| + bool allow_proxy_config_overrides, |
| + bool track_proxy_bypass_statistics); |
| + |
| + // Creates a proxy delegate. |
| + void CreateProxyDelegate(); |
| + |
| + // Returns true if the Data Reduction Proxy is enabled and false otherwise. |
| + bool IsEnabled() const; |
| + |
| + DataReductionProxyConfigurator* configurator() const { |
| + return configurator_.get(); |
| + } |
| + |
| + DataReductionProxyEventStore* event_store() const { |
| + return event_store_.get(); |
| + } |
| + |
| + |
| + DataReductionProxyStatisticsPrefs* statistics_prefs() const { |
| + return compression_stats_.get(); |
| + } |
| + |
| + net::NetworkDelegate* network_delegate() const { |
| + return network_delegate_.get(); |
| + } |
| + |
| + DataReductionProxyDelegate* proxy_delegate() const { |
| + return proxy_delegate_.get(); |
| + } |
| + |
| + private: |
| + // The type of Data Reduction Proxy client. |
| + Client client_; |
| + |
| + // Parameters including DNS names and allowable configurations. |
| + scoped_ptr<DataReductionProxyParams> params_; |
| + |
| + // Setter of the Data Reduction Proxy-specific proxy configuration. |
| + scoped_ptr<DataReductionProxyConfigurator> configurator_; |
| + |
| + // Tracker of compression statistics to be displayed to the user. |
| + scoped_ptr<DataReductionProxyStatisticsPrefs> compression_stats_; |
| + |
| + // Tracker of Data Reduction Proxy-related events, e.g., for logging. |
| + scoped_ptr<DataReductionProxyEventStore> event_store_; |
| + |
| + // A proxy delegate. Used, for example, to add authentication to HTTP CONNECT |
| + // request. |
| + scoped_ptr<DataReductionProxyDelegate> proxy_delegate_; |
| + |
| + // User-facing settings object. |
| + DataReductionProxySettings* settings_; |
| + |
| + // Tracker of various metrics to be reported in UMA. |
| + scoped_ptr<DataReductionProxyUsageStats> bypass_stats_; |
| + |
| + // Constructs credentials suitable for authenticating the client. |
| + scoped_ptr<DataReductionProxyAuthRequestHandler> auth_request_handler_; |
| + |
| + // The network delegate, which has hooks for collecting UMA, and for |
| + // overriding proxy resolutions. |
| + scoped_ptr<DataReductionProxyNetworkDelegate> network_delegate_; |
| + |
| + // IO and UI task runners, respectively. |
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| + |
| + // Preference that determines if the Data Reduction Proxy has been enabled |
| + // by the user. In practice, this can be overridden by the command line. |
| + BooleanPrefMember enabled_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DataReductionProxyIOData); |
| +}; |
| + |
| +} // namespace data_reduction_proxy |
| +#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_IO_DATA_H_ |
| + |