Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: Source/core/fetch/ResourceFetcher.cpp

Issue 632213002: Fetcher: Disable memory caching when Service Worker handles a request (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tweak test Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 777
778 // FIXME: Temporarily leave main resource caching disabled for chromium, 778 // FIXME: Temporarily leave main resource caching disabled for chromium,
779 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main 779 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main
780 // resources, we should be sure to understand the implications for memory 780 // resources, we should be sure to understand the implications for memory
781 // use. 781 // use.
782 // Remove main resource from cache to prevent reuse. 782 // Remove main resource from cache to prevent reuse.
783 if (type == Resource::MainResource) { 783 if (type == Resource::MainResource) {
784 ASSERT(policy != Use || m_documentLoader->substituteData().isValid()); 784 ASSERT(policy != Use || m_documentLoader->substituteData().isValid());
785 ASSERT(policy != Revalidate); 785 ASSERT(policy != Revalidate);
786 memoryCache()->remove(resource.get()); 786 memoryCache()->remove(resource.get());
787 } else {
788 // Remove a resource to be handled by Service Worker from the cache to
789 // prevent reuse because Service Worker can serve an arbitrary resource
790 // for an URL and pollute a memory cache entry.
791 // FIXME: isControlledByServiceWorker() always returns false on main
792 // resource request, but main resource is always removed from the cache
793 // as the above comment (http://crbug.com/388375).
794 if (frame() && m_documentLoader && frame()->loader().client()->isControl ledByServiceWorker(*m_documentLoader)) {
795 ASSERT(policy == Load || policy == Reload);
796 memoryCache()->remove(resource.get());
797 }
787 } 798 }
788 799
789 requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingF romCache : ResourceLoadingFromNetwork); 800 requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingF romCache : ResourceLoadingFromNetwork);
790 801
791 ASSERT(resource->url() == url.string()); 802 ASSERT(resource->url() == url.string());
792 m_documentResources.set(resource->url(), resource); 803 m_documentResources.set(resource->url(), resource);
793 return resource; 804 return resource;
794 } 805 }
795 806
796 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim er) 807 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim er)
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 } 946 }
936 } 947 }
937 948
938 ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy (Resource::Type type, const FetchRequest& fetchRequest, Resource* existingResour ce) const 949 ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy (Resource::Type type, const FetchRequest& fetchRequest, Resource* existingResour ce) const
939 { 950 {
940 const ResourceRequest& request = fetchRequest.resourceRequest(); 951 const ResourceRequest& request = fetchRequest.resourceRequest();
941 952
942 if (!existingResource) 953 if (!existingResource)
943 return Load; 954 return Load;
944 955
956 // FIXME: Currently caching for a resource to be handled by Service Worker
957 // is disabled (http://crbug.com/388375).
958 if (frame() && m_documentLoader && frame()->loader().client()->isControlledB yServiceWorker(*m_documentLoader))
959 return Reload;
960
945 // We already have a preload going for this URL. 961 // We already have a preload going for this URL.
946 if (fetchRequest.forPreload() && existingResource->isPreloaded()) 962 if (fetchRequest.forPreload() && existingResource->isPreloaded())
947 return Use; 963 return Use;
948 964
949 // If the same URL has been loaded as a different type, we need to reload. 965 // If the same URL has been loaded as a different type, we need to reload.
950 if (existingResource->type() != type) { 966 if (existingResource->type() != type) {
951 // FIXME: If existingResource is a Preload and the new type is LinkPrefe tch 967 // FIXME: If existingResource is a Preload and the new type is LinkPrefe tch
952 // We really should discard the new prefetch since the preload has more 968 // We really should discard the new prefetch since the preload has more
953 // specific type information! crbug.com/379893 969 // specific type information! crbug.com/379893
954 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case. 970 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case.
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 1553
1538 void ResourceFetcher::trace(Visitor* visitor) 1554 void ResourceFetcher::trace(Visitor* visitor)
1539 { 1555 {
1540 visitor->trace(m_document); 1556 visitor->trace(m_document);
1541 visitor->trace(m_loaders); 1557 visitor->trace(m_loaders);
1542 visitor->trace(m_multipartLoaders); 1558 visitor->trace(m_multipartLoaders);
1543 ResourceLoaderHost::trace(visitor); 1559 ResourceLoaderHost::trace(visitor);
1544 } 1560 }
1545 1561
1546 } 1562 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698