Roll src/third_party/WebKit aa8346d:dbb8a38 (svn 202629:202630)
[chromium-blink-merge.git] / components / cronet / android / cronet_data_reduction_proxy.h
blob25739b307d70aea022993f58dd9b8f4b7c209ce0
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.
5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_DATA_REDUCTION_PROXY_H_
6 #define COMPONENTS_CRONET_ANDROID_CRONET_DATA_REDUCTION_PROXY_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
14 class PrefService;
16 namespace base {
17 class SingleThreadTaskRunner;
20 namespace data_reduction_proxy {
21 class DataReductionProxyIOData;
22 class DataReductionProxySettings;
25 namespace net {
26 class NetLog;
27 class NetworkDelegate;
28 class URLRequestContext;
29 class URLRequestContextGetter;
30 class URLRequestInterceptor;
33 namespace cronet {
35 // Wrapper and configurator of Data Reduction Proxy objects for Cronet. It
36 // configures the Data Reduction Proxy to run both its UI and IO classes on
37 // Cronet's network thread.
38 class CronetDataReductionProxy {
39 public:
40 // Construct Data Reduction Proxy Settings and IOData objects and set
41 // the authentication key. The |task_runner| should be suitable for running
42 // tasks on the network thread. The primary proxy, fallback proxy, and secure
43 // proxy check url can override defaults. All or none must be specified.
44 CronetDataReductionProxy(
45 const std::string& key,
46 const std::string& primary_proxy,
47 const std::string& fallback_proxy,
48 const std::string& secure_proxy_check_url,
49 const std::string& user_agent,
50 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
51 net::NetLog* net_log);
53 ~CronetDataReductionProxy();
55 // Constructs a network delegate suitable for adding Data Reduction Proxy
56 // request headers.
57 scoped_ptr<net::NetworkDelegate> CreateNetworkDelegate(
58 scoped_ptr<net::NetworkDelegate> wrapped_network_delegate);
60 // Constructs a URLRequestInterceptor suitable for carrying out the Data
61 // Reduction Proxy's bypass protocol.
62 scoped_ptr<net::URLRequestInterceptor> CreateInterceptor();
64 // Constructs a bridge between the Settings and IOData objects, sets up a
65 // context for secure proxy check requests, and enables the proxy, if
66 // |enable| is true.
67 void Init(bool enable, net::URLRequestContext* context);
69 private:
70 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
71 scoped_ptr<PrefService> prefs_;
72 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
73 scoped_ptr<data_reduction_proxy::DataReductionProxySettings> settings_;
74 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> io_data_;
76 DISALLOW_COPY_AND_ASSIGN(CronetDataReductionProxy);
79 } // namespace cronet
81 #endif // COMPONENTS_CRONET_ANDROID_CRONET_DATA_REDUCTION_PROXY_H_