Clearing all Website Data should remove service worker registrations on disk
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2017 23:13:49 +0000 (23:13 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2017 23:13:49 +0000 (23:13 +0000)
commit13015e225bf1fdb778b5b51d24636510d30ec871
tree4800fc7cdec2b94ec871ca1124fb471c6713d9a4
parentaf414fde421f8e78eb4535cbbe249b256ecaffda
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
12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp
Source/WebCore/workers/service/ServiceWorkerRegistrationKey.h
Source/WebCore/workers/service/server/RegistrationDatabase.cpp
Source/WebCore/workers/service/server/RegistrationDatabase.h
Source/WebCore/workers/service/server/RegistrationStore.cpp
Source/WebCore/workers/service/server/RegistrationStore.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebCore/workers/service/server/SWServerWorker.cpp
Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/StorageProcess.cpp