Changeset 221085 in webkit
- Timestamp:
- Aug 23, 2017 10:52:56 AM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r221081 r221085 1 2017-08-23 Youenn Fablet <youenn@apple.com> 2 3 CacheStorageEngine readCachesFromDisk callback should return the read Caches 4 https://bugs.webkit.org/show_bug.cgi?id=175882 5 6 Reviewed by Alex Christensen. 7 8 Callback of readCachesFromDisk takes now a Caches or error parameter. 9 10 * NetworkProcess/cache/CacheStorageEngine.cpp: 11 (WebKit::CacheStorageEngine::open): 12 (WebKit::CacheStorageEngine::retrieveCaches): 13 (WebKit::CacheStorageEngine::readCachesFromDisk): 14 * NetworkProcess/cache/CacheStorageEngine.h: 15 1 16 2017-08-23 Chris Dumez <cdumez@apple.com> 2 17 -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
r221024 r221085 65 65 void CacheStorageEngine::open(const String& origin, const String& cacheName, CacheIdentifierCallback&& callback) 66 66 { 67 readCachesFromDisk([this, origin, cacheName, callback = WTFMove(callback)](std::optional<Error>&& error) mutable { 68 if (error) { 69 callback(makeUnexpected(error.value())); 70 return; 71 } 72 73 auto& caches = m_caches.ensure(origin, [] { 74 return Vector<Cache>(); 75 }).iterator->value; 67 readCachesFromDisk(origin, [this, cacheName, callback = WTFMove(callback)](CachesOrError&& cachesOrError) mutable { 68 if (!cachesOrError.hasValue()) { 69 callback(makeUnexpected(cachesOrError.error())); 70 return; 71 } 72 73 auto& caches = cachesOrError.value().get(); 76 74 77 75 auto position = caches.findMatching([&](const auto& item) { return item.name == cacheName; }); … … 119 117 void CacheStorageEngine::retrieveCaches(const String& origin, CacheInfosCallback&& callback) 120 118 { 121 readCachesFromDisk([this, origin, callback = WTFMove(callback)](std::optional<Error>&& error) mutable { 122 if (error) { 123 callback(makeUnexpected(error.value())); 124 return; 125 } 126 callback(caches(origin)); 119 readCachesFromDisk(origin, [this, callback = WTFMove(callback)](CachesOrError&& cachesOrError) mutable { 120 if (!cachesOrError.hasValue()) { 121 callback(makeUnexpected(cachesOrError.error())); 122 return; 123 } 124 125 auto& caches = cachesOrError.value().get(); 126 127 Vector<WebCore::CacheStorageConnection::CacheInfo> cachesInfo; 128 cachesInfo.reserveInitialCapacity(caches.size()); 129 for (auto& cache : caches) 130 cachesInfo.uncheckedAppend(WebCore::CacheStorageConnection::CacheInfo { cache.identifier, cache.name}); 131 132 callback(WTFMove(cachesInfo)); 127 133 }); 128 134 } … … 231 237 } 232 238 233 void CacheStorageEngine::readCachesFromDisk( CompletionCallback&& callback)239 void CacheStorageEngine::readCachesFromDisk(const String& origin, CachesCallback&& callback) 234 240 { 235 241 // FIXME: Implement reading. 236 callback(std::nullopt); 242 243 auto& caches = m_caches.ensure(origin, [] { 244 return Vector<Cache>(); 245 }).iterator->value; 246 247 callback(std::reference_wrapper<Vector<Cache>> { caches }); 237 248 } 238 249 … … 278 289 } 279 290 280 Vector<WebCore::CacheStorageConnection::CacheInfo> CacheStorageEngine::caches(const String& origin) const281 {282 auto iterator = m_caches.find(origin);283 if (iterator == m_caches.end())284 return { };285 286 Vector<WebCore::CacheStorageConnection::CacheInfo> cachesInfo;287 cachesInfo.reserveInitialCapacity(iterator->value.size());288 for (auto& cache : iterator->value)289 cachesInfo.uncheckedAppend(WebCore::CacheStorageConnection::CacheInfo { cache.identifier, cache.name});290 291 return cachesInfo;292 }293 294 291 Vector<uint64_t> CacheStorageEngine::queryCache(const Vector<Record>& records, const WebCore::ResourceRequest& request, const WebCore::CacheQueryOptions& options) 295 292 { -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h
r220917 r221085 80 80 static CacheStorageEngine& defaultEngine(); 81 81 82 void writeCachesToDisk(CompletionCallback&&);83 void readCachesFromDisk(CompletionCallback&&);84 85 82 struct Cache { 86 83 uint64_t identifier; … … 90 87 }; 91 88 89 void writeCachesToDisk(CompletionCallback&&); 90 91 using CachesOrError = Expected<std::reference_wrapper<Vector<Cache>>, Error>; 92 using CachesCallback = Function<void(CachesOrError&&)>; 93 void readCachesFromDisk(const String& origin, Function<void(CachesOrError&&)>&&); 94 92 95 using CacheOrError = Expected<std::reference_wrapper<Cache>, Error>; 93 96 using CacheCallback = Function<void(CacheOrError&&)>; 94 95 Vector<WebCore::CacheStorageConnection::CacheInfo> caches(const String& origin) const;96 97 97 98 void readCache(uint64_t cacheIdentifier, CacheCallback&&);
Note: See TracChangeset
for help on using the changeset viewer.