| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_DATA_REDUCTION_PROXY_H_ | |
| 6 #define COMPONENTS_CRONET_ANDROID_CRONET_DATA_REDUCTION_PROXY_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 | |
| 14 class PrefService; | |
| 15 | |
| 16 namespace base { | |
| 17 class SingleThreadTaskRunner; | |
| 18 } | |
| 19 | |
| 20 namespace data_reduction_proxy { | |
| 21 class DataReductionProxyIOData; | |
| 22 class DataReductionProxySettings; | |
| 23 } | |
| 24 | |
| 25 namespace net { | |
| 26 class NetLog; | |
| 27 class NetworkDelegate; | |
| 28 class ProxyDelegate; | |
| 29 class URLRequestContext; | |
| 30 class URLRequestContextGetter; | |
| 31 class URLRequestInterceptor; | |
| 32 } | |
| 33 | |
| 34 namespace cronet { | |
| 35 | |
| 36 // Wrapper and configurator of Data Reduction Proxy objects for Cronet. It | |
| 37 // configures the Data Reduction Proxy to run both its UI and IO classes on | |
| 38 // Cronet's network thread. | |
| 39 class CronetDataReductionProxy { | |
| 40 public: | |
| 41 // Construct Data Reduction Proxy Settings and IOData objects and set | |
| 42 // the authentication key. The |task_runner| should be suitable for running | |
| 43 // tasks on the network thread. The primary proxy, fallback proxy, and secure | |
| 44 // proxy check url can override defaults. All or none must be specified. | |
| 45 CronetDataReductionProxy( | |
| 46 const std::string& key, | |
| 47 const std::string& primary_proxy, | |
| 48 const std::string& fallback_proxy, | |
| 49 const std::string& secure_proxy_check_url, | |
| 50 const std::string& user_agent, | |
| 51 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
| 52 net::NetLog* net_log); | |
| 53 | |
| 54 ~CronetDataReductionProxy(); | |
| 55 | |
| 56 // Constructs a network delegate suitable for adding Data Reduction Proxy | |
| 57 // request headers. | |
| 58 std::unique_ptr<net::NetworkDelegate> CreateNetworkDelegate( | |
| 59 std::unique_ptr<net::NetworkDelegate> wrapped_network_delegate); | |
| 60 | |
| 61 // Constructs a proxy delegate suitable for adding Data Reduction Proxy | |
| 62 // proxy resolution. | |
| 63 std::unique_ptr<net::ProxyDelegate> CreateProxyDelegate(); | |
| 64 | |
| 65 // Constructs a URLRequestInterceptor suitable for carrying out the Data | |
| 66 // Reduction Proxy's bypass protocol. | |
| 67 std::unique_ptr<net::URLRequestInterceptor> CreateInterceptor(); | |
| 68 | |
| 69 // Constructs a bridge between the Settings and IOData objects, sets up a | |
| 70 // context for secure proxy check requests, and enables the proxy, if | |
| 71 // |enable| is true. | |
| 72 void Init(bool enable, net::URLRequestContext* context); | |
| 73 | |
| 74 private: | |
| 75 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 76 std::unique_ptr<PrefService> prefs_; | |
| 77 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | |
| 78 std::unique_ptr<data_reduction_proxy::DataReductionProxySettings> settings_; | |
| 79 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData> io_data_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(CronetDataReductionProxy); | |
| 82 }; | |
| 83 | |
| 84 } // namespace cronet | |
| 85 | |
| 86 #endif // COMPONENTS_CRONET_ANDROID_CRONET_DATA_REDUCTION_PROXY_H_ | |
| OLD | NEW |