| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 // called by RawResource::willSendRequest(). If called by | 414 // called by RawResource::willSendRequest(). If called by |
| 415 // RawResource::didAddClient(), clearing |request| won't be propagated | 415 // RawResource::didAddClient(), clearing |request| won't be propagated |
| 416 // to content::WebURLLoaderImpl. So, this loader must also get detached from | 416 // to content::WebURLLoaderImpl. So, this loader must also get detached from |
| 417 // the resource by calling clearResource(). | 417 // the resource by calling clearResource(). |
| 418 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ
est& request, const ResourceResponse& redirectResponse) | 418 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ
est& request, const ResourceResponse& redirectResponse) |
| 419 { | 419 { |
| 420 ASSERT(m_client); | 420 ASSERT(m_client); |
| 421 ASSERT_UNUSED(resource, resource == this->resource()); | 421 ASSERT_UNUSED(resource, resource == this->resource()); |
| 422 ASSERT(m_async); | 422 ASSERT(m_async); |
| 423 | 423 |
| 424 m_checker.redirectReceived(); |
| 425 |
| 424 if (!m_actualRequest.isNull()) { | 426 if (!m_actualRequest.isNull()) { |
| 425 reportResponseReceived(resource->identifier(), redirectResponse); | 427 reportResponseReceived(resource->identifier(), redirectResponse); |
| 426 | 428 |
| 427 handlePreflightFailure(redirectResponse.url().getString(), "Response for
preflight is invalid (redirect)"); | 429 handlePreflightFailure(redirectResponse.url().getString(), "Response for
preflight is invalid (redirect)"); |
| 428 | 430 |
| 429 request = ResourceRequest(); | 431 request = ResourceRequest(); |
| 430 | 432 |
| 431 return; | 433 return; |
| 432 } | 434 } |
| 433 | 435 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 request.clearHTTPUserAgent(); | 550 request.clearHTTPUserAgent(); |
| 549 // Add any CORS simple request headers which we previously saved from the or
iginal request. | 551 // Add any CORS simple request headers which we previously saved from the or
iginal request. |
| 550 for (const auto& header : m_simpleRequestHeaders) | 552 for (const auto& header : m_simpleRequestHeaders) |
| 551 request.setHTTPHeaderField(header.key, header.value); | 553 request.setHTTPHeaderField(header.key, header.value); |
| 552 makeCrossOriginAccessRequest(request); | 554 makeCrossOriginAccessRequest(request); |
| 553 // |this| may be dead here. | 555 // |this| may be dead here. |
| 554 } | 556 } |
| 555 | 557 |
| 556 void DocumentThreadableLoader::redirectBlocked() | 558 void DocumentThreadableLoader::redirectBlocked() |
| 557 { | 559 { |
| 560 m_checker.redirectBlocked(); |
| 561 |
| 558 // Tells the client that a redirect was received but not followed (for an un
known reason). | 562 // Tells the client that a redirect was received but not followed (for an un
known reason). |
| 559 ThreadableLoaderClient* client = m_client; | 563 ThreadableLoaderClient* client = m_client; |
| 560 clear(); | 564 clear(); |
| 561 client->didFailRedirectCheck(); | 565 client->didFailRedirectCheck(); |
| 562 } | 566 } |
| 563 | 567 |
| 564 void DocumentThreadableLoader::dataSent(Resource* resource, unsigned long long b
ytesSent, unsigned long long totalBytesToBeSent) | 568 void DocumentThreadableLoader::dataSent(Resource* resource, unsigned long long b
ytesSent, unsigned long long totalBytesToBeSent) |
| 565 { | 569 { |
| 566 ASSERT(m_client); | 570 ASSERT(m_client); |
| 567 ASSERT_UNUSED(resource, resource == this->resource()); | 571 ASSERT_UNUSED(resource, resource == this->resource()); |
| 568 ASSERT(m_async); | 572 ASSERT(m_async); |
| 569 | 573 |
| 574 m_checker.dataSent(); |
| 570 m_client->didSendData(bytesSent, totalBytesToBeSent); | 575 m_client->didSendData(bytesSent, totalBytesToBeSent); |
| 571 } | 576 } |
| 572 | 577 |
| 573 void DocumentThreadableLoader::dataDownloaded(Resource* resource, int dataLength
) | 578 void DocumentThreadableLoader::dataDownloaded(Resource* resource, int dataLength
) |
| 574 { | 579 { |
| 575 ASSERT(m_client); | 580 ASSERT(m_client); |
| 576 ASSERT_UNUSED(resource, resource == this->resource()); | 581 ASSERT_UNUSED(resource, resource == this->resource()); |
| 577 ASSERT(m_actualRequest.isNull()); | 582 ASSERT(m_actualRequest.isNull()); |
| 578 ASSERT(m_async); | 583 ASSERT(m_async); |
| 579 | 584 |
| 585 m_checker.dataDownloaded(); |
| 580 m_client->didDownloadData(dataLength); | 586 m_client->didDownloadData(dataLength); |
| 581 } | 587 } |
| 582 | 588 |
| 583 void DocumentThreadableLoader::didReceiveResourceTiming(Resource* resource, cons
t ResourceTimingInfo& info) | 589 void DocumentThreadableLoader::didReceiveResourceTiming(Resource* resource, cons
t ResourceTimingInfo& info) |
| 584 { | 590 { |
| 585 ASSERT(m_client); | 591 ASSERT(m_client); |
| 586 ASSERT_UNUSED(resource, resource == this->resource()); | 592 ASSERT_UNUSED(resource, resource == this->resource()); |
| 587 ASSERT(m_async); | 593 ASSERT(m_async); |
| 588 | 594 |
| 589 m_client->didReceiveResourceTiming(info); | 595 m_client->didReceiveResourceTiming(info); |
| 590 } | 596 } |
| 591 | 597 |
| 592 void DocumentThreadableLoader::responseReceived(Resource* resource, const Resour
ceResponse& response, std::unique_ptr<WebDataConsumerHandle> handle) | 598 void DocumentThreadableLoader::responseReceived(Resource* resource, const Resour
ceResponse& response, std::unique_ptr<WebDataConsumerHandle> handle) |
| 593 { | 599 { |
| 594 ASSERT_UNUSED(resource, resource == this->resource()); | 600 ASSERT_UNUSED(resource, resource == this->resource()); |
| 595 ASSERT(m_async); | 601 ASSERT(m_async); |
| 596 | 602 |
| 603 m_checker.responseReceived(); |
| 604 |
| 597 if (handle) | 605 if (handle) |
| 598 m_isUsingDataConsumerHandle = true; | 606 m_isUsingDataConsumerHandle = true; |
| 599 | 607 |
| 600 handleResponse(resource->identifier(), response, std::move(handle)); | 608 handleResponse(resource->identifier(), response, std::move(handle)); |
| 601 } | 609 } |
| 602 | 610 |
| 603 void DocumentThreadableLoader::handlePreflightResponse(const ResourceResponse& r
esponse) | 611 void DocumentThreadableLoader::handlePreflightResponse(const ResourceResponse& r
esponse) |
| 604 { | 612 { |
| 605 String accessControlErrorDescription; | 613 String accessControlErrorDescription; |
| 606 | 614 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 client->didFailAccessControlCheck(ResourceError(errorDomainBlinkInte
rnal, 0, response.url().getString(), accessControlErrorDescription)); | 702 client->didFailAccessControlCheck(ResourceError(errorDomainBlinkInte
rnal, 0, response.url().getString(), accessControlErrorDescription)); |
| 695 return; | 703 return; |
| 696 } | 704 } |
| 697 } | 705 } |
| 698 | 706 |
| 699 m_client->didReceiveResponse(identifier, response, std::move(handle)); | 707 m_client->didReceiveResponse(identifier, response, std::move(handle)); |
| 700 } | 708 } |
| 701 | 709 |
| 702 void DocumentThreadableLoader::setSerializedCachedMetadata(Resource*, const char
* data, size_t size) | 710 void DocumentThreadableLoader::setSerializedCachedMetadata(Resource*, const char
* data, size_t size) |
| 703 { | 711 { |
| 712 m_checker.setSerializedCachedMetadata(); |
| 713 |
| 704 if (!m_actualRequest.isNull()) | 714 if (!m_actualRequest.isNull()) |
| 705 return; | 715 return; |
| 706 m_client->didReceiveCachedMetadata(data, size); | 716 m_client->didReceiveCachedMetadata(data, size); |
| 707 } | 717 } |
| 708 | 718 |
| 709 void DocumentThreadableLoader::dataReceived(Resource* resource, const char* data
, size_t dataLength) | 719 void DocumentThreadableLoader::dataReceived(Resource* resource, const char* data
, size_t dataLength) |
| 710 { | 720 { |
| 711 ASSERT_UNUSED(resource, resource == this->resource()); | 721 ASSERT_UNUSED(resource, resource == this->resource()); |
| 712 ASSERT(m_async); | 722 ASSERT(m_async); |
| 713 | 723 |
| 724 m_checker.dataReceived(); |
| 725 |
| 714 if (m_isUsingDataConsumerHandle) | 726 if (m_isUsingDataConsumerHandle) |
| 715 return; | 727 return; |
| 716 | 728 |
| 717 // TODO(junov): Fix the ThreadableLoader ecosystem to use size_t. | 729 // TODO(junov): Fix the ThreadableLoader ecosystem to use size_t. |
| 718 // Until then, we use safeCast to trap potential overflows. | 730 // Until then, we use safeCast to trap potential overflows. |
| 719 handleReceivedData(data, safeCast<unsigned>(dataLength)); | 731 handleReceivedData(data, safeCast<unsigned>(dataLength)); |
| 720 } | 732 } |
| 721 | 733 |
| 722 void DocumentThreadableLoader::handleReceivedData(const char* data, size_t dataL
ength) | 734 void DocumentThreadableLoader::handleReceivedData(const char* data, size_t dataL
ength) |
| 723 { | 735 { |
| 724 ASSERT(m_client); | 736 ASSERT(m_client); |
| 725 | 737 |
| 726 // Preflight data should be invisible to clients. | 738 // Preflight data should be invisible to clients. |
| 727 if (!m_actualRequest.isNull()) | 739 if (!m_actualRequest.isNull()) |
| 728 return; | 740 return; |
| 729 | 741 |
| 730 ASSERT(m_fallbackRequestForServiceWorker.isNull()); | 742 ASSERT(m_fallbackRequestForServiceWorker.isNull()); |
| 731 | 743 |
| 732 m_client->didReceiveData(data, dataLength); | 744 m_client->didReceiveData(data, dataLength); |
| 733 } | 745 } |
| 734 | 746 |
| 735 void DocumentThreadableLoader::notifyFinished(Resource* resource) | 747 void DocumentThreadableLoader::notifyFinished(Resource* resource) |
| 736 { | 748 { |
| 737 ASSERT(m_client); | 749 ASSERT(m_client); |
| 738 ASSERT(resource == this->resource()); | 750 ASSERT(resource == this->resource()); |
| 739 ASSERT(m_async); | 751 ASSERT(m_async); |
| 740 | 752 |
| 753 m_checker.notifyFinished(resource); |
| 754 |
| 741 if (resource->errorOccurred()) { | 755 if (resource->errorOccurred()) { |
| 742 handleError(resource->resourceError()); | 756 handleError(resource->resourceError()); |
| 743 } else { | 757 } else { |
| 744 handleSuccessfulFinish(resource->identifier(), resource->loadFinishTime(
)); | 758 handleSuccessfulFinish(resource->identifier(), resource->loadFinishTime(
)); |
| 745 } | 759 } |
| 746 } | 760 } |
| 747 | 761 |
| 748 void DocumentThreadableLoader::handleSuccessfulFinish(unsigned long identifier,
double finishTime) | 762 void DocumentThreadableLoader::handleSuccessfulFinish(unsigned long identifier,
double finishTime) |
| 749 { | 763 { |
| 750 ASSERT(m_fallbackRequestForServiceWorker.isNull()); | 764 ASSERT(m_fallbackRequestForServiceWorker.isNull()); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 | 987 |
| 974 DEFINE_TRACE(DocumentThreadableLoader) | 988 DEFINE_TRACE(DocumentThreadableLoader) |
| 975 { | 989 { |
| 976 visitor->trace(m_resource); | 990 visitor->trace(m_resource); |
| 977 visitor->trace(m_document); | 991 visitor->trace(m_document); |
| 978 ThreadableLoader::trace(visitor); | 992 ThreadableLoader::trace(visitor); |
| 979 RawResourceClient::trace(visitor); | 993 RawResourceClient::trace(visitor); |
| 980 } | 994 } |
| 981 | 995 |
| 982 } // namespace blink | 996 } // namespace blink |
| OLD | NEW |