| 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" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 namespace prerender { | 61 namespace prerender { |
| 62 class PrerenderTracker; | 62 class PrerenderTracker; |
| 63 } | 63 } |
| 64 | 64 |
| 65 // ChromeNetworkDelegate is the central point from within the chrome code to | 65 // ChromeNetworkDelegate is the central point from within the chrome code to |
| 66 // add hooks into the network stack. | 66 // add hooks into the network stack. |
| 67 class ChromeNetworkDelegate : public net::NetworkDelegate { | 67 class ChromeNetworkDelegate : public net::NetworkDelegate { |
| 68 public: | 68 public: |
| 69 // Provides an opportunity to interpose on proxy resolution. Called before |
| 70 // ProxyService.ResolveProxy() returns. |proxy_info| contains information |
| 71 // about the proxy being used, and may be modified by this callback. |
| 72 typedef base::Callback<void( |
| 73 const GURL& url, |
| 74 int load_flags, |
| 75 const data_reduction_proxy::DataReductionProxyParams* params, |
| 76 net::ProxyInfo* result)> OnResolveProxyHandler; |
| 77 |
| 69 // |enable_referrers| (and all of the other optional PrefMembers) should be | 78 // |enable_referrers| (and all of the other optional PrefMembers) should be |
| 70 // initialized on the UI thread (see below) beforehand. This object's owner is | 79 // initialized on the UI thread (see below) beforehand. This object's owner is |
| 71 // responsible for cleaning them up at shutdown. | 80 // responsible for cleaning them up at shutdown. |
| 72 ChromeNetworkDelegate(extensions::EventRouterForwarder* event_router, | 81 ChromeNetworkDelegate(extensions::EventRouterForwarder* event_router, |
| 73 BooleanPrefMember* enable_referrers); | 82 BooleanPrefMember* enable_referrers); |
| 74 virtual ~ChromeNetworkDelegate(); | 83 virtual ~ChromeNetworkDelegate(); |
| 75 | 84 |
| 76 // Pass through to ChromeExtensionsNetworkDelegate::set_extension_info_map(). | 85 // Pass through to ChromeExtensionsNetworkDelegate::set_extension_info_map(). |
| 77 void set_extension_info_map(extensions::InfoMap* extension_info_map); | 86 void set_extension_info_map(extensions::InfoMap* extension_info_map); |
| 78 | 87 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 data_reduction_proxy_usage_stats_ = usage_stats; | 144 data_reduction_proxy_usage_stats_ = usage_stats; |
| 136 } | 145 } |
| 137 | 146 |
| 138 // |data_reduction_proxy_auth_request_handler_| must outlive this | 147 // |data_reduction_proxy_auth_request_handler_| must outlive this |
| 139 // ChromeNetworkDelegate. | 148 // ChromeNetworkDelegate. |
| 140 void set_data_reduction_proxy_auth_request_handler( | 149 void set_data_reduction_proxy_auth_request_handler( |
| 141 data_reduction_proxy::DataReductionProxyAuthRequestHandler* handler) { | 150 data_reduction_proxy::DataReductionProxyAuthRequestHandler* handler) { |
| 142 data_reduction_proxy_auth_request_handler_ = handler; | 151 data_reduction_proxy_auth_request_handler_ = handler; |
| 143 } | 152 } |
| 144 | 153 |
| 154 void set_on_resolve_proxy_handler(OnResolveProxyHandler handler) { |
| 155 on_resolve_proxy_handler_ = handler; |
| 156 } |
| 157 |
| 145 // Adds the Client Hints header to HTTP requests. | 158 // Adds the Client Hints header to HTTP requests. |
| 146 void SetEnableClientHints(); | 159 void SetEnableClientHints(); |
| 147 | 160 |
| 148 // Causes |OnCanThrottleRequest| to always return false, for all | 161 // Causes |OnCanThrottleRequest| to always return false, for all |
| 149 // instances of this object. | 162 // instances of this object. |
| 150 static void NeverThrottleRequests(); | 163 static void NeverThrottleRequests(); |
| 151 | 164 |
| 152 // Binds the pref members to |pref_service| and moves them to the IO thread. | 165 // Binds the pref members to |pref_service| and moves them to the IO thread. |
| 153 // |enable_referrers| cannot be NULL, the others can. | 166 // |enable_referrers| cannot be NULL, the others can. |
| 154 // This method should be called on the UI thread. | 167 // This method should be called on the UI thread. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 171 // responsible for deleting the returned value. | 184 // responsible for deleting the returned value. |
| 172 base::Value* SessionNetworkStatsInfoToValue() const; | 185 base::Value* SessionNetworkStatsInfoToValue() const; |
| 173 | 186 |
| 174 private: | 187 private: |
| 175 friend class ChromeNetworkDelegateTest; | 188 friend class ChromeNetworkDelegateTest; |
| 176 | 189 |
| 177 // NetworkDelegate implementation. | 190 // NetworkDelegate implementation. |
| 178 virtual int OnBeforeURLRequest(net::URLRequest* request, | 191 virtual int OnBeforeURLRequest(net::URLRequest* request, |
| 179 const net::CompletionCallback& callback, | 192 const net::CompletionCallback& callback, |
| 180 GURL* new_url) OVERRIDE; | 193 GURL* new_url) OVERRIDE; |
| 194 virtual void OnResolveProxy( |
| 195 const GURL& url, int load_flags, net::ProxyInfo* result) OVERRIDE; |
| 181 virtual int OnBeforeSendHeaders(net::URLRequest* request, | 196 virtual int OnBeforeSendHeaders(net::URLRequest* request, |
| 182 const net::CompletionCallback& callback, | 197 const net::CompletionCallback& callback, |
| 183 net::HttpRequestHeaders* headers) OVERRIDE; | 198 net::HttpRequestHeaders* headers) OVERRIDE; |
| 184 virtual void OnBeforeSendProxyHeaders( | 199 virtual void OnBeforeSendProxyHeaders( |
| 185 net::URLRequest* request, | 200 net::URLRequest* request, |
| 186 const net::ProxyInfo& proxy_info, | 201 const net::ProxyInfo& proxy_info, |
| 187 net::HttpRequestHeaders* headers) OVERRIDE; | 202 net::HttpRequestHeaders* headers) OVERRIDE; |
| 188 virtual void OnSendHeaders(net::URLRequest* request, | 203 virtual void OnSendHeaders(net::URLRequest* request, |
| 189 const net::HttpRequestHeaders& headers) OVERRIDE; | 204 const net::HttpRequestHeaders& headers) OVERRIDE; |
| 190 virtual int OnHeadersReceived( | 205 virtual int OnHeadersReceived( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 288 |
| 274 // |data_reduction_proxy_params_| must outlive this ChromeNetworkDelegate. | 289 // |data_reduction_proxy_params_| must outlive this ChromeNetworkDelegate. |
| 275 data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params_; | 290 data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params_; |
| 276 // |data_reduction_proxy_usage_stats_| must outlive this | 291 // |data_reduction_proxy_usage_stats_| must outlive this |
| 277 // ChromeNetworkDelegate. | 292 // ChromeNetworkDelegate. |
| 278 data_reduction_proxy::DataReductionProxyUsageStats* | 293 data_reduction_proxy::DataReductionProxyUsageStats* |
| 279 data_reduction_proxy_usage_stats_; | 294 data_reduction_proxy_usage_stats_; |
| 280 data_reduction_proxy::DataReductionProxyAuthRequestHandler* | 295 data_reduction_proxy::DataReductionProxyAuthRequestHandler* |
| 281 data_reduction_proxy_auth_request_handler_; | 296 data_reduction_proxy_auth_request_handler_; |
| 282 | 297 |
| 298 OnResolveProxyHandler on_resolve_proxy_handler_; |
| 299 |
| 283 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 300 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
| 284 }; | 301 }; |
| 285 | 302 |
| 286 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 303 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
| OLD | NEW |