Diff
Modified: trunk/Source/WebCore/ChangeLog (225297 => 225298)
--- trunk/Source/WebCore/ChangeLog 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebCore/ChangeLog 2017-11-29 23:16:03 UTC (rev 225298)
@@ -1,3 +1,38 @@
+2017-11-29 Brady Eidson <beid...@apple.com>
+
+ When managing context startups, make ServiceWorkerJobDataIdentifier's optional.
+ https://bugs.webkit.org/show_bug.cgi?id=180166
+
+ Reviewed by Chris Dumez.
+
+ No new tests (No behavior change).
+
+ We'll sometimes be starting SW contexts without an associated job, so ServiceWorkerContextData
+ should not required actually having a job identifier.
+
+ * workers/service/ServiceWorkerContextData.h:
+ (WebCore::ServiceWorkerContextData::decode):
+
+ * workers/service/context/SWContextManager.h:
+
+ * workers/service/server/SWServer.cpp:
+ (WebCore::SWServer::scriptContextFailedToStart):
+ (WebCore::SWServer::scriptContextStarted):
+ (WebCore::SWServer::didFinishInstall):
+ * workers/service/server/SWServer.h:
+
+ * workers/service/server/SWServerToContextConnection.cpp:
+ (WebCore::SWServerToContextConnection::scriptContextFailedToStart):
+ (WebCore::SWServerToContextConnection::scriptContextStarted):
+ (WebCore::SWServerToContextConnection::didFinishInstall):
+ * workers/service/server/SWServerToContextConnection.h:
+
+ * workers/service/server/SWServerWorker.cpp:
+ (WebCore::SWServerWorker::scriptContextFailedToStart):
+ (WebCore::SWServerWorker::scriptContextStarted):
+ (WebCore::SWServerWorker::didFinishInstall):
+ * workers/service/server/SWServerWorker.h:
+
2017-11-29 Youenn Fablet <you...@apple.com>
Add support for service worker generated redirections
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h (225297 => 225298)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h 2017-11-29 23:16:03 UTC (rev 225298)
@@ -36,7 +36,7 @@
namespace WebCore {
struct ServiceWorkerContextData {
- ServiceWorkerJobDataIdentifier jobDataIdentifier;
+ std::optional<ServiceWorkerJobDataIdentifier> jobDataIdentifier;
ServiceWorkerRegistrationData registration;
ServiceWorkerIdentifier serviceWorkerIdentifier;
String script;
@@ -58,7 +58,7 @@
template<class Decoder>
std::optional<ServiceWorkerContextData> ServiceWorkerContextData::decode(Decoder& decoder)
{
- std::optional<ServiceWorkerJobDataIdentifier> jobDataIdentifier;
+ std::optional<std::optional<ServiceWorkerJobDataIdentifier>> jobDataIdentifier;
decoder >> jobDataIdentifier;
if (!jobDataIdentifier)
return std::nullopt;
Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.h (225297 => 225298)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-11-29 23:16:03 UTC (rev 225298)
@@ -46,8 +46,8 @@
virtual ~Connection() { }
virtual void postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier source, const String& sourceOrigin) = 0;
- virtual void serviceWorkerStartedWithMessage(const ServiceWorkerJobDataIdentifier&, ServiceWorkerIdentifier, const String& exceptionMessage) = 0;
- virtual void didFinishInstall(const ServiceWorkerJobDataIdentifier&, ServiceWorkerIdentifier, bool wasSuccessful) = 0;
+ virtual void serviceWorkerStartedWithMessage(std::optional<ServiceWorkerJobDataIdentifier>, ServiceWorkerIdentifier, const String& exceptionMessage) = 0;
+ virtual void didFinishInstall(std::optional<ServiceWorkerJobDataIdentifier>, ServiceWorkerIdentifier, bool wasSuccessful) = 0;
virtual void didFinishActivation(ServiceWorkerIdentifier) = 0;
virtual void setServiceWorkerHasPendingEvents(ServiceWorkerIdentifier, bool) = 0;
virtual void workerTerminated(ServiceWorkerIdentifier) = 0;
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (225297 => 225298)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-11-29 23:16:03 UTC (rev 225298)
@@ -266,22 +266,31 @@
jobQueue->scriptFetchFinished(connection, result);
}
-void SWServer::scriptContextFailedToStart(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, SWServerWorker& worker, const String& message)
+void SWServer::scriptContextFailedToStart(const std::optional<ServiceWorkerJobDataIdentifier>& jobDataIdentifier, SWServerWorker& worker, const String& message)
{
+ if (!jobDataIdentifier)
+ return;
+
if (auto* jobQueue = m_jobQueues.get(worker.registrationKey()))
- jobQueue->scriptContextFailedToStart(jobDataIdentifier, worker.identifier(), message);
+ jobQueue->scriptContextFailedToStart(*jobDataIdentifier, worker.identifier(), message);
}
-void SWServer::scriptContextStarted(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, SWServerWorker& worker)
+void SWServer::scriptContextStarted(const std::optional<ServiceWorkerJobDataIdentifier>& jobDataIdentifier, SWServerWorker& worker)
{
+ if (!jobDataIdentifier)
+ return;
+
if (auto* jobQueue = m_jobQueues.get(worker.registrationKey()))
- jobQueue->scriptContextStarted(jobDataIdentifier, worker.identifier());
+ jobQueue->scriptContextStarted(*jobDataIdentifier, worker.identifier());
}
-void SWServer::didFinishInstall(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, SWServerWorker& worker, bool wasSuccessful)
+void SWServer::didFinishInstall(const std::optional<ServiceWorkerJobDataIdentifier>& jobDataIdentifier, SWServerWorker& worker, bool wasSuccessful)
{
+ if (!jobDataIdentifier)
+ return;
+
if (auto* jobQueue = m_jobQueues.get(worker.registrationKey()))
- jobQueue->didFinishInstall(jobDataIdentifier, worker.identifier(), wasSuccessful);
+ jobQueue->didFinishInstall(*jobDataIdentifier, worker.identifier(), wasSuccessful);
}
void SWServer::didFinishActivation(SWServerWorker& worker)
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (225297 => 225298)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2017-11-29 23:16:03 UTC (rev 225298)
@@ -130,9 +130,9 @@
Connection* getConnection(SWServerConnectionIdentifier identifier) { return m_connections.get(identifier); }
SWOriginStore& originStore() { return m_originStore; }
- void scriptContextFailedToStart(const ServiceWorkerJobDataIdentifier&, SWServerWorker&, const String& message);
- void scriptContextStarted(const ServiceWorkerJobDataIdentifier&, SWServerWorker&);
- void didFinishInstall(const ServiceWorkerJobDataIdentifier&, SWServerWorker&, bool wasSuccessful);
+ void scriptContextFailedToStart(const std::optional<ServiceWorkerJobDataIdentifier>&, SWServerWorker&, const String& message);
+ void scriptContextStarted(const std::optional<ServiceWorkerJobDataIdentifier>&, SWServerWorker&);
+ void didFinishInstall(const std::optional<ServiceWorkerJobDataIdentifier>&, SWServerWorker&, bool wasSuccessful);
void didFinishActivation(SWServerWorker&);
void workerContextTerminated(SWServerWorker&);
Modified: trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.cpp (225297 => 225298)
--- trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.cpp 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.cpp 2017-11-29 23:16:03 UTC (rev 225298)
@@ -72,19 +72,19 @@
return allConnections().begin()->value;
}
-void SWServerToContextConnection::scriptContextFailedToStart(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, const String& message)
+void SWServerToContextConnection::scriptContextFailedToStart(const std::optional<ServiceWorkerJobDataIdentifier>& jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, const String& message)
{
if (auto* worker = SWServerWorker::existingWorkerForIdentifier(serviceWorkerIdentifier))
worker->scriptContextFailedToStart(jobDataIdentifier, message);
}
-void SWServerToContextConnection::scriptContextStarted(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier)
+void SWServerToContextConnection::scriptContextStarted(const std::optional<ServiceWorkerJobDataIdentifier>& jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier)
{
if (auto* worker = SWServerWorker::existingWorkerForIdentifier(serviceWorkerIdentifier))
worker->scriptContextStarted(jobDataIdentifier);
}
-void SWServerToContextConnection::didFinishInstall(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful)
+void SWServerToContextConnection::didFinishInstall(const std::optional<ServiceWorkerJobDataIdentifier>& jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful)
{
if (auto* worker = SWServerWorker::existingWorkerForIdentifier(serviceWorkerIdentifier))
worker->didFinishInstall(jobDataIdentifier, wasSuccessful);
Modified: trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.h (225297 => 225298)
--- trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.h 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.h 2017-11-29 23:16:03 UTC (rev 225298)
@@ -50,9 +50,9 @@
virtual void terminateWorker(ServiceWorkerIdentifier) = 0;
// Messages back from the SW host process
- WEBCORE_EXPORT void scriptContextFailedToStart(const ServiceWorkerJobDataIdentifier&, ServiceWorkerIdentifier, const String& message);
- WEBCORE_EXPORT void scriptContextStarted(const ServiceWorkerJobDataIdentifier&, ServiceWorkerIdentifier);
- WEBCORE_EXPORT void didFinishInstall(const ServiceWorkerJobDataIdentifier&, ServiceWorkerIdentifier, bool wasSuccessful);
+ WEBCORE_EXPORT void scriptContextFailedToStart(const std::optional<ServiceWorkerJobDataIdentifier>&, ServiceWorkerIdentifier, const String& message);
+ WEBCORE_EXPORT void scriptContextStarted(const std::optional<ServiceWorkerJobDataIdentifier>&, ServiceWorkerIdentifier);
+ WEBCORE_EXPORT void didFinishInstall(const std::optional<ServiceWorkerJobDataIdentifier>&, ServiceWorkerIdentifier, bool wasSuccessful);
WEBCORE_EXPORT void didFinishActivation(ServiceWorkerIdentifier);
WEBCORE_EXPORT void setServiceWorkerHasPendingEvents(ServiceWorkerIdentifier, bool hasPendingEvents);
WEBCORE_EXPORT void workerTerminated(ServiceWorkerIdentifier);
Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp (225297 => 225298)
--- trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp 2017-11-29 23:16:03 UTC (rev 225298)
@@ -65,17 +65,17 @@
m_server.terminateWorker(*this);
}
-void SWServerWorker::scriptContextFailedToStart(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, const String& message)
+void SWServerWorker::scriptContextFailedToStart(const std::optional<ServiceWorkerJobDataIdentifier>& jobDataIdentifier, const String& message)
{
m_server.scriptContextFailedToStart(jobDataIdentifier, *this, message);
}
-void SWServerWorker::scriptContextStarted(const ServiceWorkerJobDataIdentifier& jobDataIdentifier)
+void SWServerWorker::scriptContextStarted(const std::optional<ServiceWorkerJobDataIdentifier>& jobDataIdentifier)
{
m_server.scriptContextStarted(jobDataIdentifier, *this);
}
-void SWServerWorker::didFinishInstall(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, bool wasSuccessful)
+void SWServerWorker::didFinishInstall(const std::optional<ServiceWorkerJobDataIdentifier>& jobDataIdentifier, bool wasSuccessful)
{
m_server.didFinishInstall(jobDataIdentifier, *this, wasSuccessful);
}
Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.h (225297 => 225298)
--- trunk/Source/WebCore/workers/service/server/SWServerWorker.h 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.h 2017-11-29 23:16:03 UTC (rev 225298)
@@ -68,9 +68,9 @@
bool hasPendingEvents() const { return m_hasPendingEvents; }
void setHasPendingEvents(bool value) { m_hasPendingEvents = value; }
- void scriptContextFailedToStart(const ServiceWorkerJobDataIdentifier&, const String& message);
- void scriptContextStarted(const ServiceWorkerJobDataIdentifier&);
- void didFinishInstall(const ServiceWorkerJobDataIdentifier&, bool wasSuccessful);
+ void scriptContextFailedToStart(const std::optional<ServiceWorkerJobDataIdentifier>&, const String& message);
+ void scriptContextStarted(const std::optional<ServiceWorkerJobDataIdentifier>&);
+ void didFinishInstall(const std::optional<ServiceWorkerJobDataIdentifier>&, bool wasSuccessful);
void didFinishActivation();
void contextTerminated();
Modified: trunk/Source/WebKit/ChangeLog (225297 => 225298)
--- trunk/Source/WebKit/ChangeLog 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebKit/ChangeLog 2017-11-29 23:16:03 UTC (rev 225298)
@@ -1,3 +1,17 @@
+2017-11-29 Brady Eidson <beid...@apple.com>
+
+ When managing context startups, make ServiceWorkerJobDataIdentifier's optional.
+ https://bugs.webkit.org/show_bug.cgi?id=180166
+
+ Reviewed by Chris Dumez.
+
+ * StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in:
+
+ * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+ (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage):
+ (WebKit::WebSWContextManagerConnection::didFinishInstall):
+ * WebProcess/Storage/WebSWContextManagerConnection.h:
+
2017-11-29 Youenn Fablet <you...@apple.com>
Add support for service worker generated redirections
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in (225297 => 225298)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in 2017-11-29 23:16:03 UTC (rev 225298)
@@ -25,9 +25,9 @@
messages -> WebSWServerToContextConnection {
# When possible, these messages can be implemented directly by WebCore::SWServerToContextConnection
- ScriptContextFailedToStart(struct WebCore::ServiceWorkerJobDataIdentifier jobDataIdentifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, String message);
- ScriptContextStarted(struct WebCore::ServiceWorkerJobDataIdentifier jobDataIdentifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier);
- DidFinishInstall(struct WebCore::ServiceWorkerJobDataIdentifier jobDataIdentifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful);
+ ScriptContextFailedToStart(std::optional<WebCore::ServiceWorkerJobDataIdentifier> jobDataIdentifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, String message);
+ ScriptContextStarted(std::optional<WebCore::ServiceWorkerJobDataIdentifier> jobDataIdentifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier);
+ DidFinishInstall(std::optional<WebCore::ServiceWorkerJobDataIdentifier> jobDataIdentifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful);
DidFinishActivation(WebCore::ServiceWorkerIdentifier identifier);
SetServiceWorkerHasPendingEvents(WebCore::ServiceWorkerIdentifier identifier, bool hasPendingEvents);
WorkerTerminated(WebCore::ServiceWorkerIdentifier identifier);
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (225297 => 225298)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2017-11-29 23:16:03 UTC (rev 225298)
@@ -124,7 +124,7 @@
LOG(ServiceWorker, "Context process PID: %i created worker thread\n", getpid());
}
-void WebSWContextManagerConnection::serviceWorkerStartedWithMessage(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, const String& exceptionMessage)
+void WebSWContextManagerConnection::serviceWorkerStartedWithMessage(std::optional<ServiceWorkerJobDataIdentifier> jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, const String& exceptionMessage)
{
if (exceptionMessage.isEmpty())
m_connectionToStorageProcess->send(Messages::WebSWServerToContextConnection::ScriptContextStarted(jobDataIdentifier, serviceWorkerIdentifier), 0);
@@ -174,7 +174,7 @@
m_connectionToStorageProcess->send(Messages::StorageProcess::PostMessageToServiceWorkerClient(destinationIdentifier, IPC::DataReference { message->data() }, sourceIdentifier, sourceOrigin), 0);
}
-void WebSWContextManagerConnection::didFinishInstall(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful)
+void WebSWContextManagerConnection::didFinishInstall(std::optional<ServiceWorkerJobDataIdentifier> jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful)
{
m_connectionToStorageProcess->send(Messages::WebSWServerToContextConnection::DidFinishInstall(jobDataIdentifier, serviceWorkerIdentifier, wasSuccessful), 0);
}
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h (225297 => 225298)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h 2017-11-29 23:03:49 UTC (rev 225297)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h 2017-11-29 23:16:03 UTC (rev 225298)
@@ -57,13 +57,13 @@
// WebCore::SWContextManager::Connection.
void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, Ref<WebCore::SerializedScriptValue>&& message, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin) final;
- void didFinishInstall(const WebCore::ServiceWorkerJobDataIdentifier&, WebCore::ServiceWorkerIdentifier, bool wasSuccessful) final;
+ void didFinishInstall(std::optional<WebCore::ServiceWorkerJobDataIdentifier>, WebCore::ServiceWorkerIdentifier, bool wasSuccessful) final;
void didFinishActivation(WebCore::ServiceWorkerIdentifier) final;
void setServiceWorkerHasPendingEvents(WebCore::ServiceWorkerIdentifier, bool) final;
void workerTerminated(WebCore::ServiceWorkerIdentifier) final;
// IPC messages.
- void serviceWorkerStartedWithMessage(const WebCore::ServiceWorkerJobDataIdentifier&, WebCore::ServiceWorkerIdentifier, const String& exceptionMessage) final;
+ void serviceWorkerStartedWithMessage(std::optional<WebCore::ServiceWorkerJobDataIdentifier>, WebCore::ServiceWorkerIdentifier, const String& exceptionMessage) final;
void installServiceWorker(const WebCore::ServiceWorkerContextData&);
void startFetch(WebCore::SWServerConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, WebCore::ResourceRequest&&, WebCore::FetchOptions&&, IPC::FormDataReference&&);
void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerClientIdentifier sourceIdentifier, WebCore::ServiceWorkerClientData&& sourceData);