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..a890d3bd1cb937e6eb8143bd93d54c6a56511ca2 |
--- /dev/null |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h |
@@ -0,0 +1,159 @@ |
+// 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 "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, |
mmenke
2014/12/17 21:37:22
Does this even compile? DRP doesn't know how to d
bengr
2014/12/19 20:05:58
I'm not sure what to do here.
|
+ scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs, |
+ scoped_ptr<DataReductionProxyEventStore> event_store, |
+ const DataReductionProxyNetworkDelegate::ProxyConfigGetter& |
+ proxy_config_getter, |
+ const base::Callback<void(bool)>& unavailable_callback, |
+ 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 CreateStatisticsPrefs( |
+ PrefService* prefs, |
+ const base::TimeDelta& commit_delay); |
+ |
+ // Returns true if the Data Reduction Proxy is enabled and false otherwise. |
+ bool IsEnabled() const; |
+ |
+ // Initializes the IO thread objects, establishing a handler for overriding |
+ // the current proxy configuration, setting up the capture of statistics |
+ // prefs and UMA, and creating a proxy delegate, respectively, if necessary. |
+ void Init(scoped_ptr<net::NetworkDelegate> wrapped_network_delegate, |
+ bool allow_proxy_config_overrides, |
+ bool capture_statistics, |
+ bool create_proxy_delegate); |
+ |
+ DataReductionProxyConfigurator* configurator() const { |
+ return configurator_.get(); |
+ } |
+ |
+ DataReductionProxyEventStore* event_store() const { |
+ return event_store_.get(); |
+ } |
+ |
+ |
+ DataReductionProxyStatisticsPrefs* statistics_prefs() const { |
+ return statistics_prefs_.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> statistics_prefs_; |
+ |
+ // 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_; |
+ |
+ // Callback to retrieve the current effective proxy configuration. Used by |
+ // code to override this configuration. |
+ DataReductionProxyNetworkDelegate::ProxyConfigGetter proxy_config_getter_; |
+ |
+ // Callback that is called when the Data Reduction Proxy is unavailable. |
+ base::Callback<void(bool)> unavailable_callback_; |
+ |
+ // Tracker of various metrics to be reported in UMA. |
+ scoped_ptr<DataReductionProxyUsageStats> usage_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_ |
+ |