OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 case Reload: | 622 case Reload: |
623 memoryCache()->remove(resource.get()); | 623 memoryCache()->remove(resource.get()); |
624 // Fall through | 624 // Fall through |
625 case Load: | 625 case Load: |
626 resource = loadResource(type, request, request.charset()); | 626 resource = loadResource(type, request, request.charset()); |
627 break; | 627 break; |
628 case Revalidate: | 628 case Revalidate: |
629 resource = revalidateResource(request, resource.get()); | 629 resource = revalidateResource(request, resource.get()); |
630 break; | 630 break; |
631 case Use: | 631 case Use: |
632 resource->updateForAccess(); | 632 memoryCache()->updateForAccess(resource.get()); |
633 notifyLoadedFromMemoryCache(resource.get()); | 633 notifyLoadedFromMemoryCache(resource.get()); |
634 break; | 634 break; |
635 } | 635 } |
636 | 636 |
637 if (!resource) | 637 if (!resource) |
638 return 0; | 638 return 0; |
639 | 639 |
640 if (!resource->hasClients()) | 640 if (!resource->hasClients()) |
641 m_deadStatsRecorder.update(policy); | 641 m_deadStatsRecorder.update(policy); |
642 | 642 |
643 if (policy != Use) | 643 if (policy != Use) |
644 resource->setIdentifier(createUniqueIdentifier()); | 644 resource->setIdentifier(createUniqueIdentifier()); |
645 | 645 |
646 if (!request.forPreload() || policy != Use) { | 646 if (!request.forPreload() || policy != Use) { |
647 ResourceLoadPriority priority = loadPriority(type, request); | 647 ResourceLoadPriority priority = loadPriority(type, request); |
648 if (priority != resource->resourceRequest().priority()) { | 648 if (priority != resource->resourceRequest().priority()) { |
649 resource->resourceRequest().setPriority(priority); | 649 resource->resourceRequest().setPriority(priority); |
650 resource->didChangePriority(priority); | 650 resource->didChangePriority(priority); |
651 } | 651 } |
652 } | 652 } |
653 | 653 |
654 if (resourceNeedsLoad(resource.get(), request, policy)) { | 654 if (resourceNeedsLoad(resource.get(), request, policy)) { |
655 if (!shouldLoadNewResource(type)) { | 655 if (!shouldLoadNewResource(type)) { |
656 if (resource->inCache()) | 656 if (memoryCache()->contains(resource.get())) |
657 memoryCache()->remove(resource.get()); | 657 memoryCache()->remove(resource.get()); |
658 return 0; | 658 return 0; |
659 } | 659 } |
660 | 660 |
661 if (!m_documentLoader || !m_documentLoader->scheduleArchiveLoad(resource
.get(), request.resourceRequest())) | 661 if (!m_documentLoader || !m_documentLoader->scheduleArchiveLoad(resource
.get(), request.resourceRequest())) |
662 resource->load(this, request.options()); | 662 resource->load(this, request.options()); |
663 | 663 |
664 // For asynchronous loads that immediately fail, it's sufficient to retu
rn a | 664 // For asynchronous loads that immediately fail, it's sufficient to retu
rn a |
665 // null Resource, as it indicates that something prevented the load from
starting. | 665 // null Resource, as it indicates that something prevented the load from
starting. |
666 // If there's a network error, that failure will happen asynchronously.
However, if | 666 // If there's a network error, that failure will happen asynchronously.
However, if |
667 // a sync load receives a network error, it will have already happened b
y this point. | 667 // a sync load receives a network error, it will have already happened b
y this point. |
668 // In that case, the requester should have access to the relevant Resour
ceError, so | 668 // In that case, the requester should have access to the relevant Resour
ceError, so |
669 // we need to return a non-null Resource. | 669 // we need to return a non-null Resource. |
670 if (resource->errorOccurred()) { | 670 if (resource->errorOccurred()) { |
671 if (resource->inCache()) | 671 if (memoryCache()->contains(resource.get())) |
672 memoryCache()->remove(resource.get()); | 672 memoryCache()->remove(resource.get()); |
673 return request.options().synchronousPolicy == RequestSynchronously ?
resource : 0; | 673 return request.options().synchronousPolicy == RequestSynchronously ?
resource : 0; |
674 } | 674 } |
675 } | 675 } |
676 | 676 |
677 // FIXME: Temporarily leave main resource caching disabled for chromium, | 677 // FIXME: Temporarily leave main resource caching disabled for chromium, |
678 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main | 678 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main |
679 // resources, we should be sure to understand the implications for memory | 679 // resources, we should be sure to understand the implications for memory |
680 // use. | 680 // use. |
681 // | 681 // |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 determineTargetType(request, type); | 767 determineTargetType(request, type); |
768 if (type == Resource::LinkPrefetch || type == Resource::LinkSubresource) | 768 if (type == Resource::LinkPrefetch || type == Resource::LinkSubresource) |
769 request.setHTTPHeaderField("Purpose", "prefetch"); | 769 request.setHTTPHeaderField("Purpose", "prefetch"); |
770 | 770 |
771 context().addAdditionalRequestHeaders(document(), request, (type == Resource
::MainResource) ? FetchMainResource : FetchSubresource); | 771 context().addAdditionalRequestHeaders(document(), request, (type == Resource
::MainResource) ? FetchMainResource : FetchSubresource); |
772 } | 772 } |
773 | 773 |
774 ResourcePtr<Resource> ResourceFetcher::revalidateResource(const FetchRequest& re
quest, Resource* resource) | 774 ResourcePtr<Resource> ResourceFetcher::revalidateResource(const FetchRequest& re
quest, Resource* resource) |
775 { | 775 { |
776 ASSERT(resource); | 776 ASSERT(resource); |
777 ASSERT(resource->inCache()); | 777 ASSERT(memoryCache()->contains(resource)); |
778 ASSERT(resource->isLoaded()); | 778 ASSERT(resource->isLoaded()); |
779 ASSERT(resource->canUseCacheValidator()); | 779 ASSERT(resource->canUseCacheValidator()); |
780 ASSERT(!resource->resourceToRevalidate()); | 780 ASSERT(!resource->resourceToRevalidate()); |
781 | 781 |
782 ResourceRequest revalidatingRequest(resource->resourceRequest()); | 782 ResourceRequest revalidatingRequest(resource->resourceRequest()); |
783 revalidatingRequest.clearHTTPReferrer(); | 783 revalidatingRequest.clearHTTPReferrer(); |
784 addAdditionalRequestHeaders(revalidatingRequest, resource->type()); | 784 addAdditionalRequestHeaders(revalidatingRequest, resource->type()); |
785 | 785 |
786 const AtomicString& lastModified = resource->response().httpHeaderField("Las
t-Modified"); | 786 const AtomicString& lastModified = resource->response().httpHeaderField("Las
t-Modified"); |
787 const AtomicString& eTag = resource->response().httpHeaderField("ETag"); | 787 const AtomicString& eTag = resource->response().httpHeaderField("ETag"); |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 case Revalidate: | 1395 case Revalidate: |
1396 ++m_revalidateCount; | 1396 ++m_revalidateCount; |
1397 return; | 1397 return; |
1398 case Use: | 1398 case Use: |
1399 ++m_useCount; | 1399 ++m_useCount; |
1400 return; | 1400 return; |
1401 } | 1401 } |
1402 } | 1402 } |
1403 | 1403 |
1404 } | 1404 } |
OLD | NEW |