OLD | NEW |
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 void DocumentThreadableLoader::dataDownloaded(Resource* resource, int dataLength
) | 343 void DocumentThreadableLoader::dataDownloaded(Resource* resource, int dataLength
) |
344 { | 344 { |
345 ASSERT(m_client); | 345 ASSERT(m_client); |
346 ASSERT_UNUSED(resource, resource == this->resource()); | 346 ASSERT_UNUSED(resource, resource == this->resource()); |
347 ASSERT(!m_actualRequest); | 347 ASSERT(!m_actualRequest); |
348 | 348 |
349 m_client->didDownloadData(dataLength); | 349 m_client->didDownloadData(dataLength); |
350 } | 350 } |
351 | 351 |
352 void DocumentThreadableLoader::responseReceived(Resource* resource, const Resour
ceResponse& response) | 352 void DocumentThreadableLoader::responseReceived(Resource* resource, const Resour
ceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle) |
353 { | 353 { |
354 ASSERT_UNUSED(resource, resource == this->resource()); | 354 ASSERT_UNUSED(resource, resource == this->resource()); |
355 handleResponse(resource->identifier(), response); | 355 handleResponse(resource->identifier(), response, handle); |
356 } | 356 } |
357 | 357 |
358 void DocumentThreadableLoader::handlePreflightResponse(const ResourceResponse& r
esponse) | 358 void DocumentThreadableLoader::handlePreflightResponse(const ResourceResponse& r
esponse) |
359 { | 359 { |
360 String accessControlErrorDescription; | 360 String accessControlErrorDescription; |
361 | 361 |
362 if (!passesAccessControlCheck(response, effectiveAllowCredentials(), securit
yOrigin(), accessControlErrorDescription)) { | 362 if (!passesAccessControlCheck(response, effectiveAllowCredentials(), securit
yOrigin(), accessControlErrorDescription)) { |
363 handlePreflightFailure(response.url().string(), accessControlErrorDescri
ption); | 363 handlePreflightFailure(response.url().string(), accessControlErrorDescri
ption); |
364 return; | 364 return; |
365 } | 365 } |
(...skipping 17 matching lines...) Expand all Loading... |
383 void DocumentThreadableLoader::notifyResponseReceived(unsigned long identifier,
const ResourceResponse& response) | 383 void DocumentThreadableLoader::notifyResponseReceived(unsigned long identifier,
const ResourceResponse& response) |
384 { | 384 { |
385 DocumentLoader* loader = m_document.frame()->loader().documentLoader(); | 385 DocumentLoader* loader = m_document.frame()->loader().documentLoader(); |
386 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceReceiveResponse", "data", InspectorReceiveResponseEvent::data(identifier, m_do
cument.frame(), response)); | 386 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour
ceReceiveResponse", "data", InspectorReceiveResponseEvent::data(identifier, m_do
cument.frame(), response)); |
387 LocalFrame* frame = m_document.frame(); | 387 LocalFrame* frame = m_document.frame(); |
388 InspectorInstrumentation::didReceiveResourceResponse(frame, identifier, load
er, response, resource() ? resource()->loader() : 0); | 388 InspectorInstrumentation::didReceiveResourceResponse(frame, identifier, load
er, response, resource() ? resource()->loader() : 0); |
389 // It is essential that inspector gets resource response BEFORE console. | 389 // It is essential that inspector gets resource response BEFORE console. |
390 frame->console().reportResourceResponseReceived(loader, identifier, response
); | 390 frame->console().reportResourceResponseReceived(loader, identifier, response
); |
391 } | 391 } |
392 | 392 |
393 void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re
sourceResponse& response) | 393 void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re
sourceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle) |
394 { | 394 { |
395 ASSERT(m_client); | 395 ASSERT(m_client); |
396 | 396 |
397 if (m_actualRequest) { | 397 if (m_actualRequest) { |
398 notifyResponseReceived(identifier, response); | 398 notifyResponseReceived(identifier, response); |
399 handlePreflightResponse(response); | 399 handlePreflightResponse(response); |
400 return; | 400 return; |
401 } | 401 } |
402 | 402 |
403 if (response.wasFetchedViaServiceWorker()) { | 403 if (response.wasFetchedViaServiceWorker()) { |
404 ASSERT(m_fallbackRequestForServiceWorker); | 404 ASSERT(m_fallbackRequestForServiceWorker); |
405 if (response.wasFallbackRequiredByServiceWorker()) { | 405 if (response.wasFallbackRequiredByServiceWorker()) { |
406 loadFallbackRequestForServiceWorker(); | 406 loadFallbackRequestForServiceWorker(); |
407 return; | 407 return; |
408 } | 408 } |
409 m_fallbackRequestForServiceWorker = nullptr; | 409 m_fallbackRequestForServiceWorker = nullptr; |
410 m_client->didReceiveResponse(identifier, response); | 410 m_client->didReceiveResponse(identifier, response, handle); |
411 return; | 411 return; |
412 } | 412 } |
413 | 413 |
414 ASSERT(!m_fallbackRequestForServiceWorker); | 414 ASSERT(!m_fallbackRequestForServiceWorker); |
415 | 415 |
416 if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == UseAccessC
ontrol) { | 416 if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == UseAccessC
ontrol) { |
417 String accessControlErrorDescription; | 417 String accessControlErrorDescription; |
418 if (!passesAccessControlCheck(response, effectiveAllowCredentials(), sec
urityOrigin(), accessControlErrorDescription)) { | 418 if (!passesAccessControlCheck(response, effectiveAllowCredentials(), sec
urityOrigin(), accessControlErrorDescription)) { |
419 notifyResponseReceived(identifier, response); | 419 notifyResponseReceived(identifier, response); |
420 m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkIn
ternal, 0, response.url().string(), accessControlErrorDescription)); | 420 m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkIn
ternal, 0, response.url().string(), accessControlErrorDescription)); |
421 return; | 421 return; |
422 } | 422 } |
423 } | 423 } |
424 | 424 |
425 m_client->didReceiveResponse(identifier, response); | 425 m_client->didReceiveResponse(identifier, response, handle); |
426 } | 426 } |
427 | 427 |
428 void DocumentThreadableLoader::dataReceived(Resource* resource, const char* data
, unsigned dataLength) | 428 void DocumentThreadableLoader::dataReceived(Resource* resource, const char* data
, unsigned dataLength) |
429 { | 429 { |
430 ASSERT_UNUSED(resource, resource == this->resource()); | 430 ASSERT_UNUSED(resource, resource == this->resource()); |
431 handleReceivedData(data, dataLength); | 431 handleReceivedData(data, dataLength); |
432 } | 432 } |
433 | 433 |
434 void DocumentThreadableLoader::handleReceivedData(const char* data, unsigned dat
aLength) | 434 void DocumentThreadableLoader::handleReceivedData(const char* data, unsigned dat
aLength) |
435 { | 435 { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 } | 573 } |
574 | 574 |
575 // FIXME: A synchronous request does not tell us whether a redirect happened
or not, so we guess by comparing the | 575 // FIXME: A synchronous request does not tell us whether a redirect happened
or not, so we guess by comparing the |
576 // 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 | 576 // 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 |
577 // requested. Also comparing the request and response URLs as strings will f
ail if the requestURL still has its credentials. | 577 // requested. Also comparing the request and response URLs as strings will f
ail if the requestURL still has its credentials. |
578 if (requestURL != response.url() && (!isAllowedByContentSecurityPolicy(respo
nse.url()) || !isAllowedRedirect(response.url()))) { | 578 if (requestURL != response.url() && (!isAllowedByContentSecurityPolicy(respo
nse.url()) || !isAllowedRedirect(response.url()))) { |
579 m_client->didFailRedirectCheck(); | 579 m_client->didFailRedirectCheck(); |
580 return; | 580 return; |
581 } | 581 } |
582 | 582 |
583 handleResponse(identifier, response); | 583 handleResponse(identifier, response, nullptr); |
584 | 584 |
585 SharedBuffer* data = resource->resourceBuffer(); | 585 SharedBuffer* data = resource->resourceBuffer(); |
586 if (data) | 586 if (data) |
587 handleReceivedData(data->data(), data->size()); | 587 handleReceivedData(data->data(), data->size()); |
588 | 588 |
589 handleSuccessfulFinish(identifier, 0.0); | 589 handleSuccessfulFinish(identifier, 0.0); |
590 } | 590 } |
591 | 591 |
592 bool DocumentThreadableLoader::isAllowedRedirect(const KURL& url) const | 592 bool DocumentThreadableLoader::isAllowedRedirect(const KURL& url) const |
593 { | 593 { |
(...skipping 16 matching lines...) Expand all Loading... |
610 return DoNotAllowStoredCredentials; | 610 return DoNotAllowStoredCredentials; |
611 return m_resourceLoaderOptions.allowCredentials; | 611 return m_resourceLoaderOptions.allowCredentials; |
612 } | 612 } |
613 | 613 |
614 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const | 614 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const |
615 { | 615 { |
616 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin
(); | 616 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin
(); |
617 } | 617 } |
618 | 618 |
619 } // namespace blink | 619 } // namespace blink |
OLD | NEW |