Delay some service worker operations until after the database import completes.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Dec 2017 03:03:06 +0000 (03:03 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Dec 2017 03:03:06 +0000 (03:03 +0000)
commit453bfc1b4be149a8e6386fe584bed73831c8bf2a
treea4963e0f787b862d55f473b4dd15614ff8f619b9
parentdb9f146868ec979187c155f96ee16a1f3ff335ab
Delay some service worker operations until after the database import completes.
https://bugs.webkit.org/show_bug.cgi?id=180573

Reviewed by Chris Dumez.

Source/WebCore:

No new tests (Not testable yet).

Right after the storage process launches it starts importing registration records.
During this time, a lot of the decisions we make regarding registrations, fetch, etc.
are invalid, as they rely on those in-memory records being in place.

This patch delays certain things until after the initial origin table import is complete.

* workers/service/server/RegistrationStore.cpp:
(WebCore::RegistrationStore::databaseOpenedAndRecordsImported):

* workers/service/server/SWOriginStore.h:

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::registrationStoreImportComplete): Tell the origin store the initial
  import was completed.
(WebCore::SWServer::addRegistrationFromStore):
* workers/service/server/SWServer.h:

Source/WebKit:

* StorageProcess/ServiceWorker/WebSWOriginStore.cpp:
(WebKit::WebSWOriginStore::importComplete): Tell the Origin Table on all connects that
  the import is complete.
(WebKit::WebSWOriginStore::registerSWServerConnection):
* StorageProcess/ServiceWorker/WebSWOriginStore.h:

* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::mayHaveServiceWorkerRegisteredForOrigin const):
(WebKit::WebSWClientConnection::setSWOriginTableIsImported): Run deferred tasks!
(WebKit::WebSWClientConnection::matchRegistration): If the import isn't complete yet, delay
  the match registration task until later.
(WebKit::WebSWClientConnection::runOrDelayTask): Either send the message now or save off
  the task to wait until the import is complete.
(WebKit::WebSWClientConnection::getRegistrations): If the import isn't complete yet, delay
  the get registrations task until later.
(WebKit::WebSWClientConnection::initializeSWOriginTableAsEmpty): Deleted.
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebSWClientConnection.messages.in:

* WebProcess/Storage/WebSWOriginTable.cpp:
(WebKit::WebSWOriginTable::setSharedMemory):
* WebProcess/Storage/WebSWOriginTable.h:
(WebKit::WebSWOriginTable::isImported const):
(WebKit::WebSWOriginTable::setIsImported):
(WebKit::WebSWOriginTable::isInitialized const): Deleted.
(WebKit::WebSWOriginTable::initializeAsEmpty): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225717 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/workers/service/server/RegistrationStore.cpp
Source/WebCore/workers/service/server/SWOriginStore.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/ServiceWorker/WebSWOriginStore.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWOriginStore.h
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in
Source/WebKit/WebProcess/Storage/WebSWOriginTable.cpp
Source/WebKit/WebProcess/Storage/WebSWOriginTable.h