Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Side by Side Diff: chrome/browser/net/chrome_network_delegate.h

Issue 449973002: Use data reduction proxy when managed proxy config returns direct (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no-uma-in-proxy-service
Patch Set: Addressed comment and nit Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
Ryan Sleevi 2014/08/14 19:19:50 Having read through this header, and the related c
86 typedef base::Callback<const net::ProxyConfig&()> ProxyConfigGetter;
87
79 // |enable_referrers| (and all of the other optional PrefMembers) should be 88 // |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 89 // initialized on the UI thread (see below) beforehand. This object's owner is
81 // responsible for cleaning them up at shutdown. 90 // responsible for cleaning them up at shutdown.
82 ChromeNetworkDelegate(extensions::EventRouterForwarder* event_router, 91 ChromeNetworkDelegate(extensions::EventRouterForwarder* event_router,
83 BooleanPrefMember* enable_referrers); 92 BooleanPrefMember* enable_referrers);
84 virtual ~ChromeNetworkDelegate(); 93 virtual ~ChromeNetworkDelegate();
85 94
86 // Pass through to ChromeExtensionsNetworkDelegate::set_extension_info_map(). 95 // Pass through to ChromeExtensionsNetworkDelegate::set_extension_info_map().
87 void set_extension_info_map(extensions::InfoMap* extension_info_map); 96 void set_extension_info_map(extensions::InfoMap* extension_info_map);
88 97
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // ChromeNetworkDelegate. 163 // ChromeNetworkDelegate.
155 void set_data_reduction_proxy_auth_request_handler( 164 void set_data_reduction_proxy_auth_request_handler(
156 data_reduction_proxy::DataReductionProxyAuthRequestHandler* handler) { 165 data_reduction_proxy::DataReductionProxyAuthRequestHandler* handler) {
157 data_reduction_proxy_auth_request_handler_ = handler; 166 data_reduction_proxy_auth_request_handler_ = handler;
158 } 167 }
159 168
160 void set_on_resolve_proxy_handler(OnResolveProxyHandler handler) { 169 void set_on_resolve_proxy_handler(OnResolveProxyHandler handler) {
161 on_resolve_proxy_handler_ = handler; 170 on_resolve_proxy_handler_ = handler;
162 } 171 }
163 172
173 void set_proxy_config_getter(const ProxyConfigGetter& getter) {
174 proxy_config_getter_ = getter;
175 }
176
164 // Adds the Client Hints header to HTTP requests. 177 // Adds the Client Hints header to HTTP requests.
165 void SetEnableClientHints(); 178 void SetEnableClientHints();
166 179
167 // Causes |OnCanThrottleRequest| to always return false, for all 180 // Causes |OnCanThrottleRequest| to always return false, for all
168 // instances of this object. 181 // instances of this object.
169 static void NeverThrottleRequests(); 182 static void NeverThrottleRequests();
170 183
171 // Binds the pref members to |pref_service| and moves them to the IO thread. 184 // Binds the pref members to |pref_service| and moves them to the IO thread.
172 // |enable_referrers| cannot be NULL, the others can. 185 // |enable_referrers| cannot be NULL, the others can.
173 // This method should be called on the UI thread. 186 // This method should be called on the UI thread.
(...skipping 17 matching lines...) Expand all
191 base::Value* SessionNetworkStatsInfoToValue() const; 204 base::Value* SessionNetworkStatsInfoToValue() const;
192 205
193 private: 206 private:
194 friend class ChromeNetworkDelegateTest; 207 friend class ChromeNetworkDelegateTest;
195 208
196 // NetworkDelegate implementation. 209 // NetworkDelegate implementation.
197 virtual int OnBeforeURLRequest(net::URLRequest* request, 210 virtual int OnBeforeURLRequest(net::URLRequest* request,
198 const net::CompletionCallback& callback, 211 const net::CompletionCallback& callback,
199 GURL* new_url) OVERRIDE; 212 GURL* new_url) OVERRIDE;
200 virtual void OnResolveProxy( 213 virtual void OnResolveProxy(
201 const GURL& url, int load_flags, net::ProxyInfo* result) OVERRIDE; 214 const GURL& url,
215 int load_flags,
216 const net::ProxyService& proxy_service,
217 net::ProxyInfo* result) OVERRIDE;
202 virtual void OnProxyFallback(const net::ProxyServer& bad_proxy, 218 virtual void OnProxyFallback(const net::ProxyServer& bad_proxy,
203 int net_error, 219 int net_error,
204 bool did_fallback) OVERRIDE; 220 bool did_fallback) OVERRIDE;
205 virtual int OnBeforeSendHeaders(net::URLRequest* request, 221 virtual int OnBeforeSendHeaders(net::URLRequest* request,
206 const net::CompletionCallback& callback, 222 const net::CompletionCallback& callback,
207 net::HttpRequestHeaders* headers) OVERRIDE; 223 net::HttpRequestHeaders* headers) OVERRIDE;
208 virtual void OnBeforeSendProxyHeaders( 224 virtual void OnBeforeSendProxyHeaders(
209 net::URLRequest* request, 225 net::URLRequest* request,
210 const net::ProxyInfo& proxy_info, 226 const net::ProxyInfo& proxy_info,
211 net::HttpRequestHeaders* headers) OVERRIDE; 227 net::HttpRequestHeaders* headers) OVERRIDE;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // |data_reduction_proxy_params_| must outlive this ChromeNetworkDelegate. 315 // |data_reduction_proxy_params_| must outlive this ChromeNetworkDelegate.
300 data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params_; 316 data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params_;
301 // |data_reduction_proxy_usage_stats_| must outlive this 317 // |data_reduction_proxy_usage_stats_| must outlive this
302 // ChromeNetworkDelegate. 318 // ChromeNetworkDelegate.
303 data_reduction_proxy::DataReductionProxyUsageStats* 319 data_reduction_proxy::DataReductionProxyUsageStats*
304 data_reduction_proxy_usage_stats_; 320 data_reduction_proxy_usage_stats_;
305 data_reduction_proxy::DataReductionProxyAuthRequestHandler* 321 data_reduction_proxy::DataReductionProxyAuthRequestHandler*
306 data_reduction_proxy_auth_request_handler_; 322 data_reduction_proxy_auth_request_handler_;
307 323
308 OnResolveProxyHandler on_resolve_proxy_handler_; 324 OnResolveProxyHandler on_resolve_proxy_handler_;
325 ProxyConfigGetter proxy_config_getter_;
309 326
310 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); 327 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate);
311 }; 328 };
312 329
313 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ 330 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698