| 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. |
| 11 | 11 |
| 12 This library is distributed in the hope that it will be useful, | 12 This library is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 Library General Public License for more details. | 15 Library General Public License for more details. |
| 16 | 16 |
| 17 You should have received a copy of the GNU Library General Public License | 17 You should have received a copy of the GNU Library General Public License |
| 18 along with this library; see the file COPYING.LIB. If not, write to | 18 along with this library; see the file COPYING.LIB. If not, write to |
| 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 Boston, MA 02110-1301, USA. | 20 Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #ifndef Resource_h | 23 #ifndef Resource_h |
| 24 #define Resource_h | 24 #define Resource_h |
| 25 | 25 |
| 26 #include "core/fetch/CachedMetadataHandler.h" |
| 26 #include "core/fetch/ResourceLoaderOptions.h" | 27 #include "core/fetch/ResourceLoaderOptions.h" |
| 27 #include "platform/Timer.h" | 28 #include "platform/Timer.h" |
| 28 #include "platform/network/ResourceError.h" | 29 #include "platform/network/ResourceError.h" |
| 29 #include "platform/network/ResourceLoadPriority.h" | 30 #include "platform/network/ResourceLoadPriority.h" |
| 30 #include "platform/network/ResourceRequest.h" | 31 #include "platform/network/ResourceRequest.h" |
| 31 #include "platform/network/ResourceResponse.h" | 32 #include "platform/network/ResourceResponse.h" |
| 32 #include "public/platform/WebDataConsumerHandle.h" | 33 #include "public/platform/WebDataConsumerHandle.h" |
| 33 #include "wtf/HashCountedSet.h" | 34 #include "wtf/HashCountedSet.h" |
| 34 #include "wtf/HashSet.h" | 35 #include "wtf/HashSet.h" |
| 35 #include "wtf/OwnPtr.h" | 36 #include "wtf/OwnPtr.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 enum Status { | 79 enum Status { |
| 79 Unknown, // let cache decide what to do with it | 80 Unknown, // let cache decide what to do with it |
| 80 Pending, // only partially loaded | 81 Pending, // only partially loaded |
| 81 Cached, // regular case | 82 Cached, // regular case |
| 82 LoadError, | 83 LoadError, |
| 83 DecodeError | 84 DecodeError |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 enum MetadataCacheType { | |
| 87 SendToPlatform, // send cache data to blink::Platform::cacheMetadata | |
| 88 CacheLocally // cache only in Resource's member variables | |
| 89 }; | |
| 90 | |
| 91 Resource(const ResourceRequest&, Type); | 87 Resource(const ResourceRequest&, Type); |
| 92 #if ENABLE(OILPAN) | 88 #if ENABLE(OILPAN) |
| 93 virtual ~Resource(); | 89 virtual ~Resource(); |
| 94 #else | 90 #else |
| 95 protected: | 91 protected: |
| 96 // Only deleteIfPossible should delete this. | 92 // Only deleteIfPossible should delete this. |
| 97 virtual ~Resource(); | 93 virtual ~Resource(); |
| 98 public: | 94 public: |
| 99 #endif | 95 #endif |
| 100 virtual void dispose(); | 96 virtual void dispose(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 virtual void willFollowRedirect(ResourceRequest&, const ResourceResponse&); | 187 virtual void willFollowRedirect(ResourceRequest&, const ResourceResponse&); |
| 192 | 188 |
| 193 virtual void updateRequest(const ResourceRequest&) { } | 189 virtual void updateRequest(const ResourceRequest&) { } |
| 194 virtual void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataCon
sumerHandle>); | 190 virtual void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataCon
sumerHandle>); |
| 195 void setResponse(const ResourceResponse& response) { m_response = response;
} | 191 void setResponse(const ResourceResponse& response) { m_response = response;
} |
| 196 const ResourceResponse& response() const { return m_response; } | 192 const ResourceResponse& response() const { return m_response; } |
| 197 | 193 |
| 198 // Sets the serialized metadata retrieved from the platform's cache. | 194 // Sets the serialized metadata retrieved from the platform's cache. |
| 199 virtual void setSerializedCachedMetadata(const char*, size_t); | 195 virtual void setSerializedCachedMetadata(const char*, size_t); |
| 200 | 196 |
| 201 // Caches the given metadata in association with this resource and suggests | 197 CachedMetadataHandler* cacheHandler(); |
| 202 // that the platform persist it. The dataTypeID is a pseudo-randomly chosen | |
| 203 // identifier that is used to distinguish data generated by the caller. | |
| 204 void setCachedMetadata(unsigned dataTypeID, const char*, size_t, MetadataCac
heType = SendToPlatform); | |
| 205 | |
| 206 // Reset existing metadata, to allow setting new data. | |
| 207 void clearCachedMetadata(MetadataCacheType = CacheLocally); | |
| 208 | |
| 209 // Returns cached metadata of the given type associated with this resource. | |
| 210 CachedMetadata* cachedMetadata(unsigned dataTypeID) const; | |
| 211 | 198 |
| 212 bool hasOneHandle() const; | 199 bool hasOneHandle() const; |
| 213 bool canDelete() const; | 200 bool canDelete() const; |
| 214 | 201 |
| 215 // List of acceptable MIME types separated by ",". | 202 // List of acceptable MIME types separated by ",". |
| 216 // A MIME type may contain a wildcard, e.g. "text/*". | 203 // A MIME type may contain a wildcard, e.g. "text/*". |
| 217 AtomicString accept() const { return m_accept; } | 204 AtomicString accept() const { return m_accept; } |
| 218 void setAccept(const AtomicString& accept) { m_accept = accept; } | 205 void setAccept(const AtomicString& accept) { m_accept = accept; } |
| 219 | 206 |
| 220 bool wasCanceled() const { return m_error.isCancellation(); } | 207 bool wasCanceled() const { return m_error.isCancellation(); } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 RefPtrWillBeMember<ResourceLoader> m_loader; | 331 RefPtrWillBeMember<ResourceLoader> m_loader; |
| 345 ResourceLoaderOptions m_options; | 332 ResourceLoaderOptions m_options; |
| 346 | 333 |
| 347 ResourceResponse m_response; | 334 ResourceResponse m_response; |
| 348 double m_responseTimestamp; | 335 double m_responseTimestamp; |
| 349 | 336 |
| 350 RefPtr<SharedBuffer> m_data; | 337 RefPtr<SharedBuffer> m_data; |
| 351 Timer<Resource> m_cancelTimer; | 338 Timer<Resource> m_cancelTimer; |
| 352 | 339 |
| 353 private: | 340 private: |
| 341 class CacheHandler : public CachedMetadataHandler { |
| 342 public: |
| 343 CacheHandler(Resource*); |
| 344 ~CacheHandler() override { } |
| 345 void setCachedMetadata(unsigned, const char*, size_t, CacheType) overrid
e; |
| 346 void clearCachedMetadata(CacheType) override; |
| 347 CachedMetadata* cachedMetadata(unsigned) const override; |
| 348 String encoding() const override; |
| 349 private: |
| 350 Resource* m_resource; |
| 351 }; |
| 354 bool addClientToSet(ResourceClient*); | 352 bool addClientToSet(ResourceClient*); |
| 355 void cancelTimerFired(Timer<Resource>*); | 353 void cancelTimerFired(Timer<Resource>*); |
| 356 | 354 |
| 357 void revalidationSucceeded(const ResourceResponse&); | 355 void revalidationSucceeded(const ResourceResponse&); |
| 358 void revalidationFailed(); | 356 void revalidationFailed(); |
| 359 | 357 |
| 360 bool unlock(); | 358 bool unlock(); |
| 361 | 359 |
| 362 bool hasRightHandleCountApartFromCache(unsigned targetCount) const; | 360 bool hasRightHandleCountApartFromCache(unsigned targetCount) const; |
| 363 | 361 |
| 364 void failBeforeStarting(); | 362 void failBeforeStarting(); |
| 365 | 363 |
| 364 void setCachedMetadata(unsigned dataTypeID, const char*, size_t, CachedMetad
ataHandler::CacheType); |
| 365 void clearCachedMetadata(CachedMetadataHandler::CacheType); |
| 366 CachedMetadata* cachedMetadata(unsigned dataTypeID) const; |
| 367 |
| 366 String m_fragmentIdentifierForRequest; | 368 String m_fragmentIdentifierForRequest; |
| 367 | 369 |
| 368 RefPtr<CachedMetadata> m_cachedMetadata; | 370 RefPtr<CachedMetadata> m_cachedMetadata; |
| 371 CacheHandler m_cacheHandler; |
| 369 | 372 |
| 370 ResourceError m_error; | 373 ResourceError m_error; |
| 371 | 374 |
| 372 double m_loadFinishTime; | 375 double m_loadFinishTime; |
| 373 | 376 |
| 374 unsigned long m_identifier; | 377 unsigned long m_identifier; |
| 375 | 378 |
| 376 size_t m_encodedSize; | 379 size_t m_encodedSize; |
| 377 size_t m_decodedSize; | 380 size_t m_decodedSize; |
| 378 unsigned m_handleCount; | 381 unsigned m_handleCount; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 const char* ResourceTypeName(Resource::Type); | 425 const char* ResourceTypeName(Resource::Type); |
| 423 #endif | 426 #endif |
| 424 | 427 |
| 425 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 428 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
| 426 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() =
= Resource::typeName, resource.type() == Resource::typeName); \ | 429 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() =
= Resource::typeName, resource.type() == Resource::typeName); \ |
| 427 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource
>& ptr) { return to##typeName##Resource(ptr.get()); } | 430 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource
>& ptr) { return to##typeName##Resource(ptr.get()); } |
| 428 | 431 |
| 429 } | 432 } |
| 430 | 433 |
| 431 #endif | 434 #endif |
| OLD | NEW |