Changeset 239358 in webkit
- Timestamp:
- Dec 18, 2018 3:56:23 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r239357 r239358 1 2018-12-18 Sihui Liu <sihui_liu@apple.com> 2 3 Clean up IndexedDB files between tests 4 https://bugs.webkit.org/show_bug.cgi?id=192796 5 6 Reviewed by Geoffrey Garen. 7 8 We should clean up the IndexedDB files between tests to make sure each test is independent of others. 9 10 This patch also fixes some issues in IDB. 11 12 Covered by existing tests. 13 14 * Modules/indexeddb/server/IDBServer.cpp: 15 (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesModifiedSince): 16 We should shut down all open databases instead of databases from open database connections before deleting 17 files, because database starts accessing files before connection to database is established. 18 19 * Modules/indexeddb/server/UniqueIDBDatabase.cpp: 20 (WebCore::IDBServer::UniqueIDBDatabase::shutdownForClose): 21 We should shutdown database after tasks in queue are completed, because tasks have pointer of UniqueIDBDatabase 22 and UniqueIDBDatabase can be destructed after shutdown. 23 24 (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): 25 didDeleteBackingStore can be posted to main thread after immediateCloseForUserDelete, and timer should not be 26 invoked during the hard close. 27 28 (WebCore::IDBServer::UniqueIDBDatabase::handleDatabaseOperations): 29 Tasks like didOpenBackingStore could be posted from database thread to main thread after 30 immediateCloseForUserDelete, but we know the backing store will be deleted soon, so no need to handle any 31 database operation. 32 33 (WebCore::IDBServer::UniqueIDBDatabase::performPrefetchCursor): 34 performPrefetchCursor needs to be aware of whether UniqueIDBDatabase is being closed, so that it will not access 35 m_backingStore when m_backingStore may already be deleted. 36 37 (WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete): 38 immediateCloseForUserDelete does not handle transactions that are in the process of commit or abort. 39 m_objectStoreTransactionCounts and m_objectStoreWriteTransactions may be used by those transactions in 40 transactionCompleted, so they do not need to be cleared here. 41 1 42 2018-12-18 Myles C. Maxfield <mmaxfield@apple.com> 2 43 -
trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp
r237700 r239358 510 510 511 511 HashSet<UniqueIDBDatabase*> openDatabases; 512 for (auto * connection : m_databaseConnections.values())513 openDatabases.add( connection->database());512 for (auto& database : m_uniqueIDBDatabaseMap.values()) 513 openDatabases.add(database.get()); 514 514 515 515 for (auto& database : openDatabases) -
trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
r239266 r239358 295 295 m_backingStoreIsEphemeral = false; 296 296 297 ASSERT(m_databaseQueue.isEmpty()); 297 if (!m_databaseQueue.isEmpty()) { 298 postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::shutdownForClose)); 299 return; 300 } 298 301 m_databaseQueue.kill(); 299 302 … … 337 340 338 341 m_deleteBackingStoreInProgress = false; 339 invokeOperationAndTransactionTimer(); 342 343 if (!m_hardClosedForUserDelete) 344 invokeOperationAndTransactionTimer(); 340 345 } 341 346 … … 344 349 ASSERT(isMainThread()); 345 350 LOG(IndexedDB, "(main) UniqueIDBDatabase::handleDatabaseOperations - There are %u pending", m_pendingOpenDBRequests.size()); 346 ASSERT(!m_hardClosedForUserDelete); 351 352 if (m_hardClosedForUserDelete) 353 return; 347 354 348 355 if (m_deleteBackingStoreInProgress) … … 1279 1286 LOG(IndexedDB, "(db) UniqueIDBDatabase::performPrefetchCursor"); 1280 1287 1288 if (m_owningPointerForClose) 1289 return; 1290 1281 1291 if (m_backingStore->prefetchCursor(transactionIdentifier, cursorIdentifier)) 1282 1292 postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performPrefetchCursor, transactionIdentifier, cursorIdentifier)); … … 1819 1829 transaction->databaseConnection().deleteTransaction(*transaction); 1820 1830 m_pendingTransactions.clear(); 1821 m_objectStoreTransactionCounts.clear();1822 m_objectStoreWriteTransactions.clear();1823 1831 1824 1832 // Error out all pending callbacks -
trunk/Source/WebKit/ChangeLog
r239348 r239358 1 2018-12-18 Sihui Liu <sihui_liu@apple.com> 2 3 Clean up IndexedDB files between tests 4 https://bugs.webkit.org/show_bug.cgi?id=192796 5 6 Reviewed by Geoffrey Garen. 7 8 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 9 (WKWebsiteDataStoreRemoveAllIndexedDatabasesSync): 10 * UIProcess/API/C/WKWebsiteDataStoreRef.h: 11 1 12 2018-12-18 Vivek Seth <v_seth@apple.com> 2 13 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r238771 r239358 512 512 } 513 513 514 void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef )514 void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllIndexedDatabasesCallback callback) 515 515 { 516 516 OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::IndexedDBDatabases; 517 WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, -WallTime::infinity(), [] { }); 517 WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, -WallTime::infinity(), [context, callback] { 518 if (callback) 519 callback(context); 520 }); 518 521 } 519 522 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r238125 r239358 104 104 WK_EXPORT void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback callback); 105 105 106 WK_EXPORT void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef); 106 typedef void (*WKWebsiteDataStoreRemoveAllIndexedDatabasesCallback)(void* functionContext); 107 WK_EXPORT void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllIndexedDatabasesCallback callback); 107 108 108 109 typedef void (*WKWebsiteDataStoreGetFetchCacheOriginsFunction)(WKArrayRef, void*); -
trunk/Tools/ChangeLog
r239356 r239358 1 2018-12-18 Sihui Liu <sihui_liu@apple.com> 2 3 Clean up IndexedDB files between tests 4 https://bugs.webkit.org/show_bug.cgi?id=192796 5 6 Reviewed by Geoffrey Garen. 7 8 * DumpRenderTree/mac/DumpRenderTree.mm: 9 (runTest): 10 * WebKitTestRunner/TestController.cpp: 11 (WTR::TestController::resetStateToConsistentValues): 12 (WTR::RemoveAllIndexedDatabasesCallbackContext::RemoveAllIndexedDatabasesCallbackContext): 13 (WTR::RemoveAllIndexedDatabasesCallback): 14 (WTR::TestController::ClearIndexedDatabases): 15 * WebKitTestRunner/TestController.h: 16 1 17 2018-12-18 Alex Christensen <achristensen@webkit.org> 2 18 -
trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm
r238262 r239358 2013 2013 gTestRunner->setIconDatabaseEnabled(false); 2014 2014 gTestRunner->clearAllApplicationCaches(); 2015 gTestRunner->clearAllDatabases(); 2016 gTestRunner->setIDBPerOriginQuota(50 * MB); 2015 2017 2016 2018 if (disallowedURLs) -
trunk/Tools/WebKitTestRunner/TestController.cpp
r239277 r239358 868 868 WKContextClearCachedCredentials(TestController::singleton().context()); 869 869 870 ClearIndexedDatabases(); 871 setIDBPerOriginQuota(50 * MB); 872 870 873 clearServiceWorkerRegistrations(); 871 874 clearDOMCaches(); … … 2760 2763 } 2761 2764 2765 struct RemoveAllIndexedDatabasesCallbackContext { 2766 explicit RemoveAllIndexedDatabasesCallbackContext(TestController& controller) 2767 : testController(controller) 2768 { 2769 } 2770 TestController& testController; 2771 bool done { false }; 2772 }; 2773 static void RemoveAllIndexedDatabasesCallback(void* userData) 2774 { 2775 auto* context = static_cast<RemoveAllIndexedDatabasesCallbackContext*>(userData); 2776 context->done = true; 2777 context->testController.notifyDone(); 2778 } 2779 void TestController::ClearIndexedDatabases() 2780 { 2781 auto websiteDataStore = WKContextGetWebsiteDataStore(platformContext()); 2782 RemoveAllIndexedDatabasesCallbackContext context(*this); 2783 WKWebsiteDataStoreRemoveAllIndexedDatabases(websiteDataStore, &context, RemoveAllIndexedDatabasesCallback); 2784 runUntil(context.done, noTimeout); 2785 } 2786 2762 2787 struct FetchCacheOriginsCallbackContext { 2763 2788 FetchCacheOriginsCallbackContext(TestController& controller, WKStringRef origin) -
trunk/Tools/WebKitTestRunner/TestController.h
r238939 r239358 243 243 void removeAllSessionCredentials(); 244 244 245 void ClearIndexedDatabases(); 246 245 247 void clearServiceWorkerRegistrations(); 246 248 -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r238512 r239358 904 904 905 905 if (WKStringIsEqualToUTF8CString(messageName, "DeleteAllIndexedDatabases")) { 906 WKWebsiteDataStoreRemoveAllIndexedDatabases(WKContextGetWebsiteDataStore(TestController::singleton().context()) );906 WKWebsiteDataStoreRemoveAllIndexedDatabases(WKContextGetWebsiteDataStore(TestController::singleton().context()), nullptr, { }); 907 907 return nullptr; 908 908 }
Note: See TracChangeset
for help on using the changeset viewer.