Changeset 223213 in webkit
- Timestamp:
- Oct 11, 2017 4:55:11 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 26 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r223211 r223213 1 2017-10-11 Youenn Fablet <youenn@apple.com> 2 3 Add API to clean CacheStorage data 4 https://bugs.webkit.org/show_bug.cgi?id=178034 5 6 Reviewed by Chris Dumez. 7 8 * http/tests/cache-storage/cache-clearing.https-expected.txt: Added. 9 * http/tests/cache-storage/cache-clearing.https.html: Added. 10 1 11 2017-10-11 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/Source/WTF/ChangeLog
r223149 r223213 1 2017-10-11 Youenn Fablet <youenn@apple.com> 2 3 Add API to clean CacheStorage data 4 https://bugs.webkit.org/show_bug.cgi?id=178034 5 6 Reviewed by Chris Dumez. 7 8 Moving CallbackAggregator pattern into its own class for easier reuse. 9 10 * WTF.xcodeproj/project.pbxproj: 11 * wtf/CallbackAggregator.h: Added. 12 (WTF::CallbackAggregator::create): 13 (WTF::CallbackAggregator::~CallbackAggregator): 14 (WTF::CallbackAggregator::CallbackAggregator): 15 1 16 2017-10-10 Sam Weinig <sam@webkit.org> 2 17 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r222771 r223213 305 305 313EDEC9778E49C9BEA91CFC /* StackTrace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackTrace.cpp; sourceTree = "<group>"; }; 306 306 37C7CC291EA40A73007BD956 /* WeakLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakLinking.h; sourceTree = "<group>"; }; 307 413FE8F51F8D2EAB00F6D7D7 /* CallbackAggregator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallbackAggregator.h; sourceTree = "<group>"; }; 307 308 430B47871AAAAC1A001223DA /* StringCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringCommon.h; sourceTree = "<group>"; }; 308 309 46BA9EAB1F4CD61E009A2BBC /* CompletionHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompletionHandler.h; sourceTree = "<group>"; }; … … 769 770 0FEC3C4F1F323C6800F59B6C /* CagedPtr.h */, 770 771 0F5F3D681F3FEBA600B115A2 /* CagedUniquePtr.h */, 772 413FE8F51F8D2EAB00F6D7D7 /* CallbackAggregator.h */, 771 773 A8A4726A151A825A004123FF /* CheckedArithmetic.h */, 772 774 A8A4726B151A825A004123FF /* CheckedBoolean.h */, -
trunk/Source/WTF/wtf/CallbackAggregator.h
r223212 r223213 1 1 /* 2 * Copyright (C) 201 4-2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef WebsiteDataType_h 27 #define WebsiteDataType_h 26 #pragma once 28 27 29 namespace WebKit { 28 #include "CompletionHandler.h" 29 #include "MainThread.h" 30 #include "ThreadSafeRefCounted.h" 30 31 31 enum class WebsiteDataType { 32 Cookies = 1 << 0, 33 DiskCache = 1 << 1, 34 MemoryCache = 1 << 2, 35 OfflineWebApplicationCache = 1 << 3, 36 SessionStorage = 1 << 4, 37 LocalStorage = 1 << 5, 38 WebSQLDatabases = 1 << 6, 39 IndexedDBDatabases = 1 << 7, 40 MediaKeys = 1 << 8, 41 HSTSCache = 1 << 9, 42 SearchFieldRecentSearches = 1 << 10, 43 #if ENABLE(NETSCAPE_PLUGIN_API) 44 PlugInData = 1 << 11, 45 #endif 46 ResourceLoadStatistics = 1 << 12, 47 Credentials = 1 << 13, 48 #if ENABLE(SERVICE_WORKER) 49 ServiceWorkerRegistrations = 1 << 14, 50 #endif 32 namespace WTF { 33 34 class CallbackAggregator : public ThreadSafeRefCounted<CallbackAggregator> { 35 public: 36 static Ref<CallbackAggregator> create(CompletionHandler<void()>&& callback) { return adoptRef(*new CallbackAggregator(WTFMove(callback))); } 37 38 ~CallbackAggregator() 39 { 40 if (!m_callback) 41 return; 42 if (isMainThread()) { 43 m_callback(); 44 return; 45 } 46 callOnMainThread([callback = WTFMove(m_callback)] () mutable { 47 callback(); 48 }); 49 } 50 51 private: 52 explicit CallbackAggregator(CompletionHandler<void()>&& callback) 53 : m_callback(WTFMove(callback)) 54 { 55 } 56 57 CompletionHandler<void()> m_callback; 51 58 }; 52 59 53 } ;60 } // namespace WTF 54 61 55 #endif // WebsiteDataType_h 62 using WTF::CallbackAggregator; -
trunk/Source/WebCore/ChangeLog
r223212 r223213 1 2017-10-11 Youenn Fablet <youenn@apple.com> 2 3 Add API to clean CacheStorage data 4 https://bugs.webkit.org/show_bug.cgi?id=178034 5 6 Reviewed by Chris Dumez. 7 8 Test: http/tests/cache-storage/cache-clearing.https.html 9 10 * platform/FileSystem.h: 11 1 12 2017-10-11 David Kilzer <ddkilzer@apple.com> 2 13 -
trunk/Source/WebCore/platform/FileSystem.h
r221617 r223213 105 105 WEBCORE_EXPORT std::optional<FileMetadata> fileMetadata(const String& path); 106 106 WEBCORE_EXPORT std::optional<FileMetadata> fileMetadataFollowingSymlinks(const String& path); 107 bool fileIsDirectory(const String&, ShouldFollowSymbolicLinks);107 WEBCORE_EXPORT bool fileIsDirectory(const String&, ShouldFollowSymbolicLinks); 108 108 WEBCORE_EXPORT String pathByAppendingComponent(const String& path, const String& component); 109 109 String pathByAppendingComponents(StringView path, const Vector<StringView>& components); -
trunk/Source/WebKit/ChangeLog
r223211 r223213 1 2017-10-11 Youenn Fablet <youenn@apple.com> 2 3 Add API to clean CacheStorage data 4 https://bugs.webkit.org/show_bug.cgi?id=178034 5 6 Reviewed by Chris Dumez. 7 8 Introducing a new website data type for DOMCache. 9 Adding API to delete DOMCache for a given origin or for all origins. 10 This is added to WKWebsiteDataStore. 11 12 Cleaning a CacheStorage will remove all data in the Cache object but the object will stay live 13 for the duration of the NetworkProcess. 14 This allows ensuring that once a cache is cleaned, WebProcess will update to this new state. 15 16 Fetching of WebsiteData for DOMCache is not implemented yet since we do not keep a list of all origins for which we have data. 17 18 * NetworkProcess/NetworkProcess.cpp: 19 (WebKit::fetchDOMCacheEntries): 20 (WebKit::NetworkProcess::fetchWebsiteData): 21 (WebKit::NetworkProcess::deleteWebsiteData): 22 (WebKit::NetworkProcess::deleteWebsiteDataForOrigins): 23 * NetworkProcess/cache/CacheStorageEngine.cpp: 24 (WebKit::CacheStorage::Engine::cachesRootPath): 25 (WebKit::CacheStorage::Engine::fetchEntries): 26 (WebKit::CacheStorage::ClearTasksHandler::ClearTasksHandler): 27 (WebKit::CacheStorage::ClearTasksHandler::~ClearTasksHandler): 28 (WebKit::CacheStorage::Engine::clearEngines): 29 (WebKit::CacheStorage::Engine::clearCachesForOrigins): 30 (WebKit::CacheStorage::Engine::readCachesFromDisk): 31 (WebKit::CacheStorage::deleteFolder): 32 (WebKit::CacheStorage::Engine::clearCaches): 33 (WebKit::CacheStorage::Engine::unlock): Removing the assertion as Cache objects are removed when clearing data. 34 * NetworkProcess/cache/CacheStorageEngine.h: 35 * NetworkProcess/cache/CacheStorageEngineCaches.cpp: 36 (WebKit::CacheStorage::Caches::Caches): 37 (WebKit::CacheStorage::Caches::clear): 38 * NetworkProcess/cache/CacheStorageEngineCaches.h: 39 (WebKit::CacheStorage::Caches::create): 40 * Shared/WebsiteData/WebsiteDataType.h: 41 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 42 (WKWebsiteDataStoreRemoveAllDOMCaches): 43 (WKWebsiteDataStoreRemoveDOMCacheForOrigin): 44 * UIProcess/API/C/WKWebsiteDataStoreRef.h: 45 * UIProcess/API/Cocoa/WKWebsiteDataRecord.h: 46 * UIProcess/API/Cocoa/WKWebsiteDataRecord.mm: 47 (dataTypesToString): 48 * UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h: 49 (WebKit::toWebsiteDataType): 50 (WebKit::toWKWebsiteDataTypes): 51 * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: 52 (+[WKWebsiteDataStore allWebsiteDataTypes]): 53 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 54 (WebKit::computeNetworkProcessAccessTypeForDataFetch): 55 (WebKit::computeNetworkProcessAccessTypeForDataRemoval): 56 1 57 2017-10-11 Chris Dumez <cdumez@apple.com> 2 58 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r223207 r223213 67 67 #include <WebCore/URLParser.h> 68 68 #include <pal/SessionID.h> 69 #include <wtf/CallbackAggregator.h> 69 70 #include <wtf/OptionSet.h> 70 71 #include <wtf/RunLoop.h> … … 408 409 }); 409 410 } 411 412 if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) { 413 CacheStorage::Engine::fetchEntries(sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [callbackAggregator = WTFMove(callbackAggregator)](auto entries) mutable { 414 callbackAggregator->m_websiteData.entries.appendVector(entries); 415 }); 416 } 410 417 } 411 418 … … 428 435 NetworkStorageSession::storageSession(sessionID)->credentialStorage().clearCredentials(); 429 436 } 430 431 auto c ompletionHandler =[this, callbackID] {437 438 auto clearTasksHandler = WTF::CallbackAggregator::create([this, callbackID] { 432 439 parentProcessConnection()->send(Messages::NetworkProcessProxy::DidDeleteWebsiteData(callbackID), 0); 433 }; 434 435 if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral()) { 436 clearDiskCache(modifiedSince, WTFMove(completionHandler)); 437 return; 438 } 439 440 completionHandler(); 440 }); 441 442 if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) 443 CacheStorage::Engine::clearAllEngines([clearTasksHandler = clearTasksHandler.copyRef()] { }); 444 445 if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral()) 446 clearDiskCache(modifiedSince, [clearTasksHandler = WTFMove(clearTasksHandler)] { }); 441 447 } 442 448 … … 466 472 } 467 473 468 void NetworkProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, const Vector<SecurityOriginData>& origin s, const Vector<String>& cookieHostNames, uint64_t callbackID)474 void NetworkProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, const Vector<SecurityOriginData>& originDatas, const Vector<String>& cookieHostNames, uint64_t callbackID) 469 475 { 470 476 if (websiteDataTypes.contains(WebsiteDataType::Cookies)) { … … 473 479 } 474 480 475 auto c ompletionHandler =[this, callbackID] {481 auto clearTasksHandler = WTF::CallbackAggregator::create([this, callbackID] { 476 482 parentProcessConnection()->send(Messages::NetworkProcessProxy::DidDeleteWebsiteDataForOrigins(callbackID), 0); 477 }; 478 479 if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral()) { 480 clearDiskCacheEntries(origins, WTFMove(completionHandler)); 481 return; 482 } 483 484 completionHandler(); 483 }); 484 485 if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) { 486 auto origins = WTF::map(originDatas, [] (auto& originData) { 487 return originData.securityOrigin()->toString(); 488 }); 489 CacheStorage::Engine::clearEnginesForOrigins(origins, [clearTasksHandler = clearTasksHandler.copyRef()] { }); 490 } 491 492 if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral()) 493 clearDiskCacheEntries(originDatas, [clearTasksHandler = WTFMove(clearTasksHandler)] { }); 485 494 } 486 495 -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
r223073 r223213 27 27 #include "CacheStorageEngine.h" 28 28 29 #include "NetworkCacheFileSystem.h" 29 30 #include "NetworkCacheIOChannel.h" 30 31 #include "NetworkProcess.h" 31 32 #include <WebCore/CacheQueryOptions.h> 33 #include <WebCore/NotImplemented.h> 32 34 #include <pal/SessionID.h> 33 #include <wtf/ MainThread.h>35 #include <wtf/CallbackAggregator.h> 34 36 #include <wtf/NeverDestroyed.h> 35 37 #include <wtf/text/StringBuilder.h> … … 48 50 49 51 return map; 52 } 53 54 String Engine::cachesRootPath(const String& origin) 55 { 56 if (!shouldPersist()) 57 return { }; 58 59 Key key(origin, { }, { }, { }, salt()); 60 return WebCore::pathByAppendingComponent(rootPath(), key.partitionHashAsString()); 50 61 } 51 62 … … 68 79 ASSERT(sessionID != PAL::SessionID::defaultSessionID()); 69 80 globalEngineMap().remove(sessionID); 81 } 82 83 void Engine::fetchEntries(PAL::SessionID sessionID, bool shouldComputeSize, WTF::Function<void(Vector<WebsiteData::Entry>)>&& completionHandler) 84 { 85 // FIXME: Support fetching entries 86 notImplemented(); 87 completionHandler({ }); 88 } 89 90 void Engine::clearAllEngines(WTF::Function<void()>&& completionHandler) 91 { 92 auto clearTaskHandler = CallbackAggregator::create(WTFMove(completionHandler)); 93 for (auto& engine : globalEngineMap().values()) 94 engine->clearAllCaches(clearTaskHandler.get()); 95 } 96 97 void Engine::clearEnginesForOrigins(const Vector<String>& origins, WTF::Function<void()>&& completionHandler) 98 { 99 auto clearTaskHandler = CallbackAggregator::create(WTFMove(completionHandler)); 100 for (auto& engine : globalEngineMap().values()) { 101 for (auto& origin : origins) 102 engine->clearCachesForOrigin(origin, clearTaskHandler.get()); 103 } 70 104 } 71 105 … … 191 225 initialize([this, origin, callback = WTFMove(callback)](std::optional<Error>&& error) mutable { 192 226 auto& caches = m_caches.ensure(origin, [&origin, this] { 193 return Caches::create(*this, String { origin }, NetworkProcess::singleton().cacheStoragePerOriginQuota());227 return Caches::create(*this, String { origin }, cachesRootPath(origin), NetworkProcess::singleton().cacheStoragePerOriginQuota()); 194 228 }).iterator->value; 195 229 … … 312 346 } 313 347 348 void Engine::clearAllCaches(CallbackAggregator& taskHandler) 349 { 350 for (auto& caches : m_caches.values()) 351 caches->clear([taskHandler = makeRef(taskHandler)] { }); 352 353 if (!shouldPersist()) 354 return; 355 356 m_ioQueue->dispatch([filename = m_rootPath.isolatedCopy(), taskHandler = makeRef(taskHandler)] { 357 deleteDirectoryRecursively(filename); 358 }); 359 } 360 361 void Engine::clearCachesForOrigin(const String& origin, CallbackAggregator& taskHandler) 362 { 363 if (auto caches = m_caches.get(origin)) { 364 caches->clear([taskHandler = makeRef(taskHandler)] { }); 365 return; 366 } 367 368 if (!shouldPersist()) 369 return; 370 371 m_ioQueue->dispatch([filename = cachesRootPath(origin), taskHandler = makeRef(taskHandler)] { 372 deleteDirectoryRecursively(filename); 373 }); 374 } 375 314 376 void Engine::clearMemoryRepresentation(const String& origin, WebCore::DOMCacheEngine::CompletionCallback&& callback) 315 377 { … … 336 398 { 337 399 auto lockCount = m_cacheLocks.find(cacheIdentifier); 338 ASSERT(lockCount != m_cacheLocks.end());339 400 if (lockCount == m_cacheLocks.end()) 340 401 return; -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h
r221995 r223213 28 28 #include "CacheStorageEngineCaches.h" 29 29 #include "NetworkCacheData.h" 30 #include "WebsiteData.h" 30 31 #include <wtf/HashMap.h> 31 32 #include <wtf/ThreadSafeRefCounted.h> … … 39 40 class SessionID; 40 41 } 42 43 namespace WTF { 44 class CallbackAggregator; 45 }; 41 46 42 47 namespace WebKit { … … 53 58 static Engine& from(PAL::SessionID); 54 59 static void destroyEngine(PAL::SessionID); 60 static void clearAllEngines(WTF::Function<void()>&&); 61 static void clearEnginesForOrigins(const Vector<String>& origins, WTF::Function<void()>&&); 62 static void fetchEntries(PAL::SessionID, bool shouldComputeSize, WTF::Function<void(Vector<WebsiteData::Entry>)>&&); 63 55 64 static Ref<Engine> create(String&& rootPath) { return adoptRef(*new Engine(WTFMove(rootPath))); } 56 65 … … 85 94 explicit Engine(String&& rootPath); 86 95 87 void initialize(Function<void(std::optional<WebCore::DOMCacheEngine::Error>&&)>&&); 96 String cachesRootPath(const String& origin); 97 98 void initialize(WTF::Function<void(std::optional<WebCore::DOMCacheEngine::Error>&&)>&&); 99 void clearAllCaches(WTF::CallbackAggregator&); 100 void clearCachesForOrigin(const String& origin, WTF::CallbackAggregator&); 88 101 89 102 using CachesOrError = Expected<std::reference_wrapper<Caches>, WebCore::DOMCacheEngine::Error>; -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp
r223073 r223213 28 28 29 29 #include "NetworkCacheCoders.h" 30 #include <wtf/RunLoop.h> 30 31 #include <wtf/UUID.h> 31 32 #include <wtf/text/StringBuilder.h> … … 38 39 namespace CacheStorage { 39 40 40 static inline String cachesRootPath(Engine& engine, const String& origin)41 {42 if (!engine.shouldPersist())43 return { };44 45 Key key(origin, { }, { }, { }, engine.salt());46 return WebCore::pathByAppendingComponent(engine.rootPath(), key.partitionHashAsString());47 }48 49 41 static inline String cachesListFilename(const String& cachesRootPath) 50 42 { … … 52 44 } 53 45 54 Caches::Caches(Engine& engine, String&& origin, uint64_t quota)46 Caches::Caches(Engine& engine, String&& origin, String&& rootPath, uint64_t quota) 55 47 : m_engine(&engine) 56 48 , m_origin(WTFMove(origin)) 57 , m_rootPath( cachesRootPath(engine, m_origin))49 , m_rootPath(WTFMove(rootPath)) 58 50 , m_quota(quota) 59 51 { … … 127 119 m_engine = nullptr; 128 120 m_rootPath = { }; 121 } 122 123 void Caches::clear(CompletionHandler<void()>&& completionHandler) 124 { 125 if (m_engine) 126 m_engine->removeFile(cachesListFilename(m_rootPath)); 127 if (m_storage) { 128 m_storage->clear(String { }, std::chrono::system_clock::time_point::min(), [protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable { 129 ASSERT(RunLoop::isMain()); 130 protectedThis->clearMemoryRepresentation(); 131 completionHandler(); 132 }); 133 return; 134 } 135 clearMemoryRepresentation(); 136 completionHandler(); 129 137 } 130 138 -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h
r223073 r223213 28 28 #include "CacheStorageEngineCache.h" 29 29 #include "NetworkCacheStorage.h" 30 #include <wtf/CompletionHandler.h> 30 31 31 32 namespace WebKit { … … 37 38 class Caches : public RefCounted<Caches> { 38 39 public: 39 static Ref<Caches> create(Engine& engine, String&& origin, uint64_t quota) { return adoptRef(*new Caches { engine, WTFMove(origin), quota }); }40 static Ref<Caches> create(Engine& engine, String&& origin, String&& rootPath, uint64_t quota) { return adoptRef(*new Caches { engine, WTFMove(origin), WTFMove(rootPath), quota }); } 40 41 41 42 void initialize(WebCore::DOMCacheEngine::CompletionCallback&&); 42 43 void open(const String& name, WebCore::DOMCacheEngine::CacheIdentifierCallback&&); 43 44 void remove(uint64_t identifier, WebCore::DOMCacheEngine::CacheIdentifierCallback&&); 44 void clearMemoryRepresentation();45 45 void dispose(Cache&); 46 46 … … 67 67 bool shouldPersist() const { return !m_rootPath.isNull(); } 68 68 69 void clear(WTF::CompletionHandler<void()>&&); 70 void clearMemoryRepresentation(); 71 69 72 private: 70 Caches(Engine&, String&& origin, uint64_t quota);73 Caches(Engine&, String&& origin, String&& rootPath, uint64_t quota); 71 74 72 75 void initializeSize(WebCore::DOMCacheEngine::CompletionCallback&&); -
trunk/Source/WebKit/Shared/WebsiteData/WebsiteDataType.h
r223158 r223213 49 49 ServiceWorkerRegistrations = 1 << 14, 50 50 #endif 51 DOMCache = 1 << 14, 51 52 }; 52 53 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r223158 r223213 32 32 #include "WebResourceLoadStatisticsTelemetry.h" 33 33 #include "WebsiteData.h" 34 #include "WebsiteDataRecord.h" 34 35 #include "WebsiteDataType.h" 35 36 #include <WebCore/URL.h> … … 318 319 store->resetParametersToDefaultValues(); 319 320 store->scheduleClearInMemory(); 321 } 322 323 void WKWebsiteDataStoreRemoveAllFetchCaches(WKWebsiteDataStoreRef dataStoreRef) 324 { 325 OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::DOMCache; 326 WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, std::chrono::system_clock::time_point::min(), [] { }); 327 } 328 329 void WKWebsiteDataStoreRemoveFetchCacheForOrigin(WKWebsiteDataStoreRef dataStoreRef, WKSecurityOriginRef origin) 330 { 331 WebKit::WebsiteDataRecord dataRecord; 332 dataRecord.add(WebKit::WebsiteDataType::DOMCache, WebCore::SecurityOriginData::fromSecurityOrigin(WebKit::toImpl(origin)->securityOrigin())); 333 Vector<WebKit::WebsiteDataRecord> dataRecords = { WTFMove(dataRecord) }; 334 335 OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::DOMCache; 336 WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, dataRecords, [] { }); 320 337 } 321 338 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r223158 r223213 71 71 WK_EXPORT void WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemoval(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemovalFunction callback); 72 72 WK_EXPORT void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef); 73 WK_EXPORT void WKWebsiteDataStoreRemoveFetchCacheForOrigin(WKWebsiteDataStoreRef dataStoreRef, WKSecurityOriginRef origin); 74 WK_EXPORT void WKWebsiteDataStoreRemoveAllFetchCaches(WKWebsiteDataStoreRef dataStoreRef); 73 75 WK_EXPORT void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef); 74 76 WK_EXPORT void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef); -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecord.h
r223158 r223213 31 31 32 32 NS_ASSUME_NONNULL_BEGIN 33 34 /*! @constant WKWebsiteDataTypeFetchCache On-disk Fetch caches. */ 35 WK_EXTERN NSString * const WKWebsiteDataTypeFetchCache WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_MAC_TBA)); 33 36 34 37 /*! @constant WKWebsiteDataTypeDiskCache On-disk caches. */ -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm
r223158 r223213 31 31 #import "_WKWebsiteDataSizeInternal.h" 32 32 33 NSString * const WKWebsiteDataTypeFetchCache = @"WKWebsiteDataTypeFetchCache"; 33 34 NSString * const WKWebsiteDataTypeDiskCache = @"WKWebsiteDataTypeDiskCache"; 34 35 NSString * const WKWebsiteDataTypeMemoryCache = @"WKWebsiteDataTypeMemoryCache"; … … 68 69 if ([dataTypes containsObject:WKWebsiteDataTypeDiskCache]) 69 70 [array addObject:@"Disk Cache"]; 71 if ([dataTypes containsObject:WKWebsiteDataTypeFetchCache]) 72 [array addObject:@"Fetch Cache"]; 70 73 if ([dataTypes containsObject:WKWebsiteDataTypeMemoryCache]) 71 74 [array addObject:@"Memory Cache"]; -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h
r223158 r223213 45 45 if ([websiteDataType isEqualToString:WKWebsiteDataTypeCookies]) 46 46 return WebsiteDataType::Cookies; 47 if ([websiteDataType isEqualToString:WKWebsiteDataTypeFetchCache]) 48 return WebsiteDataType::DOMCache; 47 49 if ([websiteDataType isEqualToString:WKWebsiteDataTypeDiskCache]) 48 50 return WebsiteDataType::DiskCache; … … 100 102 if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) 101 103 [wkWebsiteDataTypes addObject:WKWebsiteDataTypeDiskCache]; 104 if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) 105 [wkWebsiteDataTypes addObject:WKWebsiteDataTypeFetchCache]; 102 106 if (websiteDataTypes.contains(WebsiteDataType::MemoryCache)) 103 107 [wkWebsiteDataTypes addObject:WKWebsiteDataTypeMemoryCache]; -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r223207 r223213 96 96 static NSSet *allWebsiteDataTypes; 97 97 dispatch_once(&onceToken, ^{ 98 allWebsiteDataTypes = [[NSSet alloc] initWithArray:@[ WKWebsiteDataTypeDiskCache, WKWebsiteDataType MemoryCache, WKWebsiteDataTypeOfflineWebApplicationCache, WKWebsiteDataTypeCookies, WKWebsiteDataTypeSessionStorage, WKWebsiteDataTypeLocalStorage, WKWebsiteDataTypeIndexedDBDatabases, WKWebsiteDataTypeServiceWorkerRegistrations, WKWebsiteDataTypeWebSQLDatabases ]];98 allWebsiteDataTypes = [[NSSet alloc] initWithArray:@[ WKWebsiteDataTypeDiskCache, WKWebsiteDataTypeFetchCache, WKWebsiteDataTypeMemoryCache, WKWebsiteDataTypeOfflineWebApplicationCache, WKWebsiteDataTypeCookies, WKWebsiteDataTypeSessionStorage, WKWebsiteDataTypeLocalStorage, WKWebsiteDataTypeIndexedDBDatabases, WKWebsiteDataTypeServiceWorkerRegistrations, WKWebsiteDataTypeWebSQLDatabases ]]; 99 99 }); 100 100 -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r223158 r223213 162 162 processAccessType = std::max(processAccessType, ProcessAccessType::Launch); 163 163 164 if (dataTypes.contains(WebsiteDataType::DOMCache)) 165 processAccessType = std::max(processAccessType, ProcessAccessType::Launch); 166 164 167 return processAccessType; 165 168 } … … 570 573 processAccessType = std::max(processAccessType, ProcessAccessType::Launch); 571 574 575 if (dataTypes.contains(WebsiteDataType::DOMCache)) 576 processAccessType = std::max(processAccessType, ProcessAccessType::Launch); 577 572 578 return processAccessType; 573 579 } -
trunk/Tools/ChangeLog
r223211 r223213 1 2017-10-11 Youenn Fablet <youenn@apple.com> 2 3 Add API to clean CacheStorage data 4 https://bugs.webkit.org/show_bug.cgi?id=178034 5 6 Reviewed by Chris Dumez. 7 8 Adding internals API to trigger deleting all or origin-persistent cache storage persistent data. 9 10 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 11 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 12 (WTR::TestRunner::clearDOMCache): 13 * WebKitTestRunner/InjectedBundle/TestRunner.h: 14 * WebKitTestRunner/TestController.cpp: 15 (WTR::TestController::clearDOMCache): 16 * WebKitTestRunner/TestController.h: 17 * WebKitTestRunner/TestInvocation.cpp: 18 (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): 19 1 20 2017-10-11 Chris Dumez <cdumez@apple.com> 2 21 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r223211 r223213 57 57 void dumpDOMAsWebArchive(); 58 58 void dumpPolicyDelegateCallbacks(); 59 60 void clearDOMCache(DOMString origin); 59 61 60 62 // Special options. -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r223211 r223213 1778 1778 } 1779 1779 1780 void TestRunner::clearDOMCache(JSStringRef origin) 1781 { 1782 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ClearDOMCache")); 1783 WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(origin)); 1784 WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get()); 1785 } 1786 1780 1787 } // namespace WTR -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r223211 r223213 164 164 bool shouldDisallowIncreaseForApplicationCacheQuota() { return m_disallowIncreaseForApplicationCacheQuota; } 165 165 JSValueRef originsWithApplicationCache(); 166 167 void clearDOMCache(JSStringRef origin); 166 168 167 169 // Failed load condition testing -
trunk/Tools/WebKitTestRunner/TestController.cpp
r223211 r223213 2296 2296 #endif 2297 2297 2298 void TestController::clearDOMCache(WKStringRef origin) 2299 { 2300 #if WK_API_ENABLED 2301 auto websiteDataStore = WKContextGetWebsiteDataStore(platformContext()); 2302 2303 if (WKStringIsEmpty(origin)) { 2304 WKWebsiteDataStoreRemoveAllFetchCaches(websiteDataStore); 2305 return; 2306 } 2307 2308 auto cacheOrigin = adoptWK(WKSecurityOriginCreateFromString(origin)); 2309 WKWebsiteDataStoreRemoveFetchCacheForOrigin(websiteDataStore, cacheOrigin.get()); 2310 #endif 2311 } 2312 2298 2313 #if !PLATFORM(COCOA) || !WK_API_ENABLED 2299 2314 -
trunk/Tools/WebKitTestRunner/TestController.h
r223211 r223213 188 188 189 189 void removeAllSessionCredentials(); 190 void clearDOMCache(WKStringRef origin); 190 191 191 192 private: -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r223211 r223213 764 764 } 765 765 766 if (WKStringIsEqualToUTF8CString(messageName, "ClearDOMCache")) { 767 ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); 768 WKStringRef origin = static_cast<WKStringRef>(messageBody); 769 770 TestController::singleton().clearDOMCache(origin); 771 return; 772 } 773 766 774 ASSERT_NOT_REACHED(); 767 775 }
Note: See TracChangeset
for help on using the changeset viewer.