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

Side by Side Diff: Source/core/loader/DocumentThreadableLoader.cpp

Issue 1262593004: Prevent ThreadableLoaderClient methods from being called after failure notification (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Don't clear the resource in didFinishLoading Created 5 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 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013, Intel Corporation 3 * Copyright (C) 2013, Intel Corporation
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 , m_requestContext(request.requestContext()) 93 , m_requestContext(request.requestContext())
94 , m_timeoutTimer(this, &DocumentThreadableLoader::didTimeout) 94 , m_timeoutTimer(this, &DocumentThreadableLoader::didTimeout)
95 , m_requestStartedSeconds(0.0) 95 , m_requestStartedSeconds(0.0)
96 , m_corsRedirectLimit(kMaxCORSRedirects) 96 , m_corsRedirectLimit(kMaxCORSRedirects)
97 { 97 {
98 ASSERT(client); 98 ASSERT(client);
99 // Setting an outgoing referer is only supported in the async code path. 99 // Setting an outgoing referer is only supported in the async code path.
100 ASSERT(m_async || request.httpReferrer().isEmpty()); 100 ASSERT(m_async || request.httpReferrer().isEmpty());
101 101
102 if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == DenyCrossO riginRequests) { 102 if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == DenyCrossO riginRequests) {
103 m_client->didFail(ResourceError(errorDomainBlinkInternal, 0, request.url ().string(), "Cross origin requests are not supported.")); 103 ThreadableLoaderClient* client = m_client;
104 clear();
105 client->didFail(ResourceError(errorDomainBlinkInternal, 0, request.url() .string(), "Cross origin requests are not supported."));
106 // |this| may be dead here.
104 return; 107 return;
105 } 108 }
106 109
107 m_requestStartedSeconds = monotonicallyIncreasingTime(); 110 m_requestStartedSeconds = monotonicallyIncreasingTime();
108 111
109 // Save any CORS simple headers on the request here. If this request redirec ts cross-origin, we cancel the old request 112 // Save any CORS simple headers on the request here. If this request redirec ts cross-origin, we cancel the old request
110 // create a new one, and copy these headers. 113 // create a new one, and copy these headers.
111 const HTTPHeaderMap& headerMap = request.httpHeaderFields(); 114 const HTTPHeaderMap& headerMap = request.httpHeaderFields();
112 for (const auto& header : headerMap) { 115 for (const auto& header : headerMap) {
113 if (FetchUtils::isSimpleHeader(header.key, header.value)) 116 if (FetchUtils::isSimpleHeader(header.key, header.value))
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 154 }
152 155
153 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); 156 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl);
154 157
155 makeCrossOriginAccessRequest(request); 158 makeCrossOriginAccessRequest(request);
156 } 159 }
157 160
158 void DocumentThreadableLoader::makeCrossOriginAccessRequest(const ResourceReques t& request) 161 void DocumentThreadableLoader::makeCrossOriginAccessRequest(const ResourceReques t& request)
159 { 162 {
160 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); 163 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl);
164 ASSERT(!resource());
161 165
162 // Cross-origin requests are only allowed certain registered schemes. 166 // Cross-origin requests are only allowed certain registered schemes.
163 // We would catch this when checking response headers later, but there 167 // We would catch this when checking response headers later, but there
164 // is no reason to send a request, preflighted or not, that's guaranteed 168 // is no reason to send a request, preflighted or not, that's guaranteed
165 // to be denied. 169 // to be denied.
166 if (!SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(request.url().protoco l())) { 170 if (!SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(request.url().protoco l())) {
167 m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkIntern al, 0, request.url().string(), "Cross origin requests are only supported for pro tocol schemes: " + SchemeRegistry::listOfCORSEnabledURLSchemes() + ".")); 171 ThreadableLoaderClient* client = m_client;
172 clear();
173 client->didFailAccessControlCheck(ResourceError(errorDomainBlinkInternal , 0, request.url().string(), "Cross origin requests are only supported for proto col schemes: " + SchemeRegistry::listOfCORSEnabledURLSchemes() + "."));
174 // |this| may be dead here.
168 return; 175 return;
169 } 176 }
170 177
171 // We use isSimpleOrForbiddenRequest() here since |request| may have been 178 // We use isSimpleOrForbiddenRequest() here since |request| may have been
172 // modified in the process of loading (not from the user's input). For 179 // modified in the process of loading (not from the user's input). For
173 // example, referrer. We need to accept them. For security, we must reject 180 // example, referrer. We need to accept them. For security, we must reject
174 // forbidden headers/methods at the point we accept user's input. Not here. 181 // forbidden headers/methods at the point we accept user's input. Not here.
175 if ((m_options.preflightPolicy == ConsiderPreflight && FetchUtils::isSimpleO rForbiddenRequest(request.httpMethod(), request.httpHeaderFields())) || m_option s.preflightPolicy == PreventPreflight) { 182 if ((m_options.preflightPolicy == ConsiderPreflight && FetchUtils::isSimpleO rForbiddenRequest(request.httpMethod(), request.httpHeaderFields())) || m_option s.preflightPolicy == PreventPreflight) {
176 ResourceRequest crossOriginRequest(request); 183 ResourceRequest crossOriginRequest(request);
177 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions); 184 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 232 }
226 } 233 }
227 234
228 void DocumentThreadableLoader::cancel() 235 void DocumentThreadableLoader::cancel()
229 { 236 {
230 cancelWithError(ResourceError()); 237 cancelWithError(ResourceError());
231 } 238 }
232 239
233 void DocumentThreadableLoader::cancelWithError(const ResourceError& error) 240 void DocumentThreadableLoader::cancelWithError(const ResourceError& error)
234 { 241 {
235 RefPtr<DocumentThreadableLoader> protect(this);
236
237 // Cancel can re-enter and m_resource might be null here as a result. 242 // Cancel can re-enter and m_resource might be null here as a result.
238 if (m_client && resource()) { 243 if (m_client && resource()) {
239 ResourceError errorForCallback = error; 244 ResourceError errorForCallback = error;
240 if (errorForCallback.isNull()) { 245 if (errorForCallback.isNull()) {
241 // FIXME: This error is sent to the client in didFail(), so it shoul d not be an internal one. Use FrameLoaderClient::cancelledError() instead. 246 // FIXME: This error is sent to the client in didFail(), so it shoul d not be an internal one. Use FrameLoaderClient::cancelledError() instead.
242 errorForCallback = ResourceError(errorDomainBlinkInternal, 0, resour ce()->url().string(), "Load cancelled"); 247 errorForCallback = ResourceError(errorDomainBlinkInternal, 0, resour ce()->url().string(), "Load cancelled");
243 errorForCallback.setIsCancellation(true); 248 errorForCallback.setIsCancellation(true);
244 } 249 }
245 m_client->didFail(errorForCallback); 250
251 ThreadableLoaderClient* client = m_client;
252 clear();
253 client->didFail(errorForCallback);
254 // |this| may be dead here.
255 } else {
256 clear();
246 } 257 }
247 clearResource();
248 m_client = 0;
249 m_requestStartedSeconds = 0.0;
250 } 258 }
251 259
252 void DocumentThreadableLoader::setDefersLoading(bool value) 260 void DocumentThreadableLoader::setDefersLoading(bool value)
253 { 261 {
254 if (resource()) 262 if (resource())
255 resource()->setDefersLoading(value); 263 resource()->setDefersLoading(value);
256 } 264 }
257 265
266 void DocumentThreadableLoader::clear()
267 {
268 m_client = 0;
269
270 if (!m_async)
271 return;
272
273 clearResource();
274 m_timeoutTimer.stop();
275 m_requestStartedSeconds = 0.0;
276 }
277
258 // In this method, we can clear |request| to tell content::WebURLLoaderImpl of 278 // In this method, we can clear |request| to tell content::WebURLLoaderImpl of
259 // Chromium not to follow the redirect. This works only when this method is 279 // Chromium not to follow the redirect. This works only when this method is
260 // called by RawResource::willSendRequest(). If called by 280 // called by RawResource::willSendRequest(). If called by
261 // RawResource::didAddClient(), clearing |request| won't be propagated 281 // RawResource::didAddClient(), clearing |request| won't be propagated
262 // to content::WebURLLoaderImpl. So, this loader must also get detached from 282 // to content::WebURLLoaderImpl. So, this loader must also get detached from
263 // the resource by calling clearResource(). 283 // the resource by calling clearResource().
264 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ est& request, const ResourceResponse& redirectResponse) 284 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ est& request, const ResourceResponse& redirectResponse)
265 { 285 {
266 ASSERT(m_client); 286 ASSERT(m_client);
267 ASSERT_UNUSED(resource, resource == this->resource()); 287 ASSERT_UNUSED(resource, resource == this->resource());
268 ASSERT(m_async); 288 ASSERT(m_async);
269 289
270 RefPtr<DocumentThreadableLoader> protect(this); 290 RefPtr<DocumentThreadableLoader> protect(this);
271 291
272 if (!isAllowedByContentSecurityPolicy(request.url(), ContentSecurityPolicy:: DidRedirect)) { 292 if (!isAllowedByContentSecurityPolicy(request.url(), ContentSecurityPolicy:: DidRedirect)) {
273 m_client->didFailRedirectCheck(); 293 ThreadableLoaderClient* client = m_client;
294 clear();
295 client->didFailRedirectCheck();
296 // |this| may be dead here.
274 297
275 clearResource();
276 request = ResourceRequest(); 298 request = ResourceRequest();
277 299
278 m_requestStartedSeconds = 0.0;
279 return; 300 return;
280 } 301 }
281 302
282 // Allow same origin requests to continue after allowing clients to audit th e redirect. 303 // Allow same origin requests to continue after allowing clients to audit th e redirect.
283 if (isAllowedRedirect(request.url())) { 304 if (isAllowedRedirect(request.url())) {
284 if (m_client->isDocumentThreadableLoaderClient()) 305 if (m_client->isDocumentThreadableLoaderClient())
285 static_cast<DocumentThreadableLoaderClient*>(m_client)->willFollowRe direct(request, redirectResponse); 306 static_cast<DocumentThreadableLoaderClient*>(m_client)->willFollowRe direct(request, redirectResponse);
286 return; 307 return;
287 } 308 }
288 309
289 if (m_corsRedirectLimit <= 0) { 310 if (m_corsRedirectLimit <= 0) {
290 m_client->didFailRedirectCheck(); 311 ThreadableLoaderClient* client = m_client;
312 clear();
313 client->didFailRedirectCheck();
314 // |this| may be dead here.
291 } else if (m_options.crossOriginRequestPolicy == UseAccessControl) { 315 } else if (m_options.crossOriginRequestPolicy == UseAccessControl) {
292 --m_corsRedirectLimit; 316 --m_corsRedirectLimit;
293 317
294 InspectorInstrumentation::didReceiveCORSRedirectResponse(m_document.fram e(), resource->identifier(), m_document.frame()->loader().documentLoader(), redi rectResponse, 0); 318 InspectorInstrumentation::didReceiveCORSRedirectResponse(m_document.fram e(), resource->identifier(), m_document.frame()->loader().documentLoader(), redi rectResponse, 0);
295 319
296 bool allowRedirect = false; 320 bool allowRedirect = false;
297 String accessControlErrorDescription; 321 String accessControlErrorDescription;
298 322
299 // Non-simple cross origin requests (both preflight and actual one) are 323 // Non-simple cross origin requests (both preflight and actual one) are
300 // not allowed to follow redirect. 324 // not allowed to follow redirect.
(...skipping 30 matching lines...) Expand all
331 request.clearHTTPReferrer(); 355 request.clearHTTPReferrer();
332 request.clearHTTPOrigin(); 356 request.clearHTTPOrigin();
333 request.clearHTTPUserAgent(); 357 request.clearHTTPUserAgent();
334 // Add any CORS simple request headers which we previously saved fro m the original request. 358 // Add any CORS simple request headers which we previously saved fro m the original request.
335 for (const auto& header : m_simpleRequestHeaders) 359 for (const auto& header : m_simpleRequestHeaders)
336 request.setHTTPHeaderField(header.key, header.value); 360 request.setHTTPHeaderField(header.key, header.value);
337 makeCrossOriginAccessRequest(request); 361 makeCrossOriginAccessRequest(request);
338 return; 362 return;
339 } 363 }
340 364
341 ResourceError error(errorDomainBlinkInternal, 0, redirectResponse.url(). string(), accessControlErrorDescription); 365 ThreadableLoaderClient* client = m_client;
342 m_client->didFailAccessControlCheck(error); 366 clear();
367 client->didFailAccessControlCheck(ResourceError(errorDomainBlinkInternal , 0, redirectResponse.url().string(), accessControlErrorDescription));
368 // |this| may be dead here.
343 } else { 369 } else {
344 m_client->didFailRedirectCheck(); 370 ThreadableLoaderClient* client = m_client;
371 clear();
372 client->didFailRedirectCheck();
373 // |this| may be dead here.
345 } 374 }
346 375
347 clearResource();
348 request = ResourceRequest(); 376 request = ResourceRequest();
349
350 m_requestStartedSeconds = 0.0;
351 } 377 }
352 378
353 void DocumentThreadableLoader::dataSent(Resource* resource, unsigned long long b ytesSent, unsigned long long totalBytesToBeSent) 379 void DocumentThreadableLoader::dataSent(Resource* resource, unsigned long long b ytesSent, unsigned long long totalBytesToBeSent)
354 { 380 {
355 ASSERT(m_client); 381 ASSERT(m_client);
356 ASSERT_UNUSED(resource, resource == this->resource()); 382 ASSERT_UNUSED(resource, resource == this->resource());
357 ASSERT(m_async); 383 ASSERT(m_async);
358 384
359 m_client->didSendData(bytesSent, totalBytesToBeSent); 385 m_client->didSendData(bytesSent, totalBytesToBeSent);
360 } 386 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 // loadFallbackRequestForServiceWorker(). 487 // loadFallbackRequestForServiceWorker().
462 // FIXME: We should use |m_sameOriginRequest| when we will support 488 // FIXME: We should use |m_sameOriginRequest| when we will support
463 // Suborigins (crbug.com/336894) for Service Worker. 489 // Suborigins (crbug.com/336894) for Service Worker.
464 ASSERT(!m_fallbackRequestForServiceWorker || securityOrigin()->canRequest(m_ fallbackRequestForServiceWorker->url())); 490 ASSERT(!m_fallbackRequestForServiceWorker || securityOrigin()->canRequest(m_ fallbackRequestForServiceWorker->url()));
465 m_fallbackRequestForServiceWorker = nullptr; 491 m_fallbackRequestForServiceWorker = nullptr;
466 492
467 if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == UseAccessC ontrol) { 493 if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == UseAccessC ontrol) {
468 String accessControlErrorDescription; 494 String accessControlErrorDescription;
469 if (!passesAccessControlCheck(response, effectiveAllowCredentials(), sec urityOrigin(), accessControlErrorDescription)) { 495 if (!passesAccessControlCheck(response, effectiveAllowCredentials(), sec urityOrigin(), accessControlErrorDescription)) {
470 reportResponseReceived(identifier, response); 496 reportResponseReceived(identifier, response);
471 m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkIn ternal, 0, response.url().string(), accessControlErrorDescription)); 497
498 ThreadableLoaderClient* client = m_client;
499 clear();
500 client->didFailAccessControlCheck(ResourceError(errorDomainBlinkInte rnal, 0, response.url().string(), accessControlErrorDescription));
501 // |this| may be dead here.
472 return; 502 return;
473 } 503 }
474 } 504 }
475 505
476 m_client->didReceiveResponse(identifier, response, handle); 506 m_client->didReceiveResponse(identifier, response, handle);
477 } 507 }
478 508
479 void DocumentThreadableLoader::setSerializedCachedMetadata(Resource*, const char * data, size_t size) 509 void DocumentThreadableLoader::setSerializedCachedMetadata(Resource*, const char * data, size_t size)
480 { 510 {
481 if (m_actualRequest) 511 if (m_actualRequest)
(...skipping 24 matching lines...) Expand all
506 536
507 m_client->didReceiveData(data, dataLength); 537 m_client->didReceiveData(data, dataLength);
508 } 538 }
509 539
510 void DocumentThreadableLoader::notifyFinished(Resource* resource) 540 void DocumentThreadableLoader::notifyFinished(Resource* resource)
511 { 541 {
512 ASSERT(m_client); 542 ASSERT(m_client);
513 ASSERT(resource == this->resource()); 543 ASSERT(resource == this->resource());
514 ASSERT(m_async); 544 ASSERT(m_async);
515 545
516 m_timeoutTimer.stop(); 546 if (resource->errorOccurred()) {
517 547 ThreadableLoaderClient* client = m_client;
518 if (resource->errorOccurred()) 548 ResourceError error = resource->resourceError();
519 m_client->didFail(resource->resourceError()); 549 clear();
520 else 550 client->didFail(error);
551 // |this| may be dead here.
552 } else {
521 handleSuccessfulFinish(resource->identifier(), resource->loadFinishTime( )); 553 handleSuccessfulFinish(resource->identifier(), resource->loadFinishTime( ));
hiroshige 2015/08/03 13:22:19 m_timeoutTimer.stop() is not executed in this bran
tyoshino (SeeGerritForStatus) 2015/08/04 08:32:05 handleSuccessfulFinish does it. If it's just compl
hiroshige 2015/08/04 10:20:16 I see, thanks.
554 }
522 } 555 }
523 556
524 void DocumentThreadableLoader::handleSuccessfulFinish(unsigned long identifier, double finishTime) 557 void DocumentThreadableLoader::handleSuccessfulFinish(unsigned long identifier, double finishTime)
525 { 558 {
526 ASSERT(!m_fallbackRequestForServiceWorker); 559 ASSERT(!m_fallbackRequestForServiceWorker);
527 560
528 if (m_actualRequest) { 561 if (m_actualRequest) {
529 ASSERT(!m_sameOriginRequest); 562 ASSERT(!m_sameOriginRequest);
530 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); 563 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl);
531 loadActualRequest(); 564 loadActualRequest();
532 } else { 565 } else {
533 // FIXME: Should prevent timeout from being overridden after finished lo ading, without 566 ThreadableLoaderClient* client = m_client;
534 // resetting m_requestStartedSeconds to 0.0 567 m_client = 0;
535 m_client->didFinishLoading(identifier, finishTime); 568 if (m_async) {
569 m_timeoutTimer.stop();
570 m_requestStartedSeconds = 0.0;
571 }
572 client->didFinishLoading(identifier, finishTime);
573 // |this| may be dead here.
536 } 574 }
537 } 575 }
538 576
539 void DocumentThreadableLoader::didTimeout(Timer<DocumentThreadableLoader>* timer ) 577 void DocumentThreadableLoader::didTimeout(Timer<DocumentThreadableLoader>* timer )
540 { 578 {
541 ASSERT_UNUSED(timer, timer == &m_timeoutTimer); 579 ASSERT_UNUSED(timer, timer == &m_timeoutTimer);
542 580
543 // Using values from net/base/net_error_list.h ERR_TIMED_OUT, 581 // Using values from net/base/net_error_list.h ERR_TIMED_OUT,
544 // Same as existing FIXME above - this error should be coming from FrameLoad erClient to be identifiable. 582 // Same as existing FIXME above - this error should be coming from FrameLoad erClient to be identifiable.
545 static const int timeoutError = -7; 583 static const int timeoutError = -7;
(...skipping 23 matching lines...) Expand all
569 loadRequest(*actualRequest, *actualOptions); 607 loadRequest(*actualRequest, *actualOptions);
570 } 608 }
571 609
572 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S tring& errorDescription) 610 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S tring& errorDescription)
573 { 611 {
574 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); 612 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription);
575 613
576 // Prevent handleSuccessfulFinish() from bypassing access check. 614 // Prevent handleSuccessfulFinish() from bypassing access check.
577 m_actualRequest = nullptr; 615 m_actualRequest = nullptr;
578 616
579 // FIXME: Should prevent timeout from being overridden after preflight failu re, without 617 ThreadableLoaderClient* client = m_client;
580 // resetting m_requestStartedSeconds to 0.0 618 clear();
581 m_client->didFailAccessControlCheck(error); 619 client->didFailAccessControlCheck(error);
620 // |this| may be dead here.
582 } 621 }
583 622
584 void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Resou rceLoaderOptions resourceLoaderOptions) 623 void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Resou rceLoaderOptions resourceLoaderOptions)
585 { 624 {
586 // Any credential should have been removed from the cross-site requests. 625 // Any credential should have been removed from the cross-site requests.
587 const KURL& requestURL = request.url(); 626 const KURL& requestURL = request.url();
588 ASSERT(m_sameOriginRequest || requestURL.user().isEmpty()); 627 ASSERT(m_sameOriginRequest || requestURL.user().isEmpty());
589 ASSERT(m_sameOriginRequest || requestURL.pass().isEmpty()); 628 ASSERT(m_sameOriginRequest || requestURL.pass().isEmpty());
590 629
591 // Update resourceLoaderOptions with enforced values. 630 // Update resourceLoaderOptions with enforced values.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 // FIXME: A synchronous request does not tell us whether a redirect happened or not, so we guess by comparing the 678 // FIXME: A synchronous request does not tell us whether a redirect happened or not, so we guess by comparing the
640 // request and response URLs. This isn't a perfect test though, since a serv er can serve a redirect to the same URL that was 679 // request and response URLs. This isn't a perfect test though, since a serv er can serve a redirect to the same URL that was
641 // requested. Also comparing the request and response URLs as strings will f ail if the requestURL still has its credentials. 680 // requested. Also comparing the request and response URLs as strings will f ail if the requestURL still has its credentials.
642 if (requestURL != response.url() && (!isAllowedByContentSecurityPolicy(respo nse.url(), ContentSecurityPolicy::DidRedirect) || !isAllowedRedirect(response.ur l()))) { 681 if (requestURL != response.url() && (!isAllowedByContentSecurityPolicy(respo nse.url(), ContentSecurityPolicy::DidRedirect) || !isAllowedRedirect(response.ur l()))) {
643 m_client->didFailRedirectCheck(); 682 m_client->didFailRedirectCheck();
644 return; 683 return;
645 } 684 }
646 685
647 handleResponse(identifier, response, nullptr); 686 handleResponse(identifier, response, nullptr);
648 687
688 // handleResponse() may detect an error. In such a case (check |m_client|
689 // as it gets reset by clear() call), skip the rest.
690 //
691 // |this| is alive here since loadResourceSynchronously() keeps it alive
692 // until the end of the function.
693 if (!m_client)
694 return;
695
649 SharedBuffer* data = resource->resourceBuffer(); 696 SharedBuffer* data = resource->resourceBuffer();
650 if (data) 697 if (data)
651 handleReceivedData(data->data(), data->size()); 698 handleReceivedData(data->data(), data->size());
652 699
653 handleSuccessfulFinish(identifier, 0.0); 700 handleSuccessfulFinish(identifier, 0.0);
654 } 701 }
655 702
656 bool DocumentThreadableLoader::isAllowedRedirect(const KURL& url) const 703 bool DocumentThreadableLoader::isAllowedRedirect(const KURL& url) const
657 { 704 {
658 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) 705 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests)
(...skipping 15 matching lines...) Expand all
674 return DoNotAllowStoredCredentials; 721 return DoNotAllowStoredCredentials;
675 return m_resourceLoaderOptions.allowCredentials; 722 return m_resourceLoaderOptions.allowCredentials;
676 } 723 }
677 724
678 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const 725 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const
679 { 726 {
680 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin (); 727 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin ();
681 } 728 }
682 729
683 } // namespace blink 730 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698