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_
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
17 class SingleThreadTaskRunner
;
20 namespace data_reduction_proxy
{
21 class DataReductionProxyIOData
;
22 class DataReductionProxySettings
;
27 class NetworkDelegate
;
28 class URLRequestContext
;
29 class URLRequestContextGetter
;
30 class URLRequestInterceptor
;
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
{
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
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
67 void Init(bool enable
, net::URLRequestContext
* context
);
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
);
81 #endif // COMPONENTS_CRONET_ANDROID_CRONET_DATA_REDUCTION_PROXY_H_