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

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

Issue 703813002: [ServiceWorker] Disable the cache revalidation when the page is controlled by the ServiceWorker. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated nhiroki's comment Created 6 years, 1 month 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
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/fetch-request-no-freshness-headers-worker.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 context().addAdditionalRequestHeaders(document(), request, (type == Resource ::MainResource) ? FetchMainResource : FetchSubresource); 880 context().addAdditionalRequestHeaders(document(), request, (type == Resource ::MainResource) ? FetchMainResource : FetchSubresource);
881 } 881 }
882 882
883 ResourcePtr<Resource> ResourceFetcher::createResourceForRevalidation(const Fetch Request& request, Resource* resource) 883 ResourcePtr<Resource> ResourceFetcher::createResourceForRevalidation(const Fetch Request& request, Resource* resource)
884 { 884 {
885 ASSERT(resource); 885 ASSERT(resource);
886 ASSERT(memoryCache()->contains(resource)); 886 ASSERT(memoryCache()->contains(resource));
887 ASSERT(resource->isLoaded()); 887 ASSERT(resource->isLoaded());
888 ASSERT(resource->canUseCacheValidator()); 888 ASSERT(resource->canUseCacheValidator());
889 ASSERT(!resource->resourceToRevalidate()); 889 ASSERT(!resource->resourceToRevalidate());
890 ASSERT(!isControlledByServiceWorker());
890 891
891 ResourceRequest revalidatingRequest(resource->resourceRequest()); 892 ResourceRequest revalidatingRequest(resource->resourceRequest());
892 revalidatingRequest.clearHTTPReferrer(); 893 revalidatingRequest.clearHTTPReferrer();
893 addAdditionalRequestHeaders(revalidatingRequest, resource->type()); 894 addAdditionalRequestHeaders(revalidatingRequest, resource->type());
894 895
895 const AtomicString& lastModified = resource->response().httpHeaderField("Las t-Modified"); 896 const AtomicString& lastModified = resource->response().httpHeaderField("Las t-Modified");
896 const AtomicString& eTag = resource->response().httpHeaderField("ETag"); 897 const AtomicString& eTag = resource->response().httpHeaderField("ETag");
897 if (!lastModified.isEmpty() || !eTag.isEmpty()) { 898 if (!lastModified.isEmpty() || !eTag.isEmpty()) {
898 ASSERT(context().cachePolicy(document()) != CachePolicyReload); 899 ASSERT(context().cachePolicy(document()) != CachePolicyReload);
899 if (context().cachePolicy(document()) == CachePolicyRevalidate) 900 if (context().cachePolicy(document()) == CachePolicyRevalidate)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 // If any of the redirects in the chain to loading the resource were not cac heable, we cannot reuse our cached resource. 1070 // If any of the redirects in the chain to loading the resource were not cac heable, we cannot reuse our cached resource.
1070 if (!existingResource->canReuseRedirectChain()) { 1071 if (!existingResource->canReuseRedirectChain()) {
1071 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to an uncacheable redirect"); 1072 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to an uncacheable redirect");
1072 return Reload; 1073 return Reload;
1073 } 1074 }
1074 1075
1075 // Check if the cache headers requires us to revalidate (cache expiration fo r example). 1076 // Check if the cache headers requires us to revalidate (cache expiration fo r example).
1076 if (cachePolicy == CachePolicyRevalidate || existingResource->mustRevalidate DueToCacheHeaders() 1077 if (cachePolicy == CachePolicyRevalidate || existingResource->mustRevalidate DueToCacheHeaders()
1077 || request.cacheControlContainsNoCache()) { 1078 || request.cacheControlContainsNoCache()) {
1078 // See if the resource has usable ETag or Last-modified headers. 1079 // See if the resource has usable ETag or Last-modified headers.
1079 if (existingResource->canUseCacheValidator()) 1080 // If the page is controlled by the ServiceWorker, we choose the Reload policy because the revalidation headers should not be exposed to the ServiceWork er.(crbug.com/429570)
1081 if (existingResource->canUseCacheValidator() && !isControlledByServiceWo rker())
1080 return Revalidate; 1082 return Revalidate;
1081 1083
1082 // No, must reload. 1084 // No, must reload.
1083 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to missing cache validators."); 1085 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to missing cache validators.");
1084 return Reload; 1086 return Reload;
1085 } 1087 }
1086 1088
1087 return Use; 1089 return Use;
1088 } 1090 }
1089 1091
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 1562
1561 void ResourceFetcher::trace(Visitor* visitor) 1563 void ResourceFetcher::trace(Visitor* visitor)
1562 { 1564 {
1563 visitor->trace(m_document); 1565 visitor->trace(m_document);
1564 visitor->trace(m_loaders); 1566 visitor->trace(m_loaders);
1565 visitor->trace(m_multipartLoaders); 1567 visitor->trace(m_multipartLoaders);
1566 ResourceLoaderHost::trace(visitor); 1568 ResourceLoaderHost::trace(visitor);
1567 } 1569 }
1568 1570
1569 } 1571 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/fetch-request-no-freshness-headers-worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698