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

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: fix while loop Created 4 years, 2 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 class ChromeExtensionsNetworkDelegateImpl 100 class ChromeExtensionsNetworkDelegateImpl
101 : public ChromeExtensionsNetworkDelegate { 101 : public ChromeExtensionsNetworkDelegate {
102 public: 102 public:
103 explicit ChromeExtensionsNetworkDelegateImpl( 103 explicit ChromeExtensionsNetworkDelegateImpl(
104 extensions::EventRouterForwarder* event_router); 104 extensions::EventRouterForwarder* event_router);
105 ~ChromeExtensionsNetworkDelegateImpl() override; 105 ~ChromeExtensionsNetworkDelegateImpl() override;
106 106
107 private: 107 private:
108 // ChromeExtensionsNetworkDelegate implementation. 108 // ChromeExtensionsNetworkDelegate implementation.
109 void ForwardProxyErrors(net::URLRequest* request) override; 109 void ForwardProxyErrors(net::URLRequest* request, int net_error) override;
110 void ForwardStartRequestStatus(net::URLRequest* request) override; 110 void ForwardStartRequestStatus(net::URLRequest* request) override;
111 void ForwardDoneRequestStatus(net::URLRequest* request) override; 111 void ForwardDoneRequestStatus(net::URLRequest* request) override;
112 int OnBeforeURLRequest(net::URLRequest* request, 112 int OnBeforeURLRequest(net::URLRequest* request,
113 const net::CompletionCallback& callback, 113 const net::CompletionCallback& callback,
114 GURL* new_url) override; 114 GURL* new_url) override;
115 int OnBeforeStartTransaction(net::URLRequest* request, 115 int OnBeforeStartTransaction(net::URLRequest* request,
116 const net::CompletionCallback& callback, 116 const net::CompletionCallback& callback,
117 net::HttpRequestHeaders* headers) override; 117 net::HttpRequestHeaders* headers) override;
118 void OnStartTransaction(net::URLRequest* request, 118 void OnStartTransaction(net::URLRequest* request,
119 const net::HttpRequestHeaders& headers) override; 119 const net::HttpRequestHeaders& headers) override;
120 int OnHeadersReceived( 120 int OnHeadersReceived(
121 net::URLRequest* request, 121 net::URLRequest* request,
122 const net::CompletionCallback& callback, 122 const net::CompletionCallback& callback,
123 const net::HttpResponseHeaders* original_response_headers, 123 const net::HttpResponseHeaders* original_response_headers,
124 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, 124 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
125 GURL* allowed_unsafe_redirect_url) override; 125 GURL* allowed_unsafe_redirect_url) override;
126 void OnBeforeRedirect(net::URLRequest* request, 126 void OnBeforeRedirect(net::URLRequest* request,
127 const GURL& new_location) override; 127 const GURL& new_location) override;
128 void OnResponseStarted(net::URLRequest* request) override; 128 void OnResponseStarted(net::URLRequest* request, int net_error) override;
129 void OnCompleted(net::URLRequest* request, bool started) override; 129 void OnCompleted(net::URLRequest* request,
130 bool started,
131 int net_error) override;
130 void OnURLRequestDestroyed(net::URLRequest* request) override; 132 void OnURLRequestDestroyed(net::URLRequest* request) override;
131 void OnPACScriptError(int line_number, const base::string16& error) override; 133 void OnPACScriptError(int line_number, const base::string16& error) override;
132 net::NetworkDelegate::AuthRequiredResponse OnAuthRequired( 134 net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(
133 net::URLRequest* request, 135 net::URLRequest* request,
134 const net::AuthChallengeInfo& auth_info, 136 const net::AuthChallengeInfo& auth_info,
135 const AuthCallback& callback, 137 const AuthCallback& callback,
136 net::AuthCredentials* credentials) override; 138 net::AuthCredentials* credentials) override;
137 139
138 scoped_refptr<extensions::EventRouterForwarder> event_router_; 140 scoped_refptr<extensions::EventRouterForwarder> event_router_;
139 141
140 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsNetworkDelegateImpl); 142 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsNetworkDelegateImpl);
141 }; 143 };
142 144
143 ChromeExtensionsNetworkDelegateImpl::ChromeExtensionsNetworkDelegateImpl( 145 ChromeExtensionsNetworkDelegateImpl::ChromeExtensionsNetworkDelegateImpl(
144 extensions::EventRouterForwarder* event_router) { 146 extensions::EventRouterForwarder* event_router) {
145 DCHECK(event_router); 147 DCHECK(event_router);
146 event_router_ = event_router; 148 event_router_ = event_router;
147 } 149 }
148 150
149 ChromeExtensionsNetworkDelegateImpl::~ChromeExtensionsNetworkDelegateImpl() {} 151 ChromeExtensionsNetworkDelegateImpl::~ChromeExtensionsNetworkDelegateImpl() {}
150 152
151 void ChromeExtensionsNetworkDelegateImpl::ForwardProxyErrors( 153 void ChromeExtensionsNetworkDelegateImpl::ForwardProxyErrors(
152 net::URLRequest* request) { 154 net::URLRequest* request,
153 if (request->status().status() == net::URLRequestStatus::FAILED) { 155 int net_error) {
154 switch (request->status().error()) { 156 if (net_error != net::OK) {
157 switch (net_error) {
155 case net::ERR_PROXY_AUTH_UNSUPPORTED: 158 case net::ERR_PROXY_AUTH_UNSUPPORTED:
156 case net::ERR_PROXY_CONNECTION_FAILED: 159 case net::ERR_PROXY_CONNECTION_FAILED:
157 case net::ERR_TUNNEL_CONNECTION_FAILED: 160 case net::ERR_TUNNEL_CONNECTION_FAILED:
158 extensions::ProxyEventRouter::GetInstance()->OnProxyError( 161 extensions::ProxyEventRouter::GetInstance()->OnProxyError(
159 event_router_.get(), profile_, request->status().error()); 162 event_router_.get(), profile_, net_error);
160 } 163 }
161 } 164 }
162 } 165 }
163 166
164 void ChromeExtensionsNetworkDelegateImpl::ForwardStartRequestStatus( 167 void ChromeExtensionsNetworkDelegateImpl::ForwardStartRequestStatus(
165 net::URLRequest* request) { 168 net::URLRequest* request) {
166 ForwardRequestStatus(REQUEST_STARTED, request, profile_); 169 ForwardRequestStatus(REQUEST_STARTED, request, profile_);
167 } 170 }
168 171
169 void ChromeExtensionsNetworkDelegateImpl::ForwardDoneRequestStatus( 172 void ChromeExtensionsNetworkDelegateImpl::ForwardDoneRequestStatus(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 229 }
227 230
228 void ChromeExtensionsNetworkDelegateImpl::OnBeforeRedirect( 231 void ChromeExtensionsNetworkDelegateImpl::OnBeforeRedirect(
229 net::URLRequest* request, 232 net::URLRequest* request,
230 const GURL& new_location) { 233 const GURL& new_location) {
231 ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRedirect( 234 ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRedirect(
232 profile_, extension_info_map_.get(), 235 profile_, extension_info_map_.get(),
233 GetExtensionNavigationUIData(request), request, new_location); 236 GetExtensionNavigationUIData(request), request, new_location);
234 } 237 }
235 238
236
237 void ChromeExtensionsNetworkDelegateImpl::OnResponseStarted( 239 void ChromeExtensionsNetworkDelegateImpl::OnResponseStarted(
238 net::URLRequest* request) { 240 net::URLRequest* request,
241 int net_error) {
239 ExtensionWebRequestEventRouter::GetInstance()->OnResponseStarted( 242 ExtensionWebRequestEventRouter::GetInstance()->OnResponseStarted(
240 profile_, extension_info_map_.get(), 243 profile_, extension_info_map_.get(),
241 GetExtensionNavigationUIData(request), request); 244 GetExtensionNavigationUIData(request), request, net_error);
242 ForwardProxyErrors(request); 245 ForwardProxyErrors(request, net_error);
243 } 246 }
244 247
245 void ChromeExtensionsNetworkDelegateImpl::OnCompleted( 248 void ChromeExtensionsNetworkDelegateImpl::OnCompleted(net::URLRequest* request,
246 net::URLRequest* request, 249 bool started,
247 bool started) { 250 int net_error) {
248 if (request->status().status() == net::URLRequestStatus::SUCCESS) { 251 DCHECK_NE(net::ERR_IO_PENDING, net_error);
249 bool is_redirect = request->response_headers() && 252
250 net::HttpResponseHeaders::IsRedirectResponseCode( 253 if (net_error != net::OK) {
251 request->response_headers()->response_code()); 254 ExtensionWebRequestEventRouter::GetInstance()->OnErrorOccurred(
252 if (!is_redirect) { 255 profile_, extension_info_map_.get(),
253 ExtensionWebRequestEventRouter::GetInstance()->OnCompleted( 256 GetExtensionNavigationUIData(request), request, started, net_error);
254 profile_, extension_info_map_.get(),
255 GetExtensionNavigationUIData(request), request);
256 }
257 return; 257 return;
258 } 258 }
259 259
260 if (request->status().status() == net::URLRequestStatus::FAILED || 260 bool is_redirect = request->response_headers() &&
261 request->status().status() == net::URLRequestStatus::CANCELED) { 261 net::HttpResponseHeaders::IsRedirectResponseCode(
262 ExtensionWebRequestEventRouter::GetInstance()->OnErrorOccurred( 262 request->response_headers()->response_code());
263 if (!is_redirect) {
264 ExtensionWebRequestEventRouter::GetInstance()->OnCompleted(
263 profile_, extension_info_map_.get(), 265 profile_, extension_info_map_.get(),
264 GetExtensionNavigationUIData(request), request, started); 266 GetExtensionNavigationUIData(request), request, net_error);
265 return;
266 } 267 }
267
268 NOTREACHED();
269 } 268 }
270 269
271 void ChromeExtensionsNetworkDelegateImpl::OnURLRequestDestroyed( 270 void ChromeExtensionsNetworkDelegateImpl::OnURLRequestDestroyed(
272 net::URLRequest* request) { 271 net::URLRequest* request) {
273 ExtensionWebRequestEventRouter::GetInstance()->OnURLRequestDestroyed( 272 ExtensionWebRequestEventRouter::GetInstance()->OnURLRequestDestroyed(
274 profile_, request); 273 profile_, request);
275 } 274 }
276 275
277 void ChromeExtensionsNetworkDelegateImpl::OnPACScriptError( 276 void ChromeExtensionsNetworkDelegateImpl::OnPACScriptError(
278 int line_number, 277 int line_number,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 ChromeExtensionsNetworkDelegate::~ChromeExtensionsNetworkDelegate() {} 313 ChromeExtensionsNetworkDelegate::~ChromeExtensionsNetworkDelegate() {}
315 314
316 void ChromeExtensionsNetworkDelegate::set_extension_info_map( 315 void ChromeExtensionsNetworkDelegate::set_extension_info_map(
317 extensions::InfoMap* extension_info_map) { 316 extensions::InfoMap* extension_info_map) {
318 #if defined(ENABLE_EXTENSIONS) 317 #if defined(ENABLE_EXTENSIONS)
319 extension_info_map_ = extension_info_map; 318 extension_info_map_ = extension_info_map;
320 #endif 319 #endif
321 } 320 }
322 321
323 void ChromeExtensionsNetworkDelegate::ForwardProxyErrors( 322 void ChromeExtensionsNetworkDelegate::ForwardProxyErrors(
324 net::URLRequest* request) { 323 net::URLRequest* request,
325 } 324 int net_error) {}
326 325
327 void ChromeExtensionsNetworkDelegate::ForwardStartRequestStatus( 326 void ChromeExtensionsNetworkDelegate::ForwardStartRequestStatus(
328 net::URLRequest* request) { 327 net::URLRequest* request) {
329 } 328 }
330 329
331 void ChromeExtensionsNetworkDelegate::ForwardDoneRequestStatus( 330 void ChromeExtensionsNetworkDelegate::ForwardDoneRequestStatus(
332 net::URLRequest* request) { 331 net::URLRequest* request) {
333 } 332 }
334 333
335 int ChromeExtensionsNetworkDelegate::OnBeforeURLRequest( 334 int ChromeExtensionsNetworkDelegate::OnBeforeURLRequest(
(...skipping 21 matching lines...) Expand all
357 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, 356 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
358 GURL* allowed_unsafe_redirect_url) { 357 GURL* allowed_unsafe_redirect_url) {
359 return net::OK; 358 return net::OK;
360 } 359 }
361 360
362 void ChromeExtensionsNetworkDelegate::OnBeforeRedirect( 361 void ChromeExtensionsNetworkDelegate::OnBeforeRedirect(
363 net::URLRequest* request, 362 net::URLRequest* request,
364 const GURL& new_location) { 363 const GURL& new_location) {
365 } 364 }
366 365
366 void ChromeExtensionsNetworkDelegate::OnResponseStarted(
367 net::URLRequest* request,
368 int net_error) {}
367 369
368 void ChromeExtensionsNetworkDelegate::OnResponseStarted( 370 void ChromeExtensionsNetworkDelegate::OnCompleted(net::URLRequest* request,
369 net::URLRequest* request) { 371 bool started,
370 } 372 int net_error) {}
371
372 void ChromeExtensionsNetworkDelegate::OnCompleted(
373 net::URLRequest* request,
374 bool started) {
375 }
376 373
377 void ChromeExtensionsNetworkDelegate::OnURLRequestDestroyed( 374 void ChromeExtensionsNetworkDelegate::OnURLRequestDestroyed(
378 net::URLRequest* request) { 375 net::URLRequest* request) {
379 } 376 }
380 377
381 void ChromeExtensionsNetworkDelegate::OnPACScriptError( 378 void ChromeExtensionsNetworkDelegate::OnPACScriptError(
382 int line_number, 379 int line_number,
383 const base::string16& error) { 380 const base::string16& error) {
384 } 381 }
385 382
386 net::NetworkDelegate::AuthRequiredResponse 383 net::NetworkDelegate::AuthRequiredResponse
387 ChromeExtensionsNetworkDelegate::OnAuthRequired( 384 ChromeExtensionsNetworkDelegate::OnAuthRequired(
388 net::URLRequest* request, 385 net::URLRequest* request,
389 const net::AuthChallengeInfo& auth_info, 386 const net::AuthChallengeInfo& auth_info,
390 const AuthCallback& callback, 387 const AuthCallback& callback,
391 net::AuthCredentials* credentials) { 388 net::AuthCredentials* credentials) {
392 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; 389 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
393 } 390 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_extensions_network_delegate.h ('k') | chrome/browser/net/chrome_network_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698