Changeset 243339 in webkit
- Timestamp:
- Mar 21, 2019, 3:52:18 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 18 edited
- 1 moved
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/http/tests/IndexedDB/storage-limit-1.https-expected.txt (added)
-
LayoutTests/http/tests/IndexedDB/storage-limit-1.https.html (moved) (moved from trunk/LayoutTests/http/tests/IndexedDB/resources/storage-limit.js ) (3 diffs)
-
LayoutTests/http/tests/IndexedDB/storage-limit-2.https-expected.txt (added)
-
LayoutTests/http/tests/IndexedDB/storage-limit-2.https.html (added)
-
LayoutTests/http/tests/IndexedDB/storage-limit.https.html (modified) (1 diff)
-
LayoutTests/platform/mac-wk1/TestExpectations (modified) (1 diff)
-
LayoutTests/platform/mac-wk2/TestExpectations (modified) (1 diff)
-
LayoutTests/platform/win/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/indexeddb/server/IDBServer.h (modified) (2 diffs)
-
Source/WebCore/storage/StorageQuotaManager.cpp (modified) (4 diffs)
-
Source/WebCore/storage/StorageQuotaManager.h (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.cpp (modified) (2 diffs)
-
Source/WebKit/NetworkProcess/NetworkProcess.h (modified) (1 diff)
-
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (modified) (1 diff)
-
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h (modified) (1 diff)
-
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp (modified) (3 diffs)
-
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243336 r243339 1 2019-03-21 Youenn Fablet <youenn@apple.com> 2 3 Cache API and IDB space usages should be initialized on first quota check 4 https://bugs.webkit.org/show_bug.cgi?id=195707 5 6 Reviewed by Chris Dumez. 7 8 * TestExpectations: 9 Marking http/tests/cache-storage/cache-clearing-origin.https.html as 10 flaky on iOS as it is already marked flaky in MacOS. 11 * platform/mac-wk2/TestExpectations: 12 * http/tests/IndexedDB/storage-limit-1.https-expected.txt: Added. 13 * http/tests/IndexedDB/storage-limit-1.https.html: Added. 14 * http/tests/IndexedDB/storage-limit-2.https-expected.txt: Added. 15 * http/tests/IndexedDB/storage-limit-2.https.html: Added. 16 * http/tests/IndexedDB/storage-limit.https.html: 17 * platform/mac-wk1/TestExpectations: 18 * platform/win/TestExpectations: 19 1 20 2019-03-21 Said Abou-Hallawa <sabouhallawa@apple.com> 2 21 -
trunk/LayoutTests/TestExpectations
r243331 r243339 2237 2237 2238 2238 webkit.org/b/182928 http/tests/cache-storage/cache-representation.https.html [ Pass Failure ] 2239 webkit.org/b/193976 http/tests/cache-storage/cache-clearing-origin.https.html [ Pass Failure ] 2239 2240 2240 2241 webkit.org/b/116621 fast/replaced/preferred-widths.html [ Pass Failure ] -
trunk/LayoutTests/http/tests/IndexedDB/storage-limit-1.https.html
r243338 r243339 1 <html> 2 <head> 3 <script src="/js-test-resources/js-test.js"></script> 4 <script src="resources/shared.js"></script> 5 </head> 6 <body> 7 <script> 1 8 if (window.testRunner) 2 9 testRunner.setAllowStorageQuotaIncrease(false); 3 10 4 description("This test makes sure that storage of indexedDB doesnot grow unboundedly.");11 description("This test makes sure that storage of indexedDB and Cache API do not grow unboundedly."); 5 12 6 13 window.caches.open("test").then(cache => { 7 return cache.put(new Request("/test"), new Response(new Uint8Array(204800))); 8 }).then(() => { 14 return cache.put(new Request("/test"), new Response(new Uint8Array(200 * 1024))); 15 }).then(async() => { 16 // Let's terminate the network process so that all the opened quota users are gone for IDB quota check. 17 if (window.testRunner) 18 testRunner.terminateNetworkProcess(); 19 while (true) { 20 try { 21 await fetch("."); 22 break; 23 } catch (e) { } 24 } 9 25 indexedDBTest(prepareDatabase, onOpenSuccess, {'suffix': '-1'}); 10 26 }).catch(e => { … … 20 36 21 37 // Quota for test is 400ko, but IDB is eating some of it when initializing files. 22 // Let's make sure that 200ko is fine but 200ko after 200ko is not fine.38 // Let's make sure that 200ko is fine but 300ko after 200ko is not fine. 23 39 async function onOpenSuccess(event) 24 40 { 25 41 evalAndLog("db = event.target.result"); 26 42 evalAndLog("store = db.transaction('store', 'readwrite').objectStore('store')"); 27 evalAndLog("request = store.add(new Uint8Array( 204800), 'key')");43 evalAndLog("request = store.add(new Uint8Array(300 * 1024), 'key')"); 28 44 request.onerror = function(event) { 29 45 shouldBeTrue("'error' in request"); … … 37 53 finishJSTest(); 38 54 } 39 } 55 }</script> 56 </body> 57 </html> -
trunk/LayoutTests/http/tests/IndexedDB/storage-limit.https.html
r242911 r243339 5 5 </head> 6 6 <body> 7 <script src="resources/storage-limit.js"></script> 7 <script> 8 if (window.testRunner) 9 testRunner.setAllowStorageQuotaIncrease(false); 10 11 description("This test makes sure that storage of indexedDB does not grow unboundedly."); 12 13 window.caches.open("test").then(cache => { 14 return cache.put(new Request("/test"), new Response(new Uint8Array(204800))); 15 }).then(() => { 16 indexedDBTest(prepareDatabase, onOpenSuccess, {'suffix': '-1'}); 17 }).catch(e => { 18 testFailed("Cache API store operation failed: " + e); 19 finishJSTest(); 20 }); 21 22 function prepareDatabase(event) 23 { 24 evalAndLog("db = event.target.result"); 25 evalAndLog("store = db.createObjectStore('store')"); 26 } 27 28 // Quota for test is 400ko, but IDB is eating some of it when initializing files. 29 // Let's make sure that 200ko is fine but 200ko after 200ko is not fine. 30 async function onOpenSuccess(event) 31 { 32 evalAndLog("db = event.target.result"); 33 evalAndLog("store = db.transaction('store', 'readwrite').objectStore('store')"); 34 evalAndLog("request = store.add(new Uint8Array(204800), 'key')"); 35 request.onerror = function(event) { 36 shouldBeTrue("'error' in request"); 37 shouldBe("request.error.code", "DOMException.QUOTA_EXCEEDED_ERR"); 38 shouldBeEqualToString("request.error.name", "QuotaExceededError"); 39 finishJSTest(); 40 } 41 42 request.onsuccess = function(event) { 43 testFailed("Add operation should fail because storage limit is reached, but succeeded."); 44 finishJSTest(); 45 } 46 } 47 </script> 8 48 </body> 9 49 </html> -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r242920 r243339 165 165 # Quota check missing in WK1 166 166 http/tests/IndexedDB/storage-limit.https.html [ Skip ] 167 http/tests/IndexedDB/storage-limit-1.https.html [ Skip ] 168 http/tests/IndexedDB/storage-limit-2.https.html [ Skip ] 167 169 storage/indexeddb/storage-limit.html [ Skip ] 168 170 -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r243255 r243339 913 913 webkit.org/b/191658 [ Sierra Release ] fast/layers/no-clipping-overflow-hidden-added-after-transform.html [ Pass ImageOnlyFailure ] 914 914 915 webkit.org/b/193976 http/tests/cache-storage/cache-clearing-origin.https.html [ Pass Failure ]916 917 915 webkit.org/b/194826 http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html [ Pass Timeout ] 918 916 -
trunk/LayoutTests/platform/win/TestExpectations
r242986 r243339 2376 2376 storage/indexeddb/storage-limit.html [ Skip ] 2377 2377 http/tests/IndexedDB/storage-limit.https.html [ Skip ] 2378 http/tests/IndexedDB/storage-limit-1.https.html [ Skip ] 2379 http/tests/IndexedDB/storage-limit-2.https.html [ Skip ] 2378 2380 2379 2381 # Assertion failures: Not investigated -
trunk/Source/WebCore/ChangeLog
r243338 r243339 1 2019-03-21 Youenn Fablet <youenn@apple.com> 2 3 Cache API and IDB space usages should be initialized on first quota check 4 https://bugs.webkit.org/show_bug.cgi?id=195707 5 6 Reviewed by Chris Dumez. 7 8 Add a way to require IDBServer to create a quota user for a given origin. 9 Make sure that removing a user might kick-in processing of pending requests. 10 In the case of processing pending requests, we should not decide on the first task 11 except if it is triggered by a request space response. 12 Update processPendingRequests accordingly. 13 14 Tests: http/tests/IndexedDB/storage-limit-1.https.html 15 http/tests/IndexedDB/storage-limit-2.https.html 16 17 * Modules/indexeddb/server/IDBServer.h: 18 (WebCore::IDBServer::IDBServer::initializeQuotaUser): 19 * storage/StorageQuotaManager.cpp: 20 (WebCore::StorageQuotaManager::removeUser): 21 (WebCore::StorageQuotaManager::askForMoreSpace): 22 (WebCore::StorageQuotaManager::processPendingRequests): 23 * storage/StorageQuotaManager.h: 24 1 25 2019-03-21 Alex Christensen <achristensen@webkit.org> 2 26 -
trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp
r243019 r243339 785 785 } 786 786 787 IDBServer::QuotaUser& IDBServer:: quotaUser(const ClientOrigin& origin)787 IDBServer::QuotaUser& IDBServer::ensureQuotaUser(const ClientOrigin& origin) 788 788 { 789 789 return *m_quotaUsers.ensure(origin, [this, &origin] { … … 811 811 void IDBServer::finishComputingSpaceUsedForOrigin(const ClientOrigin& origin, uint64_t spaceUsed) 812 812 { 813 quotaUser(origin).initializeSpaceUsed(spaceUsed);813 ensureQuotaUser(origin).initializeSpaceUsed(spaceUsed); 814 814 } 815 815 816 816 void IDBServer::requestSpace(const ClientOrigin& origin, uint64_t taskSize, CompletionHandler<void(StorageQuotaManager::Decision)>&& callback) 817 817 { 818 auto* quotaManager = quotaUser(origin).manager();818 auto* quotaManager = ensureQuotaUser(origin).manager(); 819 819 if (!quotaManager) { 820 820 callback(StorageQuotaManager::Decision::Deny); … … 833 833 void IDBServer::setSpaceUsed(const ClientOrigin& origin, uint64_t taskSize) 834 834 { 835 quotaUser(origin).setSpaceUsed(taskSize);835 ensureQuotaUser(origin).setSpaceUsed(taskSize); 836 836 } 837 837 838 838 void IDBServer::increasePotentialSpaceUsed(const ClientOrigin& origin, uint64_t taskSize) 839 839 { 840 quotaUser(origin).increasePotentialSpaceUsed(taskSize);840 ensureQuotaUser(origin).increasePotentialSpaceUsed(taskSize); 841 841 } 842 842 843 843 void IDBServer::decreasePotentialSpaceUsed(const ClientOrigin& origin, uint64_t spaceUsed) 844 844 { 845 quotaUser(origin).decreasePotentialSpaceUsed(spaceUsed);845 ensureQuotaUser(origin).decreasePotentialSpaceUsed(spaceUsed); 846 846 } 847 847 -
trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h
r243019 r243339 126 126 void resetSpaceUsed(const ClientOrigin&); 127 127 128 void initializeQuotaUser(const ClientOrigin& origin) { ensureQuotaUser(origin); } 129 128 130 private: 129 131 IDBServer(PAL::SessionID, IDBBackingStoreTemporaryFileHandler&, QuotaManagerGetter&&, WTF::Function<void(bool)>&&); … … 176 178 }; 177 179 178 QuotaUser& quotaUser(const ClientOrigin&);180 WEBCORE_EXPORT QuotaUser& ensureQuotaUser(const ClientOrigin&); 179 181 void startComputingSpaceUsedForOrigin(const ClientOrigin&); 180 182 void computeSpaceUsedForOrigin(const ClientOrigin&); -
trunk/Source/WebCore/storage/StorageQuotaManager.cpp
r243276 r243339 70 70 71 71 updateQuotaBasedOnSpaceUsage(); 72 processPendingRequests({ } );72 processPendingRequests({ }, ShouldDequeueFirstPendingRequest::No); 73 73 }); 74 74 } … … 80 80 81 81 return spaceUsage() + spaceIncrease > m_quota; 82 } 83 84 void StorageQuotaManager::removeUser(StorageQuotaUser& user) 85 { 86 ASSERT(m_users.contains(&user) || m_pendingInitializationUsers.contains(&user)); 87 m_users.remove(&user); 88 if (m_pendingInitializationUsers.remove(&user) && m_pendingInitializationUsers.isEmpty()) 89 processPendingRequests({ }, ShouldDequeueFirstPendingRequest::No); 82 90 } 83 91 … … 100 108 { 101 109 ASSERT(shouldAskForMoreSpace(spaceIncrease)); 110 ASSERT(!m_isWaitingForSpaceIncreaseResponse); 111 m_isWaitingForSpaceIncreaseResponse = true; 102 112 m_spaceIncreaseRequester(m_quota, spaceUsage(), spaceIncrease, [this, weakThis = makeWeakPtr(*this)](Optional<uint64_t> newQuota) { 103 113 if (!weakThis) 104 114 return; 105 processPendingRequests(newQuota); 115 m_isWaitingForSpaceIncreaseResponse = false; 116 processPendingRequests(newQuota, ShouldDequeueFirstPendingRequest::Yes); 106 117 }); 107 118 } 108 119 109 void StorageQuotaManager::processPendingRequests(Optional<uint64_t> newQuota )120 void StorageQuotaManager::processPendingRequests(Optional<uint64_t> newQuota, ShouldDequeueFirstPendingRequest shouldDequeueFirstPendingRequest) 110 121 { 111 122 if (m_pendingRequests.isEmpty()) … … 115 126 m_quota = *newQuota; 116 127 117 auto request = m_pendingRequests.takeFirst(); 118 auto decision = shouldAskForMoreSpace(request.spaceIncrease) ? Decision::Deny : Decision::Grant; 119 request.callback(decision); 128 if (m_isWaitingForSpaceIncreaseResponse) 129 return; 130 131 if (!m_pendingInitializationUsers.isEmpty()) 132 return; 133 134 if (shouldDequeueFirstPendingRequest == ShouldDequeueFirstPendingRequest::Yes) { 135 auto request = m_pendingRequests.takeFirst(); 136 auto decision = shouldAskForMoreSpace(request.spaceIncrease) ? Decision::Deny : Decision::Grant; 137 request.callback(decision); 138 } 120 139 121 140 while (!m_pendingRequests.isEmpty()) { -
trunk/Source/WebCore/storage/StorageQuotaManager.h
r243276 r243339 51 51 52 52 WEBCORE_EXPORT void addUser(StorageQuotaUser&); 53 void removeUser(StorageQuotaUser& user) 54 { 55 ASSERT(m_users.contains(&user) || m_pendingInitializationUsers.contains(&user)); 56 m_pendingInitializationUsers.remove(&user); 57 m_users.remove(&user); 58 } 53 WEBCORE_EXPORT void removeUser(StorageQuotaUser&); 59 54 60 55 enum class Decision { Deny, Grant }; … … 69 64 bool shouldAskForMoreSpace(uint64_t spaceIncrease) const; 70 65 void askForMoreSpace(uint64_t spaceIncrease); 71 void processPendingRequests(Optional<uint64_t>); 66 67 enum class ShouldDequeueFirstPendingRequest { No, Yes }; 68 void processPendingRequests(Optional<uint64_t>, ShouldDequeueFirstPendingRequest); 72 69 73 70 uint64_t m_quota { 0 }; 71 72 bool m_isWaitingForSpaceIncreaseResponse { false }; 74 73 SpaceIncreaseRequester m_spaceIncreaseRequester; 75 74 HashSet<const StorageQuotaUser*> m_pendingInitializationUsers; -
trunk/Source/WebKit/ChangeLog
r243329 r243339 1 2019-03-21 Youenn Fablet <youenn@apple.com> 2 3 Cache API and IDB space usages should be initialized on first quota check 4 https://bugs.webkit.org/show_bug.cgi?id=195707 5 6 Reviewed by Chris Dumez. 7 8 When the quota manager is created, make sure it delays quota check decisions until IDB and Cache API quota users are initialized. 9 For IDB, the creation is synchronous but it may not be synchronous for Cache API. 10 For that purpose, add a temporary quota user that will stay uninitialized until these two quota users are added. 11 Once added, the temporary quota user is removed. 12 The addition of the real users is made asynchronously as this is triggered by the creation of one of the two quota users. 13 14 In the case of a Cache API caches being cleared, make sure to reset the size to zero and to redo the quota user initialization dance. 15 16 * NetworkProcess/NetworkProcess.cpp: 17 (WebKit::QuotaUserInitializer::initialize): 18 (WebKit::QuotaUserInitializer::~QuotaUserInitializer): 19 (WebKit::QuotaUserInitializer::QuotaUserInitializer): 20 (WebKit::NetworkProcess::storageQuotaManager): 21 * NetworkProcess/cache/CacheStorageEngine.cpp: 22 (WebKit::CacheStorage::Engine::initializeQuotaUser): 23 * NetworkProcess/cache/CacheStorageEngine.h: 24 * NetworkProcess/cache/CacheStorageEngineCaches.cpp: 25 (WebKit::CacheStorage::Caches::clear): 26 1 27 2019-03-21 Per Arne Vollan <pvollan@apple.com> 2 28 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r243276 r243339 2395 2395 } 2396 2396 2397 class QuotaUserInitializer final : public WebCore::StorageQuotaUser { 2398 public: 2399 explicit QuotaUserInitializer(StorageQuotaManager& manager) 2400 : m_manager(makeWeakPtr(manager)) 2401 { 2402 manager.addUser(*this); 2403 } 2404 2405 ~QuotaUserInitializer() 2406 { 2407 if (m_manager) 2408 m_manager->removeUser(*this); 2409 if (m_callback) 2410 m_callback(); 2411 } 2412 2413 private: 2414 // StorageQuotaUser API. 2415 uint64_t spaceUsed() const final 2416 { 2417 ASSERT_NOT_REACHED(); 2418 return 0; 2419 } 2420 2421 void whenInitialized(CompletionHandler<void()>&& callback) final 2422 { 2423 m_callback = WTFMove(callback); 2424 } 2425 2426 WeakPtr<StorageQuotaManager> m_manager; 2427 CompletionHandler<void()> m_callback; 2428 }; 2429 2430 void NetworkProcess::initializeQuotaUsers(StorageQuotaManager& manager, PAL::SessionID sessionID, const ClientOrigin& origin) 2431 { 2432 RunLoop::main().dispatch([this, weakThis = makeWeakPtr(this), sessionID, origin, user = std::make_unique<QuotaUserInitializer>(manager)]() mutable { 2433 if (!weakThis) 2434 return; 2435 this->idbServer(sessionID).initializeQuotaUser(origin); 2436 CacheStorage::Engine::initializeQuotaUser(*this, sessionID, origin, [user = WTFMove(user)] { }); 2437 }); 2438 } 2439 2397 2440 StorageQuotaManager& NetworkProcess::storageQuotaManager(PAL::SessionID sessionID, const ClientOrigin& origin) 2398 2441 { … … 2402 2445 return *storageQuotaManagers.managersPerOrigin.ensure(origin, [this, &storageQuotaManagers, sessionID, &origin] { 2403 2446 auto quota = origin.topOrigin == origin.clientOrigin ? storageQuotaManagers.defaultQuota : storageQuotaManagers.defaultThirdPartyQuota; 2404 returnstd::make_unique<StorageQuotaManager>(quota, [this, sessionID, origin](uint64_t quota, uint64_t currentSpace, uint64_t spaceIncrease, auto callback) {2447 auto manager = std::make_unique<StorageQuotaManager>(quota, [this, sessionID, origin](uint64_t quota, uint64_t currentSpace, uint64_t spaceIncrease, auto callback) { 2405 2448 this->requestStorageSpace(sessionID, origin, quota, currentSpace, spaceIncrease, WTFMove(callback)); 2406 2449 }); 2450 initializeQuotaUsers(*manager, sessionID, origin); 2451 return manager; 2407 2452 }).iterator->value; 2408 2453 } -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r243276 r243339 384 384 385 385 void setCacheStorageParameters(PAL::SessionID, uint64_t quota, String&& cacheStorageDirectory, SandboxExtension::Handle&&); 386 void initializeQuotaUsers(WebCore::StorageQuotaManager&, PAL::SessionID, const WebCore::ClientOrigin&); 386 387 387 388 // FIXME: This should take a session ID so we can identify which disk cache to delete. -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
r242599 r243339 186 186 } 187 187 188 void Engine::initializeQuotaUser(NetworkProcess& networkProcess, PAL::SessionID sessionID, const WebCore::ClientOrigin& clientOrigin, CompletionHandler<void()>&& completionHandler) 189 { 190 from(networkProcess, sessionID, [clientOrigin, completionHandler = WTFMove(completionHandler)](auto& engine) mutable { 191 engine.readCachesFromDisk(clientOrigin, [completionHandler = WTFMove(completionHandler)](auto&& cachesOrError) mutable { 192 completionHandler(); 193 }); 194 }); 195 } 196 188 197 Engine::Engine(PAL::SessionID sessionID, NetworkProcess& process, String&& rootPath) 189 198 : m_sessionID(sessionID) -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h
r242599 r243339 81 81 static void clearCachesForOrigin(NetworkProcess&, PAL::SessionID, WebCore::SecurityOriginData&&, CompletionHandler<void()>&&); 82 82 83 static void initializeQuotaUser(NetworkProcess&, PAL::SessionID, const WebCore::ClientOrigin&, CompletionHandler<void()>&&); 84 83 85 bool shouldPersist() const { return !!m_ioQueue;} 84 86 -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp
r243276 r243339 261 261 ASSERT(RunLoop::isMain()); 262 262 protectedThis->clearMemoryRepresentation(); 263 protectedThis->resetSpaceUsed(); 263 264 completionHandler(); 264 265 }); … … 266 267 } 267 268 clearMemoryRepresentation(); 269 resetSpaceUsed(); 268 270 clearPendingWritingCachesToDiskCallbacks(); 269 271 completionHandler(); … … 602 604 } 603 605 606 void Caches::resetSpaceUsed() 607 { 608 m_size = 0; 609 if (m_quotaManager) { 610 m_quotaManager->removeUser(*this); 611 m_quotaManager->addUser(*this); 612 } 613 } 614 604 615 void Caches::clearMemoryRepresentation() 605 616 { -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h
r243276 r243339 79 79 void clear(WTF::CompletionHandler<void()>&&); 80 80 void clearMemoryRepresentation(); 81 void resetSpaceUsed(); 81 82 82 83 uint64_t storageSize() const;
Note:
See TracChangeset
for help on using the changeset viewer.