eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 1 | /* |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 2 | Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 | Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 | Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
darin | 91298e5 | 2006-06-12 01:10:17 +0000 | [diff] [blame] | 5 | Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
darin | d51eb59 | 2007-05-24 22:56:33 +0000 | [diff] [blame] | 6 | Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 7 | |
| 8 | This library is free software; you can redistribute it and/or |
| 9 | modify it under the terms of the GNU Library General Public |
| 10 | License as published by the Free Software Foundation; either |
| 11 | version 2 of the License, or (at your option) any later version. |
| 12 | |
| 13 | This library is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | Library General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU Library General Public License |
| 19 | along with this library; see the file COPYING.LIB. If not, write to |
ddkilzer | c8eccec | 2007-09-26 02:29:57 +0000 | [diff] [blame] | 20 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 | Boston, MA 02110-1301, USA. |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | #include "config.h" |
darin | e775cf7 | 2006-07-09 22:48:56 +0000 | [diff] [blame] | 25 | #include "CachedResource.h" |
darin | bbe6466 | 2006-01-16 17:52:23 +0000 | [diff] [blame] | 26 | |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 27 | #include "Cache.h" |
antti@apple.com | 72e4a84 | 2008-09-05 09:28:11 +0000 | [diff] [blame] | 28 | #include "CachedResourceHandle.h" |
andersca | 53b9d2a | 2007-07-20 22:52:25 +0000 | [diff] [blame] | 29 | #include "DocLoader.h" |
ggaren | 1f92a1a | 2007-08-09 03:59:32 +0000 | [diff] [blame] | 30 | #include "Frame.h" |
kmccullo | adfd67d | 2007-03-03 02:18:43 +0000 | [diff] [blame] | 31 | #include "FrameLoader.h" |
ggaren | 1f92a1a | 2007-08-09 03:59:32 +0000 | [diff] [blame] | 32 | #include "KURL.h" |
darin | 91298e5 | 2006-06-12 01:10:17 +0000 | [diff] [blame] | 33 | #include "Request.h" |
ggaren | 1f92a1a | 2007-08-09 03:59:32 +0000 | [diff] [blame] | 34 | #include "SystemTime.h" |
darin | 91298e5 | 2006-06-12 01:10:17 +0000 | [diff] [blame] | 35 | #include <wtf/Vector.h> |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 36 | |
darin | bbe6466 | 2006-01-16 17:52:23 +0000 | [diff] [blame] | 37 | namespace WebCore { |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 38 | |
antti@apple.com | b4122c5 | 2008-03-25 19:21:00 +0000 | [diff] [blame] | 39 | CachedResource::CachedResource(const String& url, Type type) |
weinig@apple.com | c500266 | 2007-12-12 07:26:19 +0000 | [diff] [blame] | 40 | : m_url(url) |
| 41 | , m_lastDecodedAccessTime(0) |
antti@apple.com | b4122c5 | 2008-03-25 19:21:00 +0000 | [diff] [blame] | 42 | , m_sendResourceLoadCallbacks(true) |
antti@apple.com | 6c76e54 | 2008-03-13 21:20:31 +0000 | [diff] [blame] | 43 | , m_preloadCount(0) |
| 44 | , m_preloadResult(PreloadNotReferenced) |
| 45 | , m_requestedFromNetworkingLayer(false) |
antti@apple.com | b4122c5 | 2008-03-25 19:21:00 +0000 | [diff] [blame] | 46 | , m_inCache(false) |
| 47 | , m_loading(false) |
andersca | 53b9d2a | 2007-07-20 22:52:25 +0000 | [diff] [blame] | 48 | , m_docLoader(0) |
antti@apple.com | 72e4a84 | 2008-09-05 09:28:11 +0000 | [diff] [blame] | 49 | , m_handleCount(0) |
| 50 | , m_resourceToRevalidate(0) |
| 51 | , m_isBeingRevalidated(false) |
| 52 | , m_expirationDate(0) |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 53 | { |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 54 | m_type = type; |
| 55 | m_status = Pending; |
hyatt | 4724d0f | 2007-04-03 01:11:35 +0000 | [diff] [blame] | 56 | m_encodedSize = 0; |
ggaren | 568a2dd | 2007-08-13 02:41:29 +0000 | [diff] [blame] | 57 | m_decodedSize = 0; |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 58 | m_request = 0; |
hyatt | 2ce7984 | 2007-03-25 05:53:42 +0000 | [diff] [blame] | 59 | |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 60 | m_accessCount = 0; |
ggaren | 408a6df | 2007-08-08 07:01:39 +0000 | [diff] [blame] | 61 | m_inLiveDecodedResourcesList = false; |
hyatt | 2ce7984 | 2007-03-25 05:53:42 +0000 | [diff] [blame] | 62 | |
| 63 | m_nextInAllResourcesList = 0; |
| 64 | m_prevInAllResourcesList = 0; |
| 65 | |
| 66 | m_nextInLiveResourcesList = 0; |
| 67 | m_prevInLiveResourcesList = 0; |
| 68 | |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 69 | #ifndef NDEBUG |
| 70 | m_deleted = false; |
| 71 | m_lruIndex = 0; |
| 72 | #endif |
kmccullo | adfd67d | 2007-03-03 02:18:43 +0000 | [diff] [blame] | 73 | m_errorOccurred = false; |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 74 | } |
| 75 | |
darin | e775cf7 | 2006-07-09 22:48:56 +0000 | [diff] [blame] | 76 | CachedResource::~CachedResource() |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 77 | { |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 78 | ASSERT(!inCache()); |
| 79 | ASSERT(!m_deleted); |
ap@webkit.org | 86cf11e | 2008-05-02 13:07:43 +0000 | [diff] [blame] | 80 | ASSERT(url().isNull() || cache()->resourceForURL(url()) != this); |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 81 | #ifndef NDEBUG |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 82 | m_deleted = true; |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 83 | #endif |
antti@apple.com | 72e4a84 | 2008-09-05 09:28:11 +0000 | [diff] [blame] | 84 | |
| 85 | ASSERT(cache()->resourceForURL(url()) != this); |
andersca | 53b9d2a | 2007-07-20 22:52:25 +0000 | [diff] [blame] | 86 | |
antti@apple.com | 72e4a84 | 2008-09-05 09:28:11 +0000 | [diff] [blame] | 87 | if (m_resourceToRevalidate) |
| 88 | m_resourceToRevalidate->m_isBeingRevalidated = false; |
| 89 | |
andersca | 53b9d2a | 2007-07-20 22:52:25 +0000 | [diff] [blame] | 90 | if (m_docLoader) |
| 91 | m_docLoader->removeCachedResource(this); |
darin | 91298e5 | 2006-06-12 01:10:17 +0000 | [diff] [blame] | 92 | } |
antti@apple.com | b4122c5 | 2008-03-25 19:21:00 +0000 | [diff] [blame] | 93 | |
| 94 | void CachedResource::load(DocLoader* docLoader, bool incremental, bool skipCanLoadCheck, bool sendResourceLoadCallbacks) |
| 95 | { |
| 96 | m_sendResourceLoadCallbacks = sendResourceLoadCallbacks; |
| 97 | cache()->loader()->load(docLoader, this, incremental, skipCanLoadCheck, sendResourceLoadCallbacks); |
| 98 | m_loading = true; |
| 99 | } |
darin | 91298e5 | 2006-06-12 01:10:17 +0000 | [diff] [blame] | 100 | |
darin | e775cf7 | 2006-07-09 22:48:56 +0000 | [diff] [blame] | 101 | void CachedResource::finish() |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 102 | { |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 103 | m_status = Cached; |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 104 | } |
| 105 | |
darin | e775cf7 | 2006-07-09 22:48:56 +0000 | [diff] [blame] | 106 | bool CachedResource::isExpired() const |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 107 | { |
antti@apple.com | 72e4a84 | 2008-09-05 09:28:11 +0000 | [diff] [blame] | 108 | if (!m_expirationDate) |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 109 | return false; |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 110 | time_t now = time(0); |
antti@apple.com | 72e4a84 | 2008-09-05 09:28:11 +0000 | [diff] [blame] | 111 | return difftime(now, m_expirationDate) >= 0; |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 112 | } |
antti@apple.com | 72e4a84 | 2008-09-05 09:28:11 +0000 | [diff] [blame] | 113 | |
| 114 | void CachedResource::setResponse(const ResourceResponse& response) |
| 115 | { |
| 116 | m_response = response; |
| 117 | m_expirationDate = response.expirationDate(); |
| 118 | } |
| 119 | |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 120 | void CachedResource::setRequest(Request* request) |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 121 | { |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 122 | if (request && !m_request) |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 123 | m_status = Pending; |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 124 | m_request = request; |
| 125 | if (canDelete() && !inCache()) |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 126 | delete this; |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 127 | } |
| 128 | |
hyatt@apple.com | 2c814c4 | 2008-04-12 04:09:22 +0000 | [diff] [blame] | 129 | void CachedResource::addClient(CachedResourceClient *c) |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 130 | { |
antti@apple.com | 6c76e54 | 2008-03-13 21:20:31 +0000 | [diff] [blame] | 131 | if (m_preloadResult == PreloadNotReferenced) { |
| 132 | if (isLoaded()) |
| 133 | m_preloadResult = PreloadReferencedWhileComplete; |
| 134 | else if (m_requestedFromNetworkingLayer) |
| 135 | m_preloadResult = PreloadReferencedWhileLoading; |
| 136 | else |
| 137 | m_preloadResult = PreloadReferenced; |
| 138 | } |
antti@apple.com | 60381cb | 2008-08-25 20:41:11 +0000 | [diff] [blame] | 139 | if (!hasClients() && inCache()) |
hyatt | 2ce7984 | 2007-03-25 05:53:42 +0000 | [diff] [blame] | 140 | cache()->addToLiveResourcesSize(this); |
mjs | ba7cd53 | 2006-01-24 00:56:32 +0000 | [diff] [blame] | 141 | m_clients.add(c); |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 142 | } |
| 143 | |
hyatt@apple.com | 2c814c4 | 2008-04-12 04:09:22 +0000 | [diff] [blame] | 144 | void CachedResource::removeClient(CachedResourceClient *c) |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 145 | { |
hyatt | f56c441 | 2007-03-15 00:28:21 +0000 | [diff] [blame] | 146 | ASSERT(m_clients.contains(c)); |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 147 | m_clients.remove(c); |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 148 | if (canDelete() && !inCache()) |
| 149 | delete this; |
antti@apple.com | 60381cb | 2008-08-25 20:41:11 +0000 | [diff] [blame] | 150 | else if (!hasClients() && inCache()) { |
hyatt | 2ce7984 | 2007-03-25 05:53:42 +0000 | [diff] [blame] | 151 | cache()->removeFromLiveResourcesSize(this); |
ggaren | 408a6df | 2007-08-08 07:01:39 +0000 | [diff] [blame] | 152 | cache()->removeFromLiveDecodedResourcesList(this); |
mitz@apple.com | 9d7e426 | 2008-09-04 18:15:25 +0000 | [diff] [blame] | 153 | allClientsRemoved(); |
ggaren | 1aba837 | 2007-08-16 23:43:43 +0000 | [diff] [blame] | 154 | cache()->prune(); |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 155 | } |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 156 | } |
| 157 | |
antti@apple.com | 72e4a84 | 2008-09-05 09:28:11 +0000 | [diff] [blame] | 158 | void CachedResource::deleteIfPossible() |
| 159 | { |
| 160 | if (canDelete() && !inCache()) |
| 161 | delete this; |
| 162 | } |
| 163 | |
ggaren | 568a2dd | 2007-08-13 02:41:29 +0000 | [diff] [blame] | 164 | void CachedResource::setDecodedSize(unsigned size) |
| 165 | { |
| 166 | if (size == m_decodedSize) |
| 167 | return; |
| 168 | |
| 169 | int delta = size - m_decodedSize; |
| 170 | |
| 171 | // The object must now be moved to a different queue, since its size has been changed. |
| 172 | // We have to remove explicitly before updating m_decodedSize, so that we find the correct previous |
| 173 | // queue. |
| 174 | if (inCache()) |
| 175 | cache()->removeFromLRUList(this); |
| 176 | |
| 177 | m_decodedSize = size; |
| 178 | |
| 179 | if (inCache()) { |
| 180 | // Now insert into the new LRU list. |
| 181 | cache()->insertInLRUList(this); |
| 182 | |
| 183 | // Insert into or remove from the live decoded list if necessary. |
antti@apple.com | 60381cb | 2008-08-25 20:41:11 +0000 | [diff] [blame] | 184 | if (m_decodedSize && !m_inLiveDecodedResourcesList && hasClients()) |
ggaren | 568a2dd | 2007-08-13 02:41:29 +0000 | [diff] [blame] | 185 | cache()->insertInLiveDecodedResourcesList(this); |
| 186 | else if (!m_decodedSize && m_inLiveDecodedResourcesList) |
| 187 | cache()->removeFromLiveDecodedResourcesList(this); |
| 188 | |
| 189 | // Update the cache's size totals. |
antti@apple.com | 60381cb | 2008-08-25 20:41:11 +0000 | [diff] [blame] | 190 | cache()->adjustSize(hasClients(), delta); |
ggaren | 568a2dd | 2007-08-13 02:41:29 +0000 | [diff] [blame] | 191 | } |
| 192 | } |
| 193 | |
hyatt | c3e1580 | 2007-03-07 07:42:45 +0000 | [diff] [blame] | 194 | void CachedResource::setEncodedSize(unsigned size) |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 195 | { |
hyatt | c3e1580 | 2007-03-07 07:42:45 +0000 | [diff] [blame] | 196 | if (size == m_encodedSize) |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 197 | return; |
| 198 | |
hyatt | 04a8e08 | 2007-04-03 23:31:15 +0000 | [diff] [blame] | 199 | // The size cannot ever shrink (unless it is being nulled out because of an error). If it ever does, assert. |
| 200 | ASSERT(size == 0 || size >= m_encodedSize); |
hyatt | dc0dceb | 2007-04-02 23:41:57 +0000 | [diff] [blame] | 201 | |
ggaren | 568a2dd | 2007-08-13 02:41:29 +0000 | [diff] [blame] | 202 | int delta = size - m_encodedSize; |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 203 | |
| 204 | // The object must now be moved to a different queue, since its size has been changed. |
hyatt | c3e1580 | 2007-03-07 07:42:45 +0000 | [diff] [blame] | 205 | // We have to remove explicitly before updating m_encodedSize, so that we find the correct previous |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 206 | // queue. |
| 207 | if (inCache()) |
| 208 | cache()->removeFromLRUList(this); |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 209 | |
hyatt | c3e1580 | 2007-03-07 07:42:45 +0000 | [diff] [blame] | 210 | m_encodedSize = size; |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 211 | |
| 212 | if (inCache()) { |
| 213 | // Now insert into the new LRU list. |
| 214 | cache()->insertInLRUList(this); |
| 215 | |
| 216 | // Update the cache's size totals. |
antti@apple.com | 60381cb | 2008-08-25 20:41:11 +0000 | [diff] [blame] | 217 | cache()->adjustSize(hasClients(), delta); |
hyatt | 2ce7984 | 2007-03-25 05:53:42 +0000 | [diff] [blame] | 218 | } |
| 219 | } |
| 220 | |
ggaren | fbd237b | 2007-08-10 02:30:30 +0000 | [diff] [blame] | 221 | void CachedResource::didAccessDecodedData(double timeStamp) |
hyatt | 2ce7984 | 2007-03-25 05:53:42 +0000 | [diff] [blame] | 222 | { |
ggaren | fbd237b | 2007-08-10 02:30:30 +0000 | [diff] [blame] | 223 | m_lastDecodedAccessTime = timeStamp; |
ggaren | 1f92a1a | 2007-08-09 03:59:32 +0000 | [diff] [blame] | 224 | |
hyatt | 2ce7984 | 2007-03-25 05:53:42 +0000 | [diff] [blame] | 225 | if (inCache()) { |
ggaren | 408a6df | 2007-08-08 07:01:39 +0000 | [diff] [blame] | 226 | if (m_inLiveDecodedResourcesList) { |
| 227 | cache()->removeFromLiveDecodedResourcesList(this); |
| 228 | cache()->insertInLiveDecodedResourcesList(this); |
| 229 | } |
ggaren | 1aba837 | 2007-08-16 23:43:43 +0000 | [diff] [blame] | 230 | cache()->prune(); |
hyatt | c440449 | 2006-10-19 09:21:54 +0000 | [diff] [blame] | 231 | } |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 232 | } |
antti@apple.com | 72e4a84 | 2008-09-05 09:28:11 +0000 | [diff] [blame] | 233 | |
| 234 | void CachedResource::setResourceToRevalidate(CachedResource* resource) |
| 235 | { |
| 236 | ASSERT(resource); |
| 237 | ASSERT(!m_resourceToRevalidate); |
| 238 | ASSERT(resource != this); |
| 239 | ASSERT(!resource->m_isBeingRevalidated); |
| 240 | ASSERT(m_handlesToRevalidate.isEmpty()); |
| 241 | ASSERT(resource->type() == type()); |
| 242 | resource->m_isBeingRevalidated = true; |
| 243 | m_resourceToRevalidate = resource; |
| 244 | } |
| 245 | |
| 246 | void CachedResource::clearResourceToRevalidate() |
| 247 | { |
| 248 | ASSERT(m_resourceToRevalidate); |
| 249 | ASSERT(m_resourceToRevalidate->m_isBeingRevalidated); |
| 250 | m_resourceToRevalidate->m_isBeingRevalidated = false; |
| 251 | m_resourceToRevalidate->deleteIfPossible(); |
| 252 | m_handlesToRevalidate.clear(); |
| 253 | m_resourceToRevalidate = 0; |
| 254 | deleteIfPossible(); |
| 255 | } |
| 256 | |
| 257 | void CachedResource::switchClientsToRevalidatedResource() |
| 258 | { |
| 259 | ASSERT(m_resourceToRevalidate); |
| 260 | ASSERT(!inCache()); |
| 261 | |
| 262 | HashSet<CachedResourceHandleBase*>::iterator end = m_handlesToRevalidate.end(); |
| 263 | for (HashSet<CachedResourceHandleBase*>::iterator it = m_handlesToRevalidate.begin(); it != end; ++it) { |
| 264 | CachedResourceHandleBase* handle = *it; |
| 265 | handle->m_resource = m_resourceToRevalidate; |
| 266 | m_resourceToRevalidate->registerHandle(handle); |
| 267 | --m_handleCount; |
| 268 | } |
| 269 | ASSERT(!m_handleCount); |
| 270 | m_handlesToRevalidate.clear(); |
| 271 | |
| 272 | Vector<CachedResourceClient*> clientsToMove; |
| 273 | HashCountedSet<CachedResourceClient*>::iterator end2 = m_clients.end(); |
| 274 | for (HashCountedSet<CachedResourceClient*>::iterator it = m_clients.begin(); it != end2; ++it) { |
| 275 | CachedResourceClient* client = it->first; |
| 276 | unsigned count = it->second; |
| 277 | while (count) { |
| 278 | clientsToMove.append(client); |
| 279 | --count; |
| 280 | } |
| 281 | } |
| 282 | // Equivalent of calling removeClient() for all clients |
| 283 | m_clients.clear(); |
| 284 | |
| 285 | unsigned moveCount = clientsToMove.size(); |
| 286 | for (unsigned n = 0; n < moveCount; ++n) |
| 287 | m_resourceToRevalidate->addClient(clientsToMove[n]); |
| 288 | } |
| 289 | |
| 290 | bool CachedResource::canUseCacheValidator() const |
| 291 | { |
| 292 | return !m_loading && (!m_response.httpHeaderField("Last-Modified").isEmpty() || !m_response.httpHeaderField("ETag").isEmpty()); |
| 293 | } |
| 294 | |
| 295 | bool CachedResource::mustRevalidate(CachePolicy cachePolicy) const |
| 296 | { |
| 297 | if (m_loading) |
| 298 | return false; |
| 299 | String cacheControl = m_response.httpHeaderField("Cache-Control"); |
| 300 | // FIXME: It would be better to tokenize the field. |
| 301 | if (cachePolicy == CachePolicyCache) |
| 302 | return !cacheControl.isEmpty() && (cacheControl.contains("no-cache", false) || (isExpired() && cacheControl.contains("must-revalidate", false))); |
| 303 | return isExpired() || cacheControl.contains("no-cache", false); |
| 304 | } |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 305 | |
darin | bbe6466 | 2006-01-16 17:52:23 +0000 | [diff] [blame] | 306 | } |