Chromium Code Reviews| Index: Source/core/fetch/Resource.h |
| diff --git a/Source/core/fetch/Resource.h b/Source/core/fetch/Resource.h |
| index 24db9ae9e8a6fde1f9911486acacebe495eaa289..28deeb7ad0fa1d48f4efcbb770064563d55f5310 100644 |
| --- a/Source/core/fetch/Resource.h |
| +++ b/Source/core/fetch/Resource.h |
| @@ -23,6 +23,7 @@ |
| #ifndef Resource_h |
| #define Resource_h |
| +#include "core/fetch/CachedMetadataHandler.h" |
| #include "core/fetch/ResourceLoaderOptions.h" |
| #include "platform/Timer.h" |
| #include "platform/network/ResourceError.h" |
| @@ -83,11 +84,6 @@ public: |
| DecodeError |
| }; |
| - enum MetadataCacheType { |
| - SendToPlatform, // send cache data to blink::Platform::cacheMetadata |
| - CacheLocally // cache only in Resource's member variables |
| - }; |
| - |
| Resource(const ResourceRequest&, Type); |
| #if ENABLE(OILPAN) |
| virtual ~Resource(); |
| @@ -198,16 +194,7 @@ public: |
| // Sets the serialized metadata retrieved from the platform's cache. |
| virtual void setSerializedCachedMetadata(const char*, size_t); |
| - // Caches the given metadata in association with this resource and suggests |
| - // that the platform persist it. The dataTypeID is a pseudo-randomly chosen |
| - // identifier that is used to distinguish data generated by the caller. |
| - void setCachedMetadata(unsigned dataTypeID, const char*, size_t, MetadataCacheType = SendToPlatform); |
| - |
| - // Reset existing metadata, to allow setting new data. |
| - void clearCachedMetadata(MetadataCacheType = CacheLocally); |
| - |
| - // Returns cached metadata of the given type associated with this resource. |
| - CachedMetadata* cachedMetadata(unsigned dataTypeID) const; |
| + CachedMetadataHandler* cacheHandler(); |
|
vogelheim
2015/02/16 13:12:04
:) Just wanted to say I like this version better t
|
| bool hasOneHandle() const; |
| bool canDelete() const; |
| @@ -351,6 +338,17 @@ protected: |
| Timer<Resource> m_cancelTimer; |
| private: |
| + class CacheHandler : public CachedMetadataHandler { |
|
kinuko
2015/02/16 14:18:38
nit: Resource class is big, does it make sense to
horo
2015/02/16 16:20:12
Done.
|
| + public: |
| + CacheHandler(Resource*); |
| + ~CacheHandler() override { } |
| + void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; |
| + void clearCachedMetadata(CacheType) override; |
| + CachedMetadata* cachedMetadata(unsigned) const override; |
| + String encoding() const override; |
| + private: |
| + Resource* m_resource; |
| + }; |
| bool addClientToSet(ResourceClient*); |
| void cancelTimerFired(Timer<Resource>*); |
| @@ -363,9 +361,14 @@ private: |
| void failBeforeStarting(); |
| + void setCachedMetadata(unsigned dataTypeID, const char*, size_t, CachedMetadataHandler::CacheType); |
| + void clearCachedMetadata(CachedMetadataHandler::CacheType); |
| + CachedMetadata* cachedMetadata(unsigned dataTypeID) const; |
| + |
| String m_fragmentIdentifierForRequest; |
| RefPtr<CachedMetadata> m_cachedMetadata; |
| + CacheHandler m_cacheHandler; |
| ResourceError m_error; |