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..0ff1661be97aa47005de62d442078fca103de490 |
| --- /dev/null |
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h |
| @@ -0,0 +1,153 @@ |
| +// 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. |
| + |
| +#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 "base/prefs/pref_member.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_delegate.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h" |
| +#include "net/url_request/url_request_interceptor.h" |
| + |
| +namespace net { |
| +class NetLog; |
| +class URLRequestInterceptor; |
|
sclittle
2015/01/14 22:54:47
nit: either remove this forward declaration or rem
bengr
2015/01/15 00:30:32
Done.
|
| +} |
| + |
| +namespace data_reduction_proxy { |
| + |
| +class DataReductionProxyConfigurator; |
| +class DataReductionProxyEventStore; |
| +class DataReductionProxyParams; |
| +class DataReductionProxySettings; |
| +class DataReductionProxyStatisticsPrefs; |
| +class DataReductionProxyUsageStats; |
| + |
| +// Contains and initializes all Data Reduction Proxy objects that operate on |
|
sclittle
2015/01/14 22:54:46
nit: inconsistent capitalization of Data Reduction
bengr
2015/01/15 00:30:32
Done, at least in this file.
|
| +// 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. |statistics_prefs| |
| + // maintains compression statistics during use of the proxy. |
| + // |proxy_config_getter| provides the current effective proxy configuration, |
|
sclittle
2015/01/14 22:54:47
what |proxy_config_getter|?
bengr
2015/01/15 00:30:32
Done.
|
| + // which the Data Reduction Proxy overrides sometimes. |
| + // The |unavailable_callback| is called when the Data Reduction Proxy is |
|
sclittle
2015/01/14 22:54:46
what |unavailable_callback|?
bengr
2015/01/15 00:30:32
Done.
|
| + // unavailable. |
| + DataReductionProxyIOData( |
| + const Client& client, |
| + scoped_ptr<DataReductionProxyParams> params, |
| + scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs, |
| + DataReductionProxySettings* settings, |
| + net::NetLog* net_log, |
| + 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); |
|
sclittle
2015/01/14 22:54:47
Maybe remove the io_task_runner parameter, and use
bengr
2015/01/15 00:30:31
Done.
|
| + |
| + // 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. |
|
sclittle
2015/01/14 22:54:47
Does the caller own the returned interceptor?
bengr
2015/01/15 00:30:32
Done.
|
| + 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 track_proxy_bypass_statistics); |
| + |
| + // 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(); |
| + } |
| + |
|
sclittle
2015/01/14 22:54:47
nit: remove blank line
bengr
2015/01/15 00:30:32
Done.
|
| + |
| + DataReductionProxyStatisticsPrefs* statistics_prefs() const { |
| + return compression_stats_.get(); |
| + } |
| + |
| + net::NetworkDelegate* network_delegate() const { |
| + return network_delegate_.get(); |
| + } |
| + |
| + net::ProxyDelegate* 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_; |
| + |
| + // 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_; |
| + |
| + // Setter of the Data Reduction Proxy-specific proxy configuration. |
| + scoped_ptr<DataReductionProxyConfigurator> configurator_; |
| + |
| + // 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_; |
|
sclittle
2015/01/14 22:54:46
Why |bypass_stats_|, and not |usage_stats_|?
bengr
2015/01/15 00:30:32
We should rename DataReductionProxyUsageStats as D
|
| + |
| + // 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_; |
|
sclittle
2015/01/14 22:54:47
|network_delegate_| is never set.
bengr
2015/01/15 00:30:32
Done.
|
| + |
| + // 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_ |
| + |