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

Side by Side Diff: chrome/browser/net/chrome_extensions_network_delegate.cc

Issue 2264903003: Adjust callers and networking delegates in chrome/ to modified APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLRequestRead
Patch Set: rebased Created 4 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/net/chrome_extensions_network_delegate.h" 5 #include "chrome/browser/net/chrome_extensions_network_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 class ChromeExtensionsNetworkDelegateImpl 85 class ChromeExtensionsNetworkDelegateImpl
86 : public ChromeExtensionsNetworkDelegate { 86 : public ChromeExtensionsNetworkDelegate {
87 public: 87 public:
88 explicit ChromeExtensionsNetworkDelegateImpl( 88 explicit ChromeExtensionsNetworkDelegateImpl(
89 extensions::EventRouterForwarder* event_router); 89 extensions::EventRouterForwarder* event_router);
90 ~ChromeExtensionsNetworkDelegateImpl() override; 90 ~ChromeExtensionsNetworkDelegateImpl() override;
91 91
92 private: 92 private:
93 // ChromeExtensionsNetworkDelegate implementation. 93 // ChromeExtensionsNetworkDelegate implementation.
94 void ForwardProxyErrors(net::URLRequest* request) override; 94 void ForwardProxyErrors(net::URLRequest* request, int net_error) override;
95 void ForwardStartRequestStatus(net::URLRequest* request) override; 95 void ForwardStartRequestStatus(net::URLRequest* request) override;
96 void ForwardDoneRequestStatus(net::URLRequest* request) override; 96 void ForwardDoneRequestStatus(net::URLRequest* request) override;
97 int OnBeforeURLRequest(net::URLRequest* request, 97 int OnBeforeURLRequest(net::URLRequest* request,
98 const net::CompletionCallback& callback, 98 const net::CompletionCallback& callback,
99 GURL* new_url) override; 99 GURL* new_url) override;
100 int OnBeforeStartTransaction(net::URLRequest* request, 100 int OnBeforeStartTransaction(net::URLRequest* request,
101 const net::CompletionCallback& callback, 101 const net::CompletionCallback& callback,
102 net::HttpRequestHeaders* headers) override; 102 net::HttpRequestHeaders* headers) override;
103 void OnStartTransaction(net::URLRequest* request, 103 void OnStartTransaction(net::URLRequest* request,
104 const net::HttpRequestHeaders& headers) override; 104 const net::HttpRequestHeaders& headers) override;
105 int OnHeadersReceived( 105 int OnHeadersReceived(
106 net::URLRequest* request, 106 net::URLRequest* request,
107 const net::CompletionCallback& callback, 107 const net::CompletionCallback& callback,
108 const net::HttpResponseHeaders* original_response_headers, 108 const net::HttpResponseHeaders* original_response_headers,
109 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, 109 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
110 GURL* allowed_unsafe_redirect_url) override; 110 GURL* allowed_unsafe_redirect_url) override;
111 void OnBeforeRedirect(net::URLRequest* request, 111 void OnBeforeRedirect(net::URLRequest* request,
112 const GURL& new_location) override; 112 const GURL& new_location) override;
113 void OnResponseStarted(net::URLRequest* request) override; 113 void OnResponseStarted(net::URLRequest* request, int net_error) override;
114 void OnCompleted(net::URLRequest* request, bool started) override; 114 void OnCompleted(net::URLRequest* request,
115 bool started,
116 int net_error) override;
115 void OnURLRequestDestroyed(net::URLRequest* request) override; 117 void OnURLRequestDestroyed(net::URLRequest* request) override;
116 void OnPACScriptError(int line_number, const base::string16& error) override; 118 void OnPACScriptError(int line_number, const base::string16& error) override;
117 net::NetworkDelegate::AuthRequiredResponse OnAuthRequired( 119 net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(
118 net::URLRequest* request, 120 net::URLRequest* request,
119 const net::AuthChallengeInfo& auth_info, 121 const net::AuthChallengeInfo& auth_info,
120 const AuthCallback& callback, 122 const AuthCallback& callback,
121 net::AuthCredentials* credentials) override; 123 net::AuthCredentials* credentials) override;
122 124
123 scoped_refptr<extensions::EventRouterForwarder> event_router_; 125 scoped_refptr<extensions::EventRouterForwarder> event_router_;
124 126
125 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsNetworkDelegateImpl); 127 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsNetworkDelegateImpl);
126 }; 128 };
127 129
128 ChromeExtensionsNetworkDelegateImpl::ChromeExtensionsNetworkDelegateImpl( 130 ChromeExtensionsNetworkDelegateImpl::ChromeExtensionsNetworkDelegateImpl(
129 extensions::EventRouterForwarder* event_router) { 131 extensions::EventRouterForwarder* event_router) {
130 DCHECK(event_router); 132 DCHECK(event_router);
131 event_router_ = event_router; 133 event_router_ = event_router;
132 } 134 }
133 135
134 ChromeExtensionsNetworkDelegateImpl::~ChromeExtensionsNetworkDelegateImpl() {} 136 ChromeExtensionsNetworkDelegateImpl::~ChromeExtensionsNetworkDelegateImpl() {}
135 137
136 void ChromeExtensionsNetworkDelegateImpl::ForwardProxyErrors( 138 void ChromeExtensionsNetworkDelegateImpl::ForwardProxyErrors(
137 net::URLRequest* request) { 139 net::URLRequest* request,
138 if (request->status().status() == net::URLRequestStatus::FAILED) { 140 int net_error) {
139 switch (request->status().error()) { 141 if (net_error != net::OK) {
142 switch (net_error) {
140 case net::ERR_PROXY_AUTH_UNSUPPORTED: 143 case net::ERR_PROXY_AUTH_UNSUPPORTED:
141 case net::ERR_PROXY_CONNECTION_FAILED: 144 case net::ERR_PROXY_CONNECTION_FAILED:
142 case net::ERR_TUNNEL_CONNECTION_FAILED: 145 case net::ERR_TUNNEL_CONNECTION_FAILED:
143 extensions::ProxyEventRouter::GetInstance()->OnProxyError( 146 extensions::ProxyEventRouter::GetInstance()->OnProxyError(
144 event_router_.get(), profile_, request->status().error()); 147 event_router_.get(), profile_, net_error);
145 } 148 }
146 } 149 }
147 } 150 }
148 151
149 void ChromeExtensionsNetworkDelegateImpl::ForwardStartRequestStatus( 152 void ChromeExtensionsNetworkDelegateImpl::ForwardStartRequestStatus(
150 net::URLRequest* request) { 153 net::URLRequest* request) {
151 ForwardRequestStatus(REQUEST_STARTED, request, profile_); 154 ForwardRequestStatus(REQUEST_STARTED, request, profile_);
152 } 155 }
153 156
154 void ChromeExtensionsNetworkDelegateImpl::ForwardDoneRequestStatus( 157 void ChromeExtensionsNetworkDelegateImpl::ForwardDoneRequestStatus(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 allowed_unsafe_redirect_url); 213 allowed_unsafe_redirect_url);
211 } 214 }
212 215
213 void ChromeExtensionsNetworkDelegateImpl::OnBeforeRedirect( 216 void ChromeExtensionsNetworkDelegateImpl::OnBeforeRedirect(
214 net::URLRequest* request, 217 net::URLRequest* request,
215 const GURL& new_location) { 218 const GURL& new_location) {
216 ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRedirect( 219 ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRedirect(
217 profile_, extension_info_map_.get(), request, new_location); 220 profile_, extension_info_map_.get(), request, new_location);
218 } 221 }
219 222
220
221 void ChromeExtensionsNetworkDelegateImpl::OnResponseStarted( 223 void ChromeExtensionsNetworkDelegateImpl::OnResponseStarted(
222 net::URLRequest* request) { 224 net::URLRequest* request,
225 int net_error) {
223 ExtensionWebRequestEventRouter::GetInstance()->OnResponseStarted( 226 ExtensionWebRequestEventRouter::GetInstance()->OnResponseStarted(
224 profile_, extension_info_map_.get(), request); 227 profile_, extension_info_map_.get(), request, net_error);
225 ForwardProxyErrors(request); 228 ForwardProxyErrors(request, net_error);
226 } 229 }
227 230
228 void ChromeExtensionsNetworkDelegateImpl::OnCompleted( 231 void ChromeExtensionsNetworkDelegateImpl::OnCompleted(net::URLRequest* request,
229 net::URLRequest* request, 232 bool started,
230 bool started) { 233 int net_error) {
231 if (request->status().status() == net::URLRequestStatus::SUCCESS) { 234 DCHECK_NE(net::ERR_IO_PENDING, net_error);
232 bool is_redirect = request->response_headers() && 235
233 net::HttpResponseHeaders::IsRedirectResponseCode( 236 if (net_error != net::OK) {
234 request->response_headers()->response_code()); 237 ExtensionWebRequestEventRouter::GetInstance()->OnErrorOccurred(
235 if (!is_redirect) { 238 profile_, extension_info_map_.get(), request, started, net_error);
236 ExtensionWebRequestEventRouter::GetInstance()->OnCompleted(
237 profile_, extension_info_map_.get(), request);
238 }
239 return; 239 return;
240 } 240 }
241 241
242 if (request->status().status() == net::URLRequestStatus::FAILED || 242 bool is_redirect = request->response_headers() &&
243 request->status().status() == net::URLRequestStatus::CANCELED) { 243 net::HttpResponseHeaders::IsRedirectResponseCode(
244 ExtensionWebRequestEventRouter::GetInstance()->OnErrorOccurred( 244 request->response_headers()->response_code());
245 profile_, extension_info_map_.get(), request, started); 245 if (!is_redirect) {
246 return; 246 ExtensionWebRequestEventRouter::GetInstance()->OnCompleted(
247 profile_, extension_info_map_.get(), request, net_error);
247 } 248 }
248
249 NOTREACHED();
250 } 249 }
251 250
252 void ChromeExtensionsNetworkDelegateImpl::OnURLRequestDestroyed( 251 void ChromeExtensionsNetworkDelegateImpl::OnURLRequestDestroyed(
253 net::URLRequest* request) { 252 net::URLRequest* request) {
254 ExtensionWebRequestEventRouter::GetInstance()->OnURLRequestDestroyed( 253 ExtensionWebRequestEventRouter::GetInstance()->OnURLRequestDestroyed(
255 profile_, request); 254 profile_, request);
256 } 255 }
257 256
258 void ChromeExtensionsNetworkDelegateImpl::OnPACScriptError( 257 void ChromeExtensionsNetworkDelegateImpl::OnPACScriptError(
259 int line_number, 258 int line_number,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 ChromeExtensionsNetworkDelegate::~ChromeExtensionsNetworkDelegate() {} 293 ChromeExtensionsNetworkDelegate::~ChromeExtensionsNetworkDelegate() {}
295 294
296 void ChromeExtensionsNetworkDelegate::set_extension_info_map( 295 void ChromeExtensionsNetworkDelegate::set_extension_info_map(
297 extensions::InfoMap* extension_info_map) { 296 extensions::InfoMap* extension_info_map) {
298 #if defined(ENABLE_EXTENSIONS) 297 #if defined(ENABLE_EXTENSIONS)
299 extension_info_map_ = extension_info_map; 298 extension_info_map_ = extension_info_map;
300 #endif 299 #endif
301 } 300 }
302 301
303 void ChromeExtensionsNetworkDelegate::ForwardProxyErrors( 302 void ChromeExtensionsNetworkDelegate::ForwardProxyErrors(
304 net::URLRequest* request) { 303 net::URLRequest* request,
305 } 304 int net_error) {}
306 305
307 void ChromeExtensionsNetworkDelegate::ForwardStartRequestStatus( 306 void ChromeExtensionsNetworkDelegate::ForwardStartRequestStatus(
308 net::URLRequest* request) { 307 net::URLRequest* request) {
309 } 308 }
310 309
311 void ChromeExtensionsNetworkDelegate::ForwardDoneRequestStatus( 310 void ChromeExtensionsNetworkDelegate::ForwardDoneRequestStatus(
312 net::URLRequest* request) { 311 net::URLRequest* request) {
313 } 312 }
314 313
315 int ChromeExtensionsNetworkDelegate::OnBeforeURLRequest( 314 int ChromeExtensionsNetworkDelegate::OnBeforeURLRequest(
(...skipping 21 matching lines...) Expand all
337 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, 336 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
338 GURL* allowed_unsafe_redirect_url) { 337 GURL* allowed_unsafe_redirect_url) {
339 return net::OK; 338 return net::OK;
340 } 339 }
341 340
342 void ChromeExtensionsNetworkDelegate::OnBeforeRedirect( 341 void ChromeExtensionsNetworkDelegate::OnBeforeRedirect(
343 net::URLRequest* request, 342 net::URLRequest* request,
344 const GURL& new_location) { 343 const GURL& new_location) {
345 } 344 }
346 345
346 void ChromeExtensionsNetworkDelegate::OnResponseStarted(
347 net::URLRequest* request,
348 int net_error) {}
347 349
348 void ChromeExtensionsNetworkDelegate::OnResponseStarted( 350 void ChromeExtensionsNetworkDelegate::OnCompleted(net::URLRequest* request,
349 net::URLRequest* request) { 351 bool started,
350 } 352 int net_error) {}
351
352 void ChromeExtensionsNetworkDelegate::OnCompleted(
353 net::URLRequest* request,
354 bool started) {
355 }
356 353
357 void ChromeExtensionsNetworkDelegate::OnURLRequestDestroyed( 354 void ChromeExtensionsNetworkDelegate::OnURLRequestDestroyed(
358 net::URLRequest* request) { 355 net::URLRequest* request) {
359 } 356 }
360 357
361 void ChromeExtensionsNetworkDelegate::OnPACScriptError( 358 void ChromeExtensionsNetworkDelegate::OnPACScriptError(
362 int line_number, 359 int line_number,
363 const base::string16& error) { 360 const base::string16& error) {
364 } 361 }
365 362
366 net::NetworkDelegate::AuthRequiredResponse 363 net::NetworkDelegate::AuthRequiredResponse
367 ChromeExtensionsNetworkDelegate::OnAuthRequired( 364 ChromeExtensionsNetworkDelegate::OnAuthRequired(
368 net::URLRequest* request, 365 net::URLRequest* request,
369 const net::AuthChallengeInfo& auth_info, 366 const net::AuthChallengeInfo& auth_info,
370 const AuthCallback& callback, 367 const AuthCallback& callback,
371 net::AuthCredentials* credentials) { 368 net::AuthCredentials* credentials) {
372 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; 369 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
373 } 370 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698