Title: [225283] trunk/Source/WebCore
- Revision
- 225283
- Author
- cdu...@apple.com
- Date
- 2017-11-29 11:41:22 -0800 (Wed, 29 Nov 2017)
Log Message
Introduce ServiceWorkerContainer::ensureSWClientConnection()
https://bugs.webkit.org/show_bug.cgi?id=180146
Reviewed by Youenn Fablet.
Introduce ServiceWorkerContainer::ensureSWClientConnection() to reduce
code duplication. Also use callOnMainThread() in preparation for this
getting called from a service worker thread (now that ServiceWorkerContainer
is exposed to service workers). This is needed because constructing the
SWClientConnection initializes the IPC connection from the WebProcess to
the StorageProcess, which involves a synchronous IPC with the UIProcess.
Doing a synchronous IPC from a background thread is unsupported.
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::addRegistration):
(WebCore::ServiceWorkerContainer::getRegistration):
(WebCore::ServiceWorkerContainer::getRegistrations):
(WebCore::ServiceWorkerContainer::ensureSWClientConnection):
* workers/service/ServiceWorkerContainer.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (225282 => 225283)
--- trunk/Source/WebCore/ChangeLog 2017-11-29 19:40:12 UTC (rev 225282)
+++ trunk/Source/WebCore/ChangeLog 2017-11-29 19:41:22 UTC (rev 225283)
@@ -1,3 +1,25 @@
+2017-11-29 Chris Dumez <cdu...@apple.com>
+
+ Introduce ServiceWorkerContainer::ensureSWClientConnection()
+ https://bugs.webkit.org/show_bug.cgi?id=180146
+
+ Reviewed by Youenn Fablet.
+
+ Introduce ServiceWorkerContainer::ensureSWClientConnection() to reduce
+ code duplication. Also use callOnMainThread() in preparation for this
+ getting called from a service worker thread (now that ServiceWorkerContainer
+ is exposed to service workers). This is needed because constructing the
+ SWClientConnection initializes the IPC connection from the WebProcess to
+ the StorageProcess, which involves a synchronous IPC with the UIProcess.
+ Doing a synchronous IPC from a background thread is unsupported.
+
+ * workers/service/ServiceWorkerContainer.cpp:
+ (WebCore::ServiceWorkerContainer::addRegistration):
+ (WebCore::ServiceWorkerContainer::getRegistration):
+ (WebCore::ServiceWorkerContainer::getRegistrations):
+ (WebCore::ServiceWorkerContainer::ensureSWClientConnection):
+ * workers/service/ServiceWorkerContainer.h:
+
2017-11-29 Antoine Quint <grao...@apple.com>
[iOS] Media controls should stop updating while media is playing in fullscreen
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (225282 => 225283)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-11-29 19:40:12 UTC (rev 225282)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-11-29 19:41:22 UTC (rev 225283)
@@ -102,11 +102,8 @@
return;
}
- if (!m_swConnection)
- m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(scriptExecutionContext()->sessionID());
+ ServiceWorkerJobData jobData(ensureSWClientConnection().serverConnectionIdentifier());
- ServiceWorkerJobData jobData(m_swConnection->serverConnectionIdentifier());
-
jobData.scriptURL = context->completeURL(relativeScriptURL);
if (!jobData.scriptURL.isValid()) {
promise->reject(Exception { TypeError, ASCIILiteral("serviceWorker.register() must be called with a valid relative script URL") });
@@ -231,10 +228,7 @@
return;
}
- if (!m_swConnection)
- m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context->sessionID());
-
- return m_swConnection->matchRegistration(context->topOrigin(), parsedURL, [promise = WTFMove(promise), protectingThis = makePendingActivity(*this), this] (auto&& result) mutable {
+ return ensureSWClientConnection().matchRegistration(context->topOrigin(), parsedURL, [promise = WTFMove(promise), protectingThis = makePendingActivity(*this), this] (auto&& result) mutable {
if (m_isStopped)
return;
@@ -278,10 +272,7 @@
return;
}
- if (!m_swConnection)
- m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context->sessionID());
-
- return m_swConnection->getRegistrations(context->topOrigin(), context->url(), [this, pendingActivity = makePendingActivity(*this), promise = WTFMove(promise)] (auto&& registrationDatas) mutable {
+ return ensureSWClientConnection().getRegistrations(context->topOrigin(), context->url(), [this, pendingActivity = makePendingActivity(*this), promise = WTFMove(promise)] (auto&& registrationDatas) mutable {
if (m_isStopped)
return;
@@ -418,6 +409,17 @@
return !hasPendingActivity();
}
+SWClientConnection& ServiceWorkerContainer::ensureSWClientConnection()
+{
+ if (!m_swConnection) {
+ ASSERT(scriptExecutionContext());
+ callOnMainThreadAndWait([this, sessionID = scriptExecutionContext()->sessionID()]() {
+ m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(sessionID);
+ });
+ }
+ return *m_swConnection;
+}
+
void ServiceWorkerContainer::addRegistration(ServiceWorkerRegistration& registration)
{
m_swConnection->addServiceWorkerRegistrationInServer(registration.identifier());
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (225282 => 225283)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2017-11-29 19:40:12 UTC (rev 225282)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2017-11-29 19:41:22 UTC (rev 225283)
@@ -97,6 +97,7 @@
void jobDidFinish(ServiceWorkerJob&);
SWServerConnectionIdentifier connectionIdentifier() final;
+ SWClientConnection& ensureSWClientConnection();
const char* activeDOMObjectName() const final;
bool canSuspendForDocumentSuspension() const final;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes