OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
6 #define CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 6 #define CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h " | 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h " |
17 #include "net/base/network_delegate.h" | 17 #include "net/base/network_delegate.h" |
18 #include "net/proxy/proxy_retry_info.h" | |
18 | 19 |
19 class ChromeExtensionsNetworkDelegate; | 20 class ChromeExtensionsNetworkDelegate; |
20 class ClientHints; | 21 class ClientHints; |
21 class CookieSettings; | 22 class CookieSettings; |
22 class PrefService; | 23 class PrefService; |
23 | 24 |
24 template<class T> class PrefMember; | 25 template<class T> class PrefMember; |
25 | 26 |
26 typedef PrefMember<bool> BooleanPrefMember; | 27 typedef PrefMember<bool> BooleanPrefMember; |
27 | 28 |
(...skipping 15 matching lines...) Expand all Loading... | |
43 namespace domain_reliability { | 44 namespace domain_reliability { |
44 class DomainReliabilityMonitor; | 45 class DomainReliabilityMonitor; |
45 } // namespace domain_reliability | 46 } // namespace domain_reliability |
46 | 47 |
47 namespace extensions { | 48 namespace extensions { |
48 class EventRouterForwarder; | 49 class EventRouterForwarder; |
49 class InfoMap; | 50 class InfoMap; |
50 } | 51 } |
51 | 52 |
52 namespace net { | 53 namespace net { |
54 class ProxyConfig; | |
53 class ProxyInfo; | 55 class ProxyInfo; |
54 class ProxyServer; | 56 class ProxyServer; |
57 class ProxyService; | |
55 class URLRequest; | 58 class URLRequest; |
56 } | 59 } |
57 | 60 |
58 namespace policy { | 61 namespace policy { |
59 class URLBlacklistManager; | 62 class URLBlacklistManager; |
60 } | 63 } |
61 | 64 |
62 namespace prerender { | 65 namespace prerender { |
63 class PrerenderTracker; | 66 class PrerenderTracker; |
64 } | 67 } |
65 | 68 |
66 // ChromeNetworkDelegate is the central point from within the chrome code to | 69 // ChromeNetworkDelegate is the central point from within the chrome code to |
67 // add hooks into the network stack. | 70 // add hooks into the network stack. |
68 class ChromeNetworkDelegate : public net::NetworkDelegate { | 71 class ChromeNetworkDelegate : public net::NetworkDelegate { |
69 public: | 72 public: |
70 // Provides an opportunity to interpose on proxy resolution. Called before | 73 // Provides an opportunity to interpose on proxy resolution. Called before |
71 // ProxyService.ResolveProxy() returns. |proxy_info| contains information | 74 // ProxyService.ResolveProxy() returns. |proxy_info| contains information |
72 // about the proxy being used, and may be modified by this callback. | 75 // about the proxy being used, and may be modified by this callback. |
73 typedef base::Callback<void( | 76 typedef base::Callback<void( |
74 const GURL& url, | 77 const GURL& url, |
75 int load_flags, | 78 int load_flags, |
79 const net::ProxyConfig& data_reduction_proxy_config, | |
80 const net::ProxyRetryInfoMap& proxy_retry_info_map, | |
76 const data_reduction_proxy::DataReductionProxyParams* params, | 81 const data_reduction_proxy::DataReductionProxyParams* params, |
77 net::ProxyInfo* result)> OnResolveProxyHandler; | 82 net::ProxyInfo* result)> OnResolveProxyHandler; |
78 | 83 |
84 // Provides an additional proxy configuration that can be consulted after | |
85 // proxy resolution. | |
86 typedef base::Callback<void(net::ProxyConfig* proxy_config)> | |
87 ProxyConfigGetter; | |
88 | |
79 // |enable_referrers| (and all of the other optional PrefMembers) should be | 89 // |enable_referrers| (and all of the other optional PrefMembers) should be |
80 // initialized on the UI thread (see below) beforehand. This object's owner is | 90 // initialized on the UI thread (see below) beforehand. This object's owner is |
81 // responsible for cleaning them up at shutdown. | 91 // responsible for cleaning them up at shutdown. |
82 ChromeNetworkDelegate(extensions::EventRouterForwarder* event_router, | 92 ChromeNetworkDelegate(extensions::EventRouterForwarder* event_router, |
83 BooleanPrefMember* enable_referrers); | 93 BooleanPrefMember* enable_referrers); |
84 virtual ~ChromeNetworkDelegate(); | 94 virtual ~ChromeNetworkDelegate(); |
85 | 95 |
86 // Pass through to ChromeExtensionsNetworkDelegate::set_extension_info_map(). | 96 // Pass through to ChromeExtensionsNetworkDelegate::set_extension_info_map(). |
87 void set_extension_info_map(extensions::InfoMap* extension_info_map); | 97 void set_extension_info_map(extensions::InfoMap* extension_info_map); |
88 | 98 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 // ChromeNetworkDelegate. | 164 // ChromeNetworkDelegate. |
155 void set_data_reduction_proxy_auth_request_handler( | 165 void set_data_reduction_proxy_auth_request_handler( |
156 data_reduction_proxy::DataReductionProxyAuthRequestHandler* handler) { | 166 data_reduction_proxy::DataReductionProxyAuthRequestHandler* handler) { |
157 data_reduction_proxy_auth_request_handler_ = handler; | 167 data_reduction_proxy_auth_request_handler_ = handler; |
158 } | 168 } |
159 | 169 |
160 void set_on_resolve_proxy_handler(OnResolveProxyHandler handler) { | 170 void set_on_resolve_proxy_handler(OnResolveProxyHandler handler) { |
161 on_resolve_proxy_handler_ = handler; | 171 on_resolve_proxy_handler_ = handler; |
162 } | 172 } |
163 | 173 |
174 void set_proxy_config_getter(ProxyConfigGetter getter) { | |
mef
2014/08/11 19:44:40
const &?
bengr
2014/08/11 23:03:19
Done.
| |
175 proxy_config_getter_ = getter; | |
176 } | |
177 | |
178 | |
marq (ping after 24h)
2014/08/11 16:11:33
Extra line.
bengr
2014/08/11 23:03:19
Done.
| |
164 // Adds the Client Hints header to HTTP requests. | 179 // Adds the Client Hints header to HTTP requests. |
165 void SetEnableClientHints(); | 180 void SetEnableClientHints(); |
166 | 181 |
167 // Causes |OnCanThrottleRequest| to always return false, for all | 182 // Causes |OnCanThrottleRequest| to always return false, for all |
168 // instances of this object. | 183 // instances of this object. |
169 static void NeverThrottleRequests(); | 184 static void NeverThrottleRequests(); |
170 | 185 |
171 // Binds the pref members to |pref_service| and moves them to the IO thread. | 186 // Binds the pref members to |pref_service| and moves them to the IO thread. |
172 // |enable_referrers| cannot be NULL, the others can. | 187 // |enable_referrers| cannot be NULL, the others can. |
173 // This method should be called on the UI thread. | 188 // This method should be called on the UI thread. |
(...skipping 17 matching lines...) Expand all Loading... | |
191 base::Value* SessionNetworkStatsInfoToValue() const; | 206 base::Value* SessionNetworkStatsInfoToValue() const; |
192 | 207 |
193 private: | 208 private: |
194 friend class ChromeNetworkDelegateTest; | 209 friend class ChromeNetworkDelegateTest; |
195 | 210 |
196 // NetworkDelegate implementation. | 211 // NetworkDelegate implementation. |
197 virtual int OnBeforeURLRequest(net::URLRequest* request, | 212 virtual int OnBeforeURLRequest(net::URLRequest* request, |
198 const net::CompletionCallback& callback, | 213 const net::CompletionCallback& callback, |
199 GURL* new_url) OVERRIDE; | 214 GURL* new_url) OVERRIDE; |
200 virtual void OnResolveProxy( | 215 virtual void OnResolveProxy( |
201 const GURL& url, int load_flags, net::ProxyInfo* result) OVERRIDE; | 216 const GURL& url, |
217 int load_flags, | |
218 const net::ProxyService* proxy_service, | |
219 net::ProxyInfo* result) OVERRIDE; | |
202 virtual void OnProxyFallback(const net::ProxyServer& bad_proxy, | 220 virtual void OnProxyFallback(const net::ProxyServer& bad_proxy, |
203 int net_error, | 221 int net_error, |
204 bool did_fallback) OVERRIDE; | 222 bool did_fallback) OVERRIDE; |
205 virtual int OnBeforeSendHeaders(net::URLRequest* request, | 223 virtual int OnBeforeSendHeaders(net::URLRequest* request, |
206 const net::CompletionCallback& callback, | 224 const net::CompletionCallback& callback, |
207 net::HttpRequestHeaders* headers) OVERRIDE; | 225 net::HttpRequestHeaders* headers) OVERRIDE; |
208 virtual void OnBeforeSendProxyHeaders( | 226 virtual void OnBeforeSendProxyHeaders( |
209 net::URLRequest* request, | 227 net::URLRequest* request, |
210 const net::ProxyInfo& proxy_info, | 228 const net::ProxyInfo& proxy_info, |
211 net::HttpRequestHeaders* headers) OVERRIDE; | 229 net::HttpRequestHeaders* headers) OVERRIDE; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 // |data_reduction_proxy_params_| must outlive this ChromeNetworkDelegate. | 317 // |data_reduction_proxy_params_| must outlive this ChromeNetworkDelegate. |
300 data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params_; | 318 data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params_; |
301 // |data_reduction_proxy_usage_stats_| must outlive this | 319 // |data_reduction_proxy_usage_stats_| must outlive this |
302 // ChromeNetworkDelegate. | 320 // ChromeNetworkDelegate. |
303 data_reduction_proxy::DataReductionProxyUsageStats* | 321 data_reduction_proxy::DataReductionProxyUsageStats* |
304 data_reduction_proxy_usage_stats_; | 322 data_reduction_proxy_usage_stats_; |
305 data_reduction_proxy::DataReductionProxyAuthRequestHandler* | 323 data_reduction_proxy::DataReductionProxyAuthRequestHandler* |
306 data_reduction_proxy_auth_request_handler_; | 324 data_reduction_proxy_auth_request_handler_; |
307 | 325 |
308 OnResolveProxyHandler on_resolve_proxy_handler_; | 326 OnResolveProxyHandler on_resolve_proxy_handler_; |
327 ProxyConfigGetter proxy_config_getter_; | |
309 | 328 |
310 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 329 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
311 }; | 330 }; |
312 | 331 |
313 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 332 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
OLD | NEW |