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

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: fix test crash 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 763
764 // FIXME: Temporarily leave main resource caching disabled for chromium, 764 // FIXME: Temporarily leave main resource caching disabled for chromium,
765 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main 765 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main
766 // resources, we should be sure to understand the implications for memory 766 // resources, we should be sure to understand the implications for memory
767 // use. 767 // use.
768 // Remove main resource from cache to prevent reuse. 768 // Remove main resource from cache to prevent reuse.
769 if (type == Resource::MainResource) { 769 if (type == Resource::MainResource) {
770 ASSERT(policy != Use || m_documentLoader->substituteData().isValid()); 770 ASSERT(policy != Use || m_documentLoader->substituteData().isValid());
771 ASSERT(policy != Revalidate); 771 ASSERT(policy != Revalidate);
772 memoryCache()->remove(resource.get()); 772 memoryCache()->remove(resource.get());
773 } else {
774 // Remove a resource to be handled by Service Worker from the cache to
775 // prevent reuse because Service Worker can serve an arbitrary resource
776 // for an URL and pollute a memory cache entry.
777 // FIXME: isControlledByServiceWorker() always returns false on main
778 // resource request, but main resource is always removed from the cache
779 // as the above comment (http://crbug.com/388375).
780 if (frame() && m_documentLoader && frame()->loader().client()->isControl ledByServiceWorker(*m_documentLoader)) {
781 ASSERT(policy == Load || policy == Reload);
782 memoryCache()->remove(resource.get());
Nate Chapin 2014/10/09 17:56:22 Re: "(*) I'm not sure we can fetch a resource to b
nhiroki 2014/10/10 06:20:37 Thank you for your detailed answer! I'll take a lo
783 }
773 } 784 }
774 785
775 requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingF romCache : ResourceLoadingFromNetwork); 786 requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingF romCache : ResourceLoadingFromNetwork);
776 787
777 ASSERT(resource->url() == url.string()); 788 ASSERT(resource->url() == url.string());
778 m_documentResources.set(resource->url(), resource); 789 m_documentResources.set(resource->url(), resource);
779 return resource; 790 return resource;
780 } 791 }
781 792
782 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim er) 793 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim er)
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 } 932 }
922 } 933 }
923 934
924 ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy (Resource::Type type, const FetchRequest& fetchRequest, Resource* existingResour ce) const 935 ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy (Resource::Type type, const FetchRequest& fetchRequest, Resource* existingResour ce) const
925 { 936 {
926 const ResourceRequest& request = fetchRequest.resourceRequest(); 937 const ResourceRequest& request = fetchRequest.resourceRequest();
927 938
928 if (!existingResource) 939 if (!existingResource)
929 return Load; 940 return Load;
930 941
942 // FIXME: Currently caching for a resource to be handled by Service Worker
943 // is disabled (http://crbug.com/388375).
944 if (frame() && m_documentLoader && frame()->loader().client()->isControlledB yServiceWorker(*m_documentLoader))
945 return Reload;
946
931 // We already have a preload going for this URL. 947 // We already have a preload going for this URL.
932 if (fetchRequest.forPreload() && existingResource->isPreloaded()) 948 if (fetchRequest.forPreload() && existingResource->isPreloaded())
933 return Use; 949 return Use;
934 950
935 // If the same URL has been loaded as a different type, we need to reload. 951 // If the same URL has been loaded as a different type, we need to reload.
936 if (existingResource->type() != type) { 952 if (existingResource->type() != type) {
937 // FIXME: If existingResource is a Preload and the new type is LinkPrefe tch 953 // FIXME: If existingResource is a Preload and the new type is LinkPrefe tch
938 // We really should discard the new prefetch since the preload has more 954 // We really should discard the new prefetch since the preload has more
939 // specific type information! crbug.com/379893 955 // specific type information! crbug.com/379893
940 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case. 956 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case.
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 1539
1524 void ResourceFetcher::trace(Visitor* visitor) 1540 void ResourceFetcher::trace(Visitor* visitor)
1525 { 1541 {
1526 visitor->trace(m_document); 1542 visitor->trace(m_document);
1527 visitor->trace(m_loaders); 1543 visitor->trace(m_loaders);
1528 visitor->trace(m_multipartLoaders); 1544 visitor->trace(m_multipartLoaders);
1529 ResourceLoaderHost::trace(visitor); 1545 ResourceLoaderHost::trace(visitor);
1530 } 1546 }
1531 1547
1532 } 1548 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698