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) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
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 | 6 |
7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 void setIdentifier(unsigned long identifier) { m_identifier = identifier; } | 115 void setIdentifier(unsigned long identifier) { m_identifier = identifier; } |
116 unsigned long identifier() const { return m_identifier; } | 116 unsigned long identifier() const { return m_identifier; } |
117 | 117 |
118 virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; } | 118 virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; } |
119 | 119 |
120 ResourceRequest& mutableResourceRequest() { return m_resourceRequest; } | 120 ResourceRequest& mutableResourceRequest() { return m_resourceRequest; } |
121 const ResourceRequest& resourceRequest() const { return m_resourceRequest; } | 121 const ResourceRequest& resourceRequest() const { return m_resourceRequest; } |
122 const ResourceRequest& lastResourceRequest() const; | 122 const ResourceRequest& lastResourceRequest() const; |
123 | 123 |
| 124 void setRevalidatingRequest(const ResourceRequest& request) { m_revalidating
Request = request; } |
| 125 |
124 const KURL& url() const { return m_resourceRequest.url();} | 126 const KURL& url() const { return m_resourceRequest.url();} |
125 Type type() const { return static_cast<Type>(m_type); } | 127 Type type() const { return static_cast<Type>(m_type); } |
126 const ResourceLoaderOptions& options() const { return m_options; } | 128 const ResourceLoaderOptions& options() const { return m_options; } |
127 void setOptions(const ResourceLoaderOptions& options) { m_options = options;
} | 129 void setOptions(const ResourceLoaderOptions& options) { m_options = options;
} |
128 | 130 |
129 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); | 131 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); |
130 | 132 |
131 void addClient(ResourceClient*); | 133 void addClient(ResourceClient*); |
132 void removeClient(ResourceClient*); | 134 void removeClient(ResourceClient*); |
133 bool hasClients() const { return !m_clients.isEmpty() || !m_clientsAwaitingC
allback.isEmpty(); } | 135 bool hasClients() const { return !m_clients.isEmpty() || !m_clientsAwaitingC
allback.isEmpty(); } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 bool isPreloaded() const { return m_preloadCount; } | 225 bool isPreloaded() const { return m_preloadCount; } |
224 void increasePreloadCount() { ++m_preloadCount; } | 226 void increasePreloadCount() { ++m_preloadCount; } |
225 void decreasePreloadCount() { ASSERT(m_preloadCount); --m_preloadCount; } | 227 void decreasePreloadCount() { ASSERT(m_preloadCount); --m_preloadCount; } |
226 | 228 |
227 void registerHandle(ResourcePtrBase* h); | 229 void registerHandle(ResourcePtrBase* h); |
228 void unregisterHandle(ResourcePtrBase* h); | 230 void unregisterHandle(ResourcePtrBase* h); |
229 | 231 |
230 bool canReuseRedirectChain(); | 232 bool canReuseRedirectChain(); |
231 bool mustRevalidateDueToCacheHeaders(); | 233 bool mustRevalidateDueToCacheHeaders(); |
232 bool canUseCacheValidator(); | 234 bool canUseCacheValidator(); |
233 bool isCacheValidator() const { return m_resourceToRevalidate; } | 235 bool isCacheValidator() const { return !m_revalidatingRequest.isNull(); } |
234 Resource* resourceToRevalidate() const { return m_resourceToRevalidate; } | |
235 void setResourceToRevalidate(Resource*); | |
236 bool hasCacheControlNoStoreHeader(); | 236 bool hasCacheControlNoStoreHeader(); |
237 | 237 |
238 double currentAge() const; | 238 double currentAge() const; |
239 double freshnessLifetime(); | 239 double freshnessLifetime(); |
240 double stalenessLifetime(); | 240 double stalenessLifetime(); |
241 | 241 |
242 bool isPurgeable() const; | 242 bool isPurgeable() const; |
243 bool wasPurged() const; | 243 bool wasPurged() const; |
244 bool lock(); | 244 bool lock(); |
245 | 245 |
(...skipping 15 matching lines...) Expand all Loading... |
261 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK | 261 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK |
262 void assertAlive() const { RELEASE_ASSERT(!m_deleted); } | 262 void assertAlive() const { RELEASE_ASSERT(!m_deleted); } |
263 #else | 263 #else |
264 void assertAlive() const { } | 264 void assertAlive() const { } |
265 #endif | 265 #endif |
266 | 266 |
267 protected: | 267 protected: |
268 virtual void checkNotify(); | 268 virtual void checkNotify(); |
269 virtual void finishOnePart(); | 269 virtual void finishOnePart(); |
270 | 270 |
| 271 virtual void destroyDecodedDataForFailedRevalidation() { } |
| 272 |
271 // Normal resource pointers will silently switch what Resource* they referen
ce when we | 273 // Normal resource pointers will silently switch what Resource* they referen
ce when we |
272 // successfully revalidated the resource. We need a way to guarantee that th
e Resource | 274 // successfully revalidated the resource. We need a way to guarantee that th
e Resource |
273 // that received the 304 response survives long enough to switch everything
over to the | 275 // that received the 304 response survives long enough to switch everything
over to the |
274 // revalidatedresource. The normal mechanisms for keeping a Resource alive e
xternally | 276 // revalidatedresource. The normal mechanisms for keeping a Resource alive e
xternally |
275 // (ResourcePtrs and ResourceClients registering themselves) don't work in t
his case, so | 277 // (ResourcePtrs and ResourceClients registering themselves) don't work in t
his case, so |
276 // have a separate internal protector). | 278 // have a separate internal protector). |
277 class InternalResourcePtr { | 279 class InternalResourcePtr { |
278 public: | 280 public: |
279 explicit InternalResourcePtr(Resource* resource) | 281 explicit InternalResourcePtr(Resource* resource) |
280 : m_resource(resource) | 282 : m_resource(resource) |
(...skipping 10 matching lines...) Expand all Loading... |
291 Resource* m_resource; | 293 Resource* m_resource; |
292 }; | 294 }; |
293 | 295 |
294 void incrementProtectorCount() { m_protectorCount++; } | 296 void incrementProtectorCount() { m_protectorCount++; } |
295 void decrementProtectorCount() { m_protectorCount--; } | 297 void decrementProtectorCount() { m_protectorCount--; } |
296 | 298 |
297 void setEncodedSize(size_t); | 299 void setEncodedSize(size_t); |
298 void setDecodedSize(size_t); | 300 void setDecodedSize(size_t); |
299 void didAccessDecodedData(); | 301 void didAccessDecodedData(); |
300 | 302 |
301 void clearResourceToRevalidate(); | |
302 void updateResponseAfterRevalidation(const ResourceResponse& validatingRespo
nse); | |
303 | |
304 void finishPendingClients(); | 303 void finishPendingClients(); |
305 | 304 |
306 HashCountedSet<ResourceClient*> m_clients; | 305 HashCountedSet<ResourceClient*> m_clients; |
307 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; | 306 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; |
308 | 307 |
309 class ResourceCallback { | 308 class ResourceCallback { |
310 public: | 309 public: |
311 static ResourceCallback* callbackHandler(); | 310 static ResourceCallback* callbackHandler(); |
312 void schedule(Resource*); | 311 void schedule(Resource*); |
313 void cancel(Resource*); | 312 void cancel(Resource*); |
(...skipping 17 matching lines...) Expand all Loading... |
331 | 330 |
332 ResourceRequest m_request; | 331 ResourceRequest m_request; |
333 ResourceResponse m_redirectResponse; | 332 ResourceResponse m_redirectResponse; |
334 }; | 333 }; |
335 const Vector<RedirectPair>& redirectChain() const { return m_redirectChain;
} | 334 const Vector<RedirectPair>& redirectChain() const { return m_redirectChain;
} |
336 | 335 |
337 virtual bool isSafeToUnlock() const { return false; } | 336 virtual bool isSafeToUnlock() const { return false; } |
338 virtual void destroyDecodedDataIfPossible() { } | 337 virtual void destroyDecodedDataIfPossible() { } |
339 | 338 |
340 ResourceRequest m_resourceRequest; | 339 ResourceRequest m_resourceRequest; |
| 340 ResourceRequest m_revalidatingRequest; |
341 AtomicString m_accept; | 341 AtomicString m_accept; |
342 PersistentWillBeMember<ResourceLoader> m_loader; | 342 PersistentWillBeMember<ResourceLoader> m_loader; |
343 ResourceLoaderOptions m_options; | 343 ResourceLoaderOptions m_options; |
344 | 344 |
345 ResourceResponse m_response; | 345 ResourceResponse m_response; |
346 double m_responseTimestamp; | 346 double m_responseTimestamp; |
347 | 347 |
348 RefPtr<SharedBuffer> m_data; | 348 RefPtr<SharedBuffer> m_data; |
349 Timer<Resource> m_cancelTimer; | 349 Timer<Resource> m_cancelTimer; |
350 | 350 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 unsigned m_status : 3; // Status | 395 unsigned m_status : 3; // Status |
396 | 396 |
397 unsigned m_wasPurged : 1; | 397 unsigned m_wasPurged : 1; |
398 | 398 |
399 unsigned m_needsSynchronousCacheHit : 1; | 399 unsigned m_needsSynchronousCacheHit : 1; |
400 | 400 |
401 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK | 401 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK |
402 bool m_deleted; | 402 bool m_deleted; |
403 #endif | 403 #endif |
404 | 404 |
405 // If this field is non-null we are using the resource as a proxy for checki
ng whether an existing resource is still up to date | |
406 // using HTTP If-Modified-Since/If-None-Match headers. If the response is 30
4 all clients of this resource are moved | |
407 // to to be clients of m_resourceToRevalidate and the resource is deleted. I
f not, the field is zeroed and this | |
408 // resources becomes normal resource load. | |
409 RawPtrWillBeMember<Resource> m_resourceToRevalidate; | |
410 | |
411 // If this field is non-null, the resource has a proxy for checking whether
it is still up to date (see m_resourceToRevalidate). | |
412 RawPtrWillBeMember<Resource> m_proxyResource; | |
413 | |
414 // These handles will need to be updated to point to the m_resourceToRevalid
ate in case we get 304 response. | |
415 HashSet<ResourcePtrBase*> m_handlesToRevalidate; | |
416 | |
417 // Ordered list of all redirects followed while fetching this resource. | 405 // Ordered list of all redirects followed while fetching this resource. |
418 Vector<RedirectPair> m_redirectChain; | 406 Vector<RedirectPair> m_redirectChain; |
419 }; | 407 }; |
420 | 408 |
421 class ResourceFactory { | 409 class ResourceFactory { |
422 public: | 410 public: |
423 virtual Resource* create(const ResourceRequest&, const String&) const = 0; | 411 virtual Resource* create(const ResourceRequest&, const String&) const = 0; |
424 Resource::Type type() const { return m_type; } | 412 Resource::Type type() const { return m_type; } |
425 | 413 |
426 protected: | 414 protected: |
427 ResourceFactory(Resource::Type type) : m_type(type) { } | 415 ResourceFactory(Resource::Type type) : m_type(type) { } |
428 | 416 |
429 Resource::Type m_type; | 417 Resource::Type m_type; |
430 }; | 418 }; |
431 | 419 |
432 #if !LOG_DISABLED | 420 #if !LOG_DISABLED |
433 // Intended to be used in LOG statements. | 421 // Intended to be used in LOG statements. |
434 const char* ResourceTypeName(Resource::Type); | 422 const char* ResourceTypeName(Resource::Type); |
435 #endif | 423 #endif |
436 | 424 |
437 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 425 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
438 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() =
= Resource::typeName, resource.type() == Resource::typeName); \ | 426 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() =
= Resource::typeName, resource.type() == Resource::typeName); \ |
439 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource
>& ptr) { return to##typeName##Resource(ptr.get()); } | 427 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource
>& ptr) { return to##typeName##Resource(ptr.get()); } |
440 | 428 |
441 } | 429 } |
442 | 430 |
443 #endif | 431 #endif |
OLD | NEW |