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) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 ~CachedMetadataHandlerImpl() override {} | 103 ~CachedMetadataHandlerImpl() override {} |
104 DECLARE_VIRTUAL_TRACE(); | 104 DECLARE_VIRTUAL_TRACE(); |
105 void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; | 105 void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; |
106 void clearCachedMetadata(CacheType) override; | 106 void clearCachedMetadata(CacheType) override; |
107 CachedMetadata* cachedMetadata(unsigned) const override; | 107 CachedMetadata* cachedMetadata(unsigned) const override; |
108 String encoding() const override; | 108 String encoding() const override; |
109 // Sets the serialized metadata retrieved from the platform's cache. | 109 // Sets the serialized metadata retrieved from the platform's cache. |
110 void setSerializedCachedMetadata(const char*, size_t); | 110 void setSerializedCachedMetadata(const char*, size_t); |
111 | 111 |
| 112 void prune() override; |
| 113 |
112 protected: | 114 protected: |
113 explicit CachedMetadataHandlerImpl(Resource*); | 115 explicit CachedMetadataHandlerImpl(Resource*); |
114 virtual void sendToPlatform(); | 116 virtual void sendToPlatform(); |
115 const ResourceResponse& response() const { return m_resource->response(); } | 117 const ResourceResponse& response() const { return m_resource->response(); } |
116 | 118 |
117 RefPtr<CachedMetadata> m_cachedMetadata; | 119 RefPtr<CachedMetadata> m_cachedMetadata; |
118 | 120 |
119 private: | 121 private: |
120 Member<Resource> m_resource; | 122 Member<Resource> m_resource; |
121 }; | 123 }; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void Resource::CachedMetadataHandlerImpl::sendToPlatform() | 175 void Resource::CachedMetadataHandlerImpl::sendToPlatform() |
174 { | 176 { |
175 if (m_cachedMetadata) { | 177 if (m_cachedMetadata) { |
176 const Vector<char>& serializedData = m_cachedMetadata->serialize(); | 178 const Vector<char>& serializedData = m_cachedMetadata->serialize(); |
177 Platform::current()->cacheMetadata(response().url(), response().response
Time(), serializedData.data(), serializedData.size()); | 179 Platform::current()->cacheMetadata(response().url(), response().response
Time(), serializedData.data(), serializedData.size()); |
178 } else { | 180 } else { |
179 Platform::current()->cacheMetadata(response().url(), response().response
Time(), nullptr, 0); | 181 Platform::current()->cacheMetadata(response().url(), response().response
Time(), nullptr, 0); |
180 } | 182 } |
181 } | 183 } |
182 | 184 |
| 185 void Resource::CachedMetadataHandlerImpl::prune() |
| 186 { |
| 187 clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
| 188 } |
| 189 |
183 class Resource::ServiceWorkerResponseCachedMetadataHandler : public Resource::Ca
chedMetadataHandlerImpl { | 190 class Resource::ServiceWorkerResponseCachedMetadataHandler : public Resource::Ca
chedMetadataHandlerImpl { |
184 public: | 191 public: |
185 static Resource::CachedMetadataHandlerImpl* create(Resource* resource, Secur
ityOrigin* securityOrigin) | 192 static Resource::CachedMetadataHandlerImpl* create(Resource* resource, Secur
ityOrigin* securityOrigin) |
186 { | 193 { |
187 return new ServiceWorkerResponseCachedMetadataHandler(resource, security
Origin); | 194 return new ServiceWorkerResponseCachedMetadataHandler(resource, security
Origin); |
188 } | 195 } |
189 ~ServiceWorkerResponseCachedMetadataHandler() override {} | 196 ~ServiceWorkerResponseCachedMetadataHandler() override {} |
190 DECLARE_VIRTUAL_TRACE(); | 197 DECLARE_VIRTUAL_TRACE(); |
191 | 198 |
192 protected: | 199 protected: |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 if (scheduled && m_clientsAwaitingCallback.isEmpty()) | 828 if (scheduled && m_clientsAwaitingCallback.isEmpty()) |
822 ResourceCallback::callbackHandler().cancel(this); | 829 ResourceCallback::callbackHandler().cancel(this); |
823 | 830 |
824 // Prevent the case when there are clients waiting but no callback scheduled
. | 831 // Prevent the case when there are clients waiting but no callback scheduled
. |
825 ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled); | 832 ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled); |
826 } | 833 } |
827 | 834 |
828 void Resource::prune() | 835 void Resource::prune() |
829 { | 836 { |
830 destroyDecodedDataIfPossible(); | 837 destroyDecodedDataIfPossible(); |
| 838 if (m_cacheHandler) |
| 839 m_cacheHandler->prune(); |
831 unlock(); | 840 unlock(); |
832 } | 841 } |
833 | 842 |
834 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess
MemoryDump* memoryDump) const | 843 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess
MemoryDump* memoryDump) const |
835 { | 844 { |
836 static const size_t kMaxURLReportLength = 128; | 845 static const size_t kMaxURLReportLength = 128; |
837 static const int kMaxResourceClientToShowInMemoryInfra = 10; | 846 static const int kMaxResourceClientToShowInMemoryInfra = 10; |
838 | 847 |
839 const String dumpName = getMemoryDumpName(); | 848 const String dumpName = getMemoryDumpName(); |
840 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam
e); | 849 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam
e); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 case Resource::Media: | 1137 case Resource::Media: |
1129 return "Media"; | 1138 return "Media"; |
1130 case Resource::Manifest: | 1139 case Resource::Manifest: |
1131 return "Manifest"; | 1140 return "Manifest"; |
1132 } | 1141 } |
1133 ASSERT_NOT_REACHED(); | 1142 ASSERT_NOT_REACHED(); |
1134 return "Unknown"; | 1143 return "Unknown"; |
1135 } | 1144 } |
1136 | 1145 |
1137 } // namespace blink | 1146 } // namespace blink |
OLD | NEW |