| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2011 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 void RawResource::reportResourceTimingToClients(const ResourceTimingInfo& info) | 192 void RawResource::reportResourceTimingToClients(const ResourceTimingInfo& info) |
| 193 { | 193 { |
| 194 ResourceClientWalker<RawResourceClient> w(clients()); | 194 ResourceClientWalker<RawResourceClient> w(clients()); |
| 195 while (RawResourceClient* c = w.next()) | 195 while (RawResourceClient* c = w.next()) |
| 196 c->didReceiveResourceTiming(this, info); | 196 c->didReceiveResourceTiming(this, info); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void RawResource::setDefersLoading(bool defers) | 199 void RawResource::setDefersLoading(bool defers) |
| 200 { | 200 { |
| 201 if (m_loader) | 201 if (loader()) |
| 202 m_loader->setDefersLoading(defers); | 202 loader()->setDefersLoading(defers); |
| 203 } | 203 } |
| 204 | 204 |
| 205 static bool shouldIgnoreHeaderForCacheReuse(AtomicString headerName) | 205 static bool shouldIgnoreHeaderForCacheReuse(AtomicString headerName) |
| 206 { | 206 { |
| 207 // FIXME: This list of headers that don't affect cache policy almost certain
ly isn't complete. | 207 // FIXME: This list of headers that don't affect cache policy almost certain
ly isn't complete. |
| 208 DEFINE_STATIC_LOCAL(HashSet<AtomicString>, headers, ({ | 208 DEFINE_STATIC_LOCAL(HashSet<AtomicString>, headers, ({ |
| 209 "Cache-Control", | 209 "Cache-Control", |
| 210 "If-Modified-Since", | 210 "If-Modified-Since", |
| 211 "If-None-Match", | 211 "If-None-Match", |
| 212 "Origin", | 212 "Origin", |
| (...skipping 11 matching lines...) Expand all Loading... |
| 224 // Per http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.10, | 224 // Per http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.10, |
| 225 // these methods always invalidate the cache entry. | 225 // these methods always invalidate the cache entry. |
| 226 return method != "POST" && method != "PUT" && method != "DELETE"; | 226 return method != "POST" && method != "PUT" && method != "DELETE"; |
| 227 } | 227 } |
| 228 | 228 |
| 229 bool RawResource::canReuse(const ResourceRequest& newRequest) const | 229 bool RawResource::canReuse(const ResourceRequest& newRequest) const |
| 230 { | 230 { |
| 231 if (dataBufferingPolicy() == DoNotBufferData) | 231 if (dataBufferingPolicy() == DoNotBufferData) |
| 232 return false; | 232 return false; |
| 233 | 233 |
| 234 if (!isCacheableHTTPMethod(m_resourceRequest.httpMethod())) | 234 if (!isCacheableHTTPMethod(resourceRequest().httpMethod())) |
| 235 return false; | 235 return false; |
| 236 if (m_resourceRequest.httpMethod() != newRequest.httpMethod()) | 236 if (resourceRequest().httpMethod() != newRequest.httpMethod()) |
| 237 return false; | 237 return false; |
| 238 | 238 |
| 239 if (m_resourceRequest.httpBody() != newRequest.httpBody()) | 239 if (resourceRequest().httpBody() != newRequest.httpBody()) |
| 240 return false; | 240 return false; |
| 241 | 241 |
| 242 if (m_resourceRequest.allowStoredCredentials() != newRequest.allowStoredCred
entials()) | 242 if (resourceRequest().allowStoredCredentials() != newRequest.allowStoredCred
entials()) |
| 243 return false; | 243 return false; |
| 244 | 244 |
| 245 // Ensure most headers match the existing headers before continuing. | 245 // Ensure most headers match the existing headers before continuing. |
| 246 // Note that the list of ignored headers includes some headers explicitly re
lated to caching. | 246 // Note that the list of ignored headers includes some headers explicitly re
lated to caching. |
| 247 // A more detailed check of caching policy will be performed later, this is
simply a list of | 247 // A more detailed check of caching policy will be performed later, this is
simply a list of |
| 248 // headers that we might permit to be different and still reuse the existing
Resource. | 248 // headers that we might permit to be different and still reuse the existing
Resource. |
| 249 const HTTPHeaderMap& newHeaders = newRequest.httpHeaderFields(); | 249 const HTTPHeaderMap& newHeaders = newRequest.httpHeaderFields(); |
| 250 const HTTPHeaderMap& oldHeaders = m_resourceRequest.httpHeaderFields(); | 250 const HTTPHeaderMap& oldHeaders = resourceRequest().httpHeaderFields(); |
| 251 | 251 |
| 252 for (const auto& header : newHeaders) { | 252 for (const auto& header : newHeaders) { |
| 253 AtomicString headerName = header.key; | 253 AtomicString headerName = header.key; |
| 254 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != oldH
eaders.get(headerName)) | 254 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != oldH
eaders.get(headerName)) |
| 255 return false; | 255 return false; |
| 256 } | 256 } |
| 257 | 257 |
| 258 for (const auto& header : oldHeaders) { | 258 for (const auto& header : oldHeaders) { |
| 259 AtomicString headerName = header.key; | 259 AtomicString headerName = header.key; |
| 260 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH
eaders.get(headerName)) | 260 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH
eaders.get(headerName)) |
| 261 return false; | 261 return false; |
| 262 } | 262 } |
| 263 | 263 |
| 264 return true; | 264 return true; |
| 265 } | 265 } |
| 266 | 266 |
| 267 } // namespace blink | 267 } // namespace blink |
| OLD | NEW |