Clearing all Website Data should remove service worker registrations on disk
https://bugs.webkit.org/show_bug.cgi?id=180558
Reviewed by Youenn Fablet.
Source/WebCore:
Clear service worker registrations on disk in addition to the ones in memory.
* workers/service/server/RegistrationDatabase.cpp:
(WebCore::v1RecordsTableSchema):
(WebCore::v1RecordsTableSchemaAlternate):
(WebCore::databaseFilename):
Make sure these always get called from the background thread since they use
a static string.
(WebCore::RegistrationDatabase::RegistrationDatabase):
Call importRecordsIfNecessary() instead of openSQLiteDatabase(). importRecordsIfNecessary()
only calls openSQLiteDatabase() if the database file exists, to avoid creating a database
file unnecessarily.
(WebCore::RegistrationDatabase::databasePath const):
New method which returns the database file path.
(WebCore::RegistrationDatabase::openSQLiteDatabase):
(WebCore::RegistrationDatabase::importRecordsIfNecessary):
New methods which imports records if the database file exist. It the database file does
not exist, it does not create it.
(WebCore::RegistrationDatabase::pushChanges):
Call completion handler when changes are pushed.
(WebCore::RegistrationDatabase::clearAll):
Close the database if it is open, then remove the database files.
(WebCore::RegistrationDatabase::doPushChanges):
If the database is not already open, we now open it when trying to write changes for
the first time.
* workers/service/server/RegistrationDatabase.h:
* workers/service/server/RegistrationStore.cpp:
(WebCore::RegistrationStore::clearAll):
(WebCore::RegistrationStore::flushChanges):
* workers/service/server/RegistrationStore.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::clearAll):
(WebCore::SWServer::clear):
Also clear the database.
* workers/service/server/SWServer.h:
* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::terminate):
Only call SWServer::terminateWorker() if the worker is running. Otherwise, we hit
an assertion when clearing a registration would worker was already terminated.
Source/WebKit:
* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::deleteWebsiteData):
(WebKit::StorageProcess::deleteWebsiteDataForOrigins):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225711
268f45cc-cd09-0410-ab3c-
d52691b4dbfc