Changeset 223558 in webkit
- Timestamp:
- Oct 17, 2017 11:21:37 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r223557 r223558 1 2017-10-17 Youenn Fablet <youenn@apple.com> 2 3 Cache API implementation should be able to compute storage size for WebKit client applications. 4 https://bugs.webkit.org/show_bug.cgi?id=178350 5 6 Reviewed by Chris Dumez. 7 8 * http/tests/cache-storage/cache-clearing-origin.https.html: 9 * http/tests/cache-storage/cache-representation.https.html: 10 1 11 2017-10-17 Ryan Haddad <ryanhaddad@apple.com> 2 12 -
trunk/LayoutTests/http/tests/cache-storage/cache-clearing-origin.https.html
r223299 r223558 31 31 var keys = await self.caches.keys(); 32 32 assert_not_equals(keys.length, 0, "keys should not be empty"); 33 assert_true(testRunner.domCacheSize(window.location.origin) > 0, "Actual origin cache size is not zero"); 33 34 34 35 testRunner.clearDOMCache(window.location.origin); 35 36 assert_false(testRunner.hasDOMCache(window.location.origin), "Actual origin cache is cleared"); 37 assert_equals(testRunner.domCacheSize(window.location.origin), 0, "Actual origin cache size is zero"); 36 38 37 39 keys = await self.caches.keys(); -
trunk/LayoutTests/http/tests/cache-storage/cache-representation.https.html
r221710 r223558 19 19 assert_equals(!!caches["persistent"].length, hasPersistent, "persistent"); 20 20 assert_equals(!!caches["removed"].length, hasRemoved, "removed"); 21 22 if (!hasPersistent) 23 assert_equals(testRunner.domCacheSize(results.origin), 0, "non persistent cache storage size is zero"); 24 21 25 }, name); 22 26 } -
trunk/Source/WebCore/ChangeLog
r223553 r223558 1 2017-10-17 Youenn Fablet <youenn@apple.com> 2 3 Cache API implementation should be able to compute storage size for WebKit client applications. 4 https://bugs.webkit.org/show_bug.cgi?id=178350 5 6 Reviewed by Chris Dumez. 7 8 * page/SecurityOriginData.h: 9 (WebCore::SecurityOriginData::equals const): 10 1 11 2017-10-17 Daniel Bates <dabates@apple.com> 2 12 -
trunk/Source/WebKit/ChangeLog
r223476 r223558 1 2017-10-17 Youenn Fablet <youenn@apple.com> 2 3 Cache API implementation should be able to compute storage size for WebKit client applications. 4 https://bugs.webkit.org/show_bug.cgi?id=178350 5 6 Reviewed by Chris Dumez. 7 8 When gathering data from DOM Cache, we compute the size as follows: 9 - If Caches object is not persistent, size is zero 10 - If Caches object is persistent, we use the size computed by NetworkCache::Storage. 11 Covered by updated tests. 12 13 * NetworkProcess/cache/CacheStorageEngine.cpp: 14 (WebKit::CacheStorage::ReadOriginsTaskCounter::create): 15 (WebKit::CacheStorage::ReadOriginsTaskCounter::addOrigin): 16 (WebKit::CacheStorage::Engine::fetchEntries): 17 * NetworkProcess/cache/CacheStorageEngineCaches.cpp: 18 (WebKit::CacheStorage::Caches::storageSize const): 19 * NetworkProcess/cache/CacheStorageEngineCaches.h: 20 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 21 (WKWebsiteDataStoreGetFetchCacheSizeForOrigin): 22 * UIProcess/API/C/WKWebsiteDataStoreRef.h: 23 1 24 2017-10-17 Keith Miller <keith_miller@apple.com> 2 25 -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
r223299 r223558 349 349 static Ref<ReadOriginsTaskCounter> create(WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&& callback) 350 350 { 351 return adoptRef(*new ReadOriginsTaskCounter(WTFMove(callback)));} 351 return adoptRef(*new ReadOriginsTaskCounter(WTFMove(callback))); 352 } 352 353 353 354 ~ReadOriginsTaskCounter() … … 356 357 } 357 358 358 void addOrigin(WebCore::SecurityOriginData&& origin )359 void addOrigin(WebCore::SecurityOriginData&& origin, uint64_t size) 359 360 { 360 m_entries.append(WebsiteData::Entry { WTFMove(origin), WebsiteDataType::DOMCache, 0});361 m_entries.append(WebsiteData::Entry { WTFMove(origin), WebsiteDataType::DOMCache, size }); 361 362 } 362 363 … … 371 372 }; 372 373 373 void Engine::fetchEntries(bool /* shouldComputeSize */, WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&& completionHandler)374 void Engine::fetchEntries(bool shouldComputeSize, WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&& completionHandler) 374 375 { 375 376 if (!shouldPersist()) { … … 385 386 if (!WebCore::fileIsDirectory(folderPath, WebCore::ShouldFollowSymbolicLinks::No)) 386 387 continue; 387 Caches::retrieveOriginFromDirectory(folderPath, *m_ioQueue, [ taskCounter = taskCounter.copyRef()] (std::optional<WebCore::SecurityOriginData>&& origin) mutable {388 Caches::retrieveOriginFromDirectory(folderPath, *m_ioQueue, [protectedThis = makeRef(*this), shouldComputeSize, taskCounter = taskCounter.copyRef()] (std::optional<WebCore::SecurityOriginData>&& origin) mutable { 388 389 ASSERT(RunLoop::isMain()); 389 if (origin) 390 taskCounter->addOrigin(WTFMove(origin.value())); 390 if (!origin) 391 return; 392 393 if (!shouldComputeSize) { 394 taskCounter->addOrigin(WTFMove(origin.value()), 0); 395 return; 396 } 397 398 auto cacheOrigin = origin->securityOrigin()->toString(); 399 protectedThis->readCachesFromDisk(cacheOrigin, [origin = WTFMove(origin.value()), taskCounter = WTFMove(taskCounter)] (CachesOrError&& result) mutable { 400 if (!result.hasValue()) 401 return; 402 taskCounter->addOrigin(WTFMove(origin), result.value().get().storageSize()); 403 404 }); 391 405 }); 392 406 } -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp
r223299 r223558 531 531 } 532 532 533 uint64_t Caches::storageSize() const 534 { 535 ASSERT(m_isInitialized); 536 if (!shouldPersist()) 537 return 0; 538 return m_storage->approximateSize(); 539 } 540 533 541 } // namespace CacheStorage 534 542 -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h
r223299 r223558 74 74 void clearMemoryRepresentation(); 75 75 76 uint64_t storageSize() const; 77 76 78 private: 77 79 Caches(Engine&, String&& origin, String&& rootPath, uint64_t quota); -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r223299 r223558 30 30 #include "APIWebsiteDataStore.h" 31 31 #include "WKAPICast.h" 32 #include "WKSecurityOriginRef.h" 32 33 #include "WebResourceLoadStatisticsStore.h" 33 34 #include "WebResourceLoadStatisticsTelemetry.h" 34 35 #include "WebsiteData.h" 36 #include "WebsiteDataFetchOption.h" 35 37 #include "WebsiteDataRecord.h" 36 38 #include "WebsiteDataType.h" … … 369 371 }); 370 372 } 373 374 void WKWebsiteDataStoreGetFetchCacheSizeForOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef origin, void* context, WKWebsiteDataStoreGetFetchCacheSizeForOriginFunction callback) 375 { 376 OptionSet<WebKit::WebsiteDataFetchOption> fetchOptions = WebKit::WebsiteDataFetchOption::ComputeSizes; 377 378 WebKit::toImpl(dataStoreRef)->websiteDataStore().fetchData(WebKit::WebsiteDataType::DOMCache, fetchOptions, [origin, context, callback] (auto dataRecords) { 379 auto originData = WebCore::SecurityOriginData::fromSecurityOrigin(WebCore::SecurityOrigin::createFromString(WebKit::toImpl(origin)->string())); 380 for (auto& dataRecord : dataRecords) { 381 for (const auto& recordOrigin : dataRecord.origins) { 382 if (originData == recordOrigin) { 383 callback(dataRecord.size ? dataRecord.size->totalSize : 0, context); 384 return; 385 } 386 387 } 388 } 389 callback(0, context); 390 }); 391 } -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r223299 r223558 82 82 WK_EXPORT void WKWebsiteDataStoreGetFetchCacheOrigins(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreGetFetchCacheOriginsFunction function); 83 83 84 typedef void (*WKWebsiteDataStoreGetFetchCacheSizeForOriginFunction)(uint64_t, void*); 85 WK_EXPORT void WKWebsiteDataStoreGetFetchCacheSizeForOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef origin, void* context, WKWebsiteDataStoreGetFetchCacheSizeForOriginFunction function); 86 84 87 #ifdef __cplusplus 85 88 } -
trunk/Tools/ChangeLog
r223536 r223558 1 2017-10-17 Youenn Fablet <youenn@apple.com> 2 3 Cache API implementation should be able to compute storage size for WebKit client applications. 4 https://bugs.webkit.org/show_bug.cgi?id=178350 5 6 Reviewed by Chris Dumez. 7 8 Adding support for a domCacheSize getter. 9 10 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 11 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 12 (WTR::TestRunner::domCacheSize): 13 * WebKitTestRunner/InjectedBundle/TestRunner.h: 14 * WebKitTestRunner/TestController.cpp: 15 (WTR::FetchCacheSizeForOriginCallbackContext::FetchCacheSizeForOriginCallbackContext): 16 (WTR::fetchCacheSizeForOriginCallback): 17 (WTR::TestController::domCacheSize): 18 * WebKitTestRunner/TestController.h: 19 * WebKitTestRunner/TestInvocation.cpp: 20 (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): 21 1 22 2017-10-17 Nael Ouedraogo <nael.ouedraogo@crf.canon.fr> 2 23 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r223299 r223558 60 60 void clearDOMCache(DOMString origin); 61 61 boolean hasDOMCache(DOMString origin); 62 unsigned long domCacheSize(DOMString origin); 62 63 63 64 // Special options. -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r223433 r223558 1839 1839 } 1840 1840 1841 uint64_t TestRunner::domCacheSize(JSStringRef origin) 1842 { 1843 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("DOMCacheSize")); 1844 WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(origin)); 1845 WKTypeRef returnData = 0; 1846 WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData); 1847 return WKUInt64GetValue(static_cast<WKUInt64Ref>(returnData)); 1848 } 1849 1841 1850 } // namespace WTR -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r223433 r223558 166 166 void clearDOMCache(JSStringRef origin); 167 167 bool hasDOMCache(JSStringRef origin); 168 uint64_t domCacheSize(JSStringRef origin); 168 169 169 170 // Failed load condition testing -
trunk/Tools/WebKitTestRunner/TestController.cpp
r223502 r223558 2374 2374 } 2375 2375 2376 struct FetchCacheSizeForOriginCallbackContext { 2377 explicit FetchCacheSizeForOriginCallbackContext(TestController& controller) 2378 : testController(controller) 2379 { 2380 } 2381 2382 TestController& testController; 2383 2384 bool done { false }; 2385 uint64_t result { 0 }; 2386 }; 2387 2388 static void fetchCacheSizeForOriginCallback(uint64_t size, void* userData) 2389 { 2390 auto* context = static_cast<FetchCacheSizeForOriginCallbackContext*>(userData); 2391 context->done = true; 2392 context->result = size; 2393 context->testController.notifyDone(); 2394 } 2395 2396 uint64_t TestController::domCacheSize(WKStringRef origin) 2397 { 2398 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2399 FetchCacheSizeForOriginCallbackContext context(*this); 2400 WKWebsiteDataStoreGetFetchCacheSizeForOrigin(dataStore, origin, &context, fetchCacheSizeForOriginCallback); 2401 if (!context.done) 2402 runUntil(context.done, m_currentInvocation->shortTimeout()); 2403 return context.result; 2404 } 2405 2376 2406 #if !PLATFORM(COCOA) || !WK_API_ENABLED 2377 2407 -
trunk/Tools/WebKitTestRunner/TestController.h
r223299 r223558 184 184 void statisticsResetToConsistentState(); 185 185 186 bool hasDOMCache(WKStringRef);187 188 186 WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); } 189 187 void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; } … … 192 190 193 191 void removeAllSessionCredentials(); 192 194 193 void clearDOMCache(WKStringRef origin); 194 bool hasDOMCache(WKStringRef origin); 195 uint64_t domCacheSize(WKStringRef origin); 195 196 196 197 private: -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r223299 r223558 1220 1220 } 1221 1221 1222 if (WKStringIsEqualToUTF8CString(messageName, "DOMCacheSize")) { 1223 ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); 1224 WKStringRef origin = static_cast<WKStringRef>(messageBody); 1225 1226 auto domCacheSize = TestController::singleton().domCacheSize(origin); 1227 WKRetainPtr<WKTypeRef> result(AdoptWK, WKUInt64Create(domCacheSize)); 1228 return result; 1229 } 1230 1222 1231 ASSERT_NOT_REACHED(); 1223 1232 return nullptr;
Note: See TracChangeset
for help on using the changeset viewer.