Chromium Code Reviews| 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 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 (existingResource->canUseCacheValidator() && !isControlledByServiceWo rker()) |
|
nhiroki
2014/11/05 07:38:35
Can we have a link to the issue and a comment abou
horo
2014/11/05 08:48:03
Done.
| |
| 1080 return Revalidate; | 1081 return Revalidate; |
| 1081 | 1082 |
| 1082 // No, must reload. | 1083 // No, must reload. |
| 1083 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to missing cache validators."); | 1084 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to missing cache validators."); |
| 1084 return Reload; | 1085 return Reload; |
| 1085 } | 1086 } |
| 1086 | 1087 |
| 1087 return Use; | 1088 return Use; |
| 1088 } | 1089 } |
| 1089 | 1090 |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1560 | 1561 |
| 1561 void ResourceFetcher::trace(Visitor* visitor) | 1562 void ResourceFetcher::trace(Visitor* visitor) |
| 1562 { | 1563 { |
| 1563 visitor->trace(m_document); | 1564 visitor->trace(m_document); |
| 1564 visitor->trace(m_loaders); | 1565 visitor->trace(m_loaders); |
| 1565 visitor->trace(m_multipartLoaders); | 1566 visitor->trace(m_multipartLoaders); |
| 1566 ResourceLoaderHost::trace(visitor); | 1567 ResourceLoaderHost::trace(visitor); |
| 1567 } | 1568 } |
| 1568 | 1569 |
| 1569 } | 1570 } |
| OLD | NEW |