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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
667 m_resourceTimingReportTimer.startOneShot(0, FROM_HERE); | 667 m_resourceTimingReportTimer.startOneShot(0, FROM_HERE); |
668 } | 668 } |
669 | 669 |
670 m_validatedURLs.add(request.resourceRequest().url()); | 670 m_validatedURLs.add(request.resourceRequest().url()); |
671 } | 671 } |
672 | 672 |
673 ResourcePtr<Resource> ResourceFetcher::requestResource(Resource::Type type, Fetc hRequest& request) | 673 ResourcePtr<Resource> ResourceFetcher::requestResource(Resource::Type type, Fetc hRequest& request) |
674 { | 674 { |
675 ASSERT(request.options().synchronousPolicy == RequestAsynchronously || type == Resource::Raw); | 675 ASSERT(request.options().synchronousPolicy == RequestAsynchronously || type == Resource::Raw); |
676 | 676 |
677 // If loading main resource ensure main resources aren't preloaded. | |
678 if (type == Resource::MainResource && request.forPreload()) { | |
Nate Chapin
2014/06/06 23:00:01
Ok. What if we move both this and the old code blo
| |
679 return 0; | |
680 } | |
681 | |
677 TRACE_EVENT0("webkit", "ResourceFetcher::requestResource"); | 682 TRACE_EVENT0("webkit", "ResourceFetcher::requestResource"); |
678 | 683 |
679 KURL url = request.resourceRequest().url(); | 684 KURL url = request.resourceRequest().url(); |
680 | 685 |
681 WTF_LOG(ResourceLoading, "ResourceFetcher::requestResource '%s', charset '%s ', priority=%d, forPreload=%u, type=%s", url.elidedString().latin1().data(), req uest.charset().latin1().data(), request.priority(), request.forPreload(), Resour ceTypeName(type)); | 686 WTF_LOG(ResourceLoading, "ResourceFetcher::requestResource '%s', charset '%s ', priority=%d, forPreload=%u, type=%s", url.elidedString().latin1().data(), req uest.charset().latin1().data(), request.priority(), request.forPreload(), Resour ceTypeName(type)); |
682 | 687 |
683 // If only the fragment identifiers differ, it is the same resource. | 688 // If only the fragment identifiers differ, it is the same resource. |
684 url = MemoryCache::removeFragmentIdentifierIfNeeded(url); | 689 url = MemoryCache::removeFragmentIdentifierIfNeeded(url); |
685 | 690 |
686 if (!url.isValid()) | 691 if (!url.isValid()) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 memoryCache()->remove(resource.get()); | 754 memoryCache()->remove(resource.get()); |
750 return request.options().synchronousPolicy == RequestSynchronously ? resource : 0; | 755 return request.options().synchronousPolicy == RequestSynchronously ? resource : 0; |
751 } | 756 } |
752 } | 757 } |
753 | 758 |
754 // FIXME: Temporarily leave main resource caching disabled for chromium, | 759 // FIXME: Temporarily leave main resource caching disabled for chromium, |
755 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main | 760 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main |
756 // resources, we should be sure to understand the implications for memory | 761 // resources, we should be sure to understand the implications for memory |
757 // use. | 762 // use. |
758 // | 763 // |
759 // Ensure main resources aren't preloaded, and other main resource loads | 764 // Main resource loads are removed from cache to prevent reuse. |
760 // are removed from cache to prevent reuse. | |
761 if (type == Resource::MainResource) { | 765 if (type == Resource::MainResource) { |
762 ASSERT(policy != Use || m_documentLoader->substituteData().isValid()); | 766 ASSERT(policy != Use || m_documentLoader->substituteData().isValid()); |
763 ASSERT(policy != Revalidate); | 767 ASSERT(policy != Revalidate); |
764 memoryCache()->remove(resource.get()); | 768 memoryCache()->remove(resource.get()); |
765 if (request.forPreload()) | |
766 return 0; | |
767 } | 769 } |
768 | 770 |
769 requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingF romCache : ResourceLoadingFromNetwork); | 771 requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingF romCache : ResourceLoadingFromNetwork); |
770 | 772 |
771 ASSERT(resource->url() == url.string()); | 773 ASSERT(resource->url() == url.string()); |
772 m_documentResources.set(resource->url(), resource); | 774 m_documentResources.set(resource->url(), resource); |
773 return resource; | 775 return resource; |
774 } | 776 } |
775 | 777 |
776 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim er) | 778 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim er) |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1492 } | 1494 } |
1493 } | 1495 } |
1494 | 1496 |
1495 void ResourceFetcher::trace(Visitor* visitor) | 1497 void ResourceFetcher::trace(Visitor* visitor) |
1496 { | 1498 { |
1497 visitor->trace(m_document); | 1499 visitor->trace(m_document); |
1498 ResourceLoaderHost::trace(visitor); | 1500 ResourceLoaderHost::trace(visitor); |
1499 } | 1501 } |
1500 | 1502 |
1501 } | 1503 } |
OLD | NEW |