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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 // called by RawResource::willSendRequest(). If called by | 418 // called by RawResource::willSendRequest(). If called by |
419 // RawResource::didAddClient(), clearing |request| won't be propagated | 419 // RawResource::didAddClient(), clearing |request| won't be propagated |
420 // to content::WebURLLoaderImpl. So, this loader must also get detached from | 420 // to content::WebURLLoaderImpl. So, this loader must also get detached from |
421 // the resource by calling clearResource(). | 421 // the resource by calling clearResource(). |
422 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ
est& request, const ResourceResponse& redirectResponse) | 422 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ
est& request, const ResourceResponse& redirectResponse) |
423 { | 423 { |
424 ASSERT(m_client); | 424 ASSERT(m_client); |
425 ASSERT_UNUSED(resource, resource == this->resource()); | 425 ASSERT_UNUSED(resource, resource == this->resource()); |
426 ASSERT(m_async); | 426 ASSERT(m_async); |
427 | 427 |
| 428 m_checker.redirectReceived(); |
| 429 |
428 if (!m_actualRequest.isNull()) { | 430 if (!m_actualRequest.isNull()) { |
429 reportResponseReceived(resource->identifier(), redirectResponse); | 431 reportResponseReceived(resource->identifier(), redirectResponse); |
430 | 432 |
431 handlePreflightFailure(redirectResponse.url().getString(), "Response for
preflight is invalid (redirect)"); | 433 handlePreflightFailure(redirectResponse.url().getString(), "Response for
preflight is invalid (redirect)"); |
432 // |this| may be dead here. | 434 // |this| may be dead here. |
433 | 435 |
434 request = ResourceRequest(); | 436 request = ResourceRequest(); |
435 | 437 |
436 return; | 438 return; |
437 } | 439 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 clear(); | 553 clear(); |
552 client->didFailRedirectCheck(); | 554 client->didFailRedirectCheck(); |
553 // |this| may be dead here. | 555 // |this| may be dead here. |
554 } | 556 } |
555 | 557 |
556 request = ResourceRequest(); | 558 request = ResourceRequest(); |
557 } | 559 } |
558 | 560 |
559 void DocumentThreadableLoader::redirectBlocked() | 561 void DocumentThreadableLoader::redirectBlocked() |
560 { | 562 { |
| 563 m_checker.redirectBlocked(); |
| 564 |
561 // Tells the client that a redirect was received but not followed (for an un
known reason). | 565 // Tells the client that a redirect was received but not followed (for an un
known reason). |
562 ThreadableLoaderClient* client = m_client; | 566 ThreadableLoaderClient* client = m_client; |
563 clear(); | 567 clear(); |
564 client->didFailRedirectCheck(); | 568 client->didFailRedirectCheck(); |
565 // |this| may be dead here | 569 // |this| may be dead here |
566 } | 570 } |
567 | 571 |
568 void DocumentThreadableLoader::dataSent(Resource* resource, unsigned long long b
ytesSent, unsigned long long totalBytesToBeSent) | 572 void DocumentThreadableLoader::dataSent(Resource* resource, unsigned long long b
ytesSent, unsigned long long totalBytesToBeSent) |
569 { | 573 { |
570 ASSERT(m_client); | 574 ASSERT(m_client); |
571 ASSERT_UNUSED(resource, resource == this->resource()); | 575 ASSERT_UNUSED(resource, resource == this->resource()); |
572 ASSERT(m_async); | 576 ASSERT(m_async); |
573 | 577 |
| 578 m_checker.dataSent(); |
574 m_client->didSendData(bytesSent, totalBytesToBeSent); | 579 m_client->didSendData(bytesSent, totalBytesToBeSent); |
575 // |this| may be dead here. | 580 // |this| may be dead here. |
576 } | 581 } |
577 | 582 |
578 void DocumentThreadableLoader::dataDownloaded(Resource* resource, int dataLength
) | 583 void DocumentThreadableLoader::dataDownloaded(Resource* resource, int dataLength
) |
579 { | 584 { |
580 ASSERT(m_client); | 585 ASSERT(m_client); |
581 ASSERT_UNUSED(resource, resource == this->resource()); | 586 ASSERT_UNUSED(resource, resource == this->resource()); |
582 ASSERT(m_actualRequest.isNull()); | 587 ASSERT(m_actualRequest.isNull()); |
583 ASSERT(m_async); | 588 ASSERT(m_async); |
584 | 589 |
| 590 m_checker.dataDownloaded(); |
585 m_client->didDownloadData(dataLength); | 591 m_client->didDownloadData(dataLength); |
586 // |this| may be dead here. | 592 // |this| may be dead here. |
587 } | 593 } |
588 | 594 |
589 void DocumentThreadableLoader::didReceiveResourceTiming(Resource* resource, cons
t ResourceTimingInfo& info) | 595 void DocumentThreadableLoader::didReceiveResourceTiming(Resource* resource, cons
t ResourceTimingInfo& info) |
590 { | 596 { |
591 ASSERT(m_client); | 597 ASSERT(m_client); |
592 ASSERT_UNUSED(resource, resource == this->resource()); | 598 ASSERT_UNUSED(resource, resource == this->resource()); |
593 ASSERT(m_async); | 599 ASSERT(m_async); |
594 | 600 |
595 m_client->didReceiveResourceTiming(info); | 601 m_client->didReceiveResourceTiming(info); |
596 // |this| may be dead here. | 602 // |this| may be dead here. |
597 } | 603 } |
598 | 604 |
599 void DocumentThreadableLoader::responseReceived(Resource* resource, const Resour
ceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle) | 605 void DocumentThreadableLoader::responseReceived(Resource* resource, const Resour
ceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle) |
600 { | 606 { |
601 ASSERT_UNUSED(resource, resource == this->resource()); | 607 ASSERT_UNUSED(resource, resource == this->resource()); |
602 ASSERT(m_async); | 608 ASSERT(m_async); |
603 | 609 |
| 610 m_checker.responseReceived(); |
| 611 |
604 if (handle) | 612 if (handle) |
605 m_isUsingDataConsumerHandle = true; | 613 m_isUsingDataConsumerHandle = true; |
606 | 614 |
607 handleResponse(resource->identifier(), response, std::move(handle)); | 615 handleResponse(resource->identifier(), response, std::move(handle)); |
608 // |this| may be dead here. | 616 // |this| may be dead here. |
609 } | 617 } |
610 | 618 |
611 void DocumentThreadableLoader::handlePreflightResponse(const ResourceResponse& r
esponse) | 619 void DocumentThreadableLoader::handlePreflightResponse(const ResourceResponse& r
esponse) |
612 { | 620 { |
613 String accessControlErrorDescription; | 621 String accessControlErrorDescription; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 // |this| may be dead here. | 715 // |this| may be dead here. |
708 return; | 716 return; |
709 } | 717 } |
710 } | 718 } |
711 | 719 |
712 m_client->didReceiveResponse(identifier, response, std::move(handle)); | 720 m_client->didReceiveResponse(identifier, response, std::move(handle)); |
713 } | 721 } |
714 | 722 |
715 void DocumentThreadableLoader::setSerializedCachedMetadata(Resource*, const char
* data, size_t size) | 723 void DocumentThreadableLoader::setSerializedCachedMetadata(Resource*, const char
* data, size_t size) |
716 { | 724 { |
| 725 m_checker.setSerializedCachedMetadata(); |
| 726 |
717 if (!m_actualRequest.isNull()) | 727 if (!m_actualRequest.isNull()) |
718 return; | 728 return; |
719 m_client->didReceiveCachedMetadata(data, size); | 729 m_client->didReceiveCachedMetadata(data, size); |
720 // |this| may be dead here. | 730 // |this| may be dead here. |
721 } | 731 } |
722 | 732 |
723 void DocumentThreadableLoader::dataReceived(Resource* resource, const char* data
, size_t dataLength) | 733 void DocumentThreadableLoader::dataReceived(Resource* resource, const char* data
, size_t dataLength) |
724 { | 734 { |
725 ASSERT_UNUSED(resource, resource == this->resource()); | 735 ASSERT_UNUSED(resource, resource == this->resource()); |
726 ASSERT(m_async); | 736 ASSERT(m_async); |
727 | 737 |
| 738 m_checker.dataReceived(); |
| 739 |
728 if (m_isUsingDataConsumerHandle) | 740 if (m_isUsingDataConsumerHandle) |
729 return; | 741 return; |
730 | 742 |
731 // TODO(junov): Fix the ThreadableLoader ecosystem to use size_t. | 743 // TODO(junov): Fix the ThreadableLoader ecosystem to use size_t. |
732 // Until then, we use safeCast to trap potential overflows. | 744 // Until then, we use safeCast to trap potential overflows. |
733 handleReceivedData(data, safeCast<unsigned>(dataLength)); | 745 handleReceivedData(data, safeCast<unsigned>(dataLength)); |
734 // |this| may be dead here. | 746 // |this| may be dead here. |
735 } | 747 } |
736 | 748 |
737 void DocumentThreadableLoader::handleReceivedData(const char* data, size_t dataL
ength) | 749 void DocumentThreadableLoader::handleReceivedData(const char* data, size_t dataL
ength) |
738 { | 750 { |
739 ASSERT(m_client); | 751 ASSERT(m_client); |
740 | 752 |
741 // Preflight data should be invisible to clients. | 753 // Preflight data should be invisible to clients. |
742 if (!m_actualRequest.isNull()) | 754 if (!m_actualRequest.isNull()) |
743 return; | 755 return; |
744 | 756 |
745 ASSERT(m_fallbackRequestForServiceWorker.isNull()); | 757 ASSERT(m_fallbackRequestForServiceWorker.isNull()); |
746 | 758 |
747 m_client->didReceiveData(data, dataLength); | 759 m_client->didReceiveData(data, dataLength); |
748 // |this| may be dead here in async mode. | 760 // |this| may be dead here in async mode. |
749 } | 761 } |
750 | 762 |
751 void DocumentThreadableLoader::notifyFinished(Resource* resource) | 763 void DocumentThreadableLoader::notifyFinished(Resource* resource) |
752 { | 764 { |
753 ASSERT(m_client); | 765 ASSERT(m_client); |
754 ASSERT(resource == this->resource()); | 766 ASSERT(resource == this->resource()); |
755 ASSERT(m_async); | 767 ASSERT(m_async); |
756 | 768 |
| 769 m_checker.notifyFinished(resource); |
| 770 |
757 if (resource->errorOccurred()) { | 771 if (resource->errorOccurred()) { |
758 handleError(resource->resourceError()); | 772 handleError(resource->resourceError()); |
759 // |this| may be dead here. | 773 // |this| may be dead here. |
760 } else { | 774 } else { |
761 handleSuccessfulFinish(resource->identifier(), resource->loadFinishTime(
)); | 775 handleSuccessfulFinish(resource->identifier(), resource->loadFinishTime(
)); |
762 // |this| may be dead here. | 776 // |this| may be dead here. |
763 } | 777 } |
764 } | 778 } |
765 | 779 |
766 void DocumentThreadableLoader::handleSuccessfulFinish(unsigned long identifier,
double finishTime) | 780 void DocumentThreadableLoader::handleSuccessfulFinish(unsigned long identifier,
double finishTime) |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri
gin(); | 1005 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri
gin(); |
992 } | 1006 } |
993 | 1007 |
994 Document& DocumentThreadableLoader::document() const | 1008 Document& DocumentThreadableLoader::document() const |
995 { | 1009 { |
996 ASSERT(m_document); | 1010 ASSERT(m_document); |
997 return *m_document; | 1011 return *m_document; |
998 } | 1012 } |
999 | 1013 |
1000 } // namespace blink | 1014 } // namespace blink |
OLD | NEW |