Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (224552 => 224553)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2017-11-07 23:06:55 UTC (rev 224553)
@@ -1,3 +1,12 @@
+2017-11-07 Brady Eidson <[email protected]>
+
+ Implement "UpdateWorkerState" and use it
+ https://bugs.webkit.org/show_bug.cgi?id=179318
+
+ Reviewed by Chris Dumez.
+
+ * web-platform-tests/service-workers/service-worker/update.https-expected.txt:
+
2017-11-07 Maciej Stachowiak <[email protected]>
Update WPT encoding test suite to the latest version.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/update.https-expected.txt (224552 => 224553)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/update.https-expected.txt 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/update.https-expected.txt 2017-11-07 23:06:55 UTC (rev 224553)
@@ -1,3 +1,3 @@
-FAIL Update a registration. promise_test: Unhandled rejection with value: object "TypeError: Cannot update a null/nonexistent service worker registration"
+FAIL Update a registration. assert_unreached: update() should reject. Reached unreachable code
Modified: trunk/Source/WTF/ChangeLog (224552 => 224553)
--- trunk/Source/WTF/ChangeLog 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WTF/ChangeLog 2017-11-07 23:06:55 UTC (rev 224553)
@@ -1,3 +1,13 @@
+2017-11-07 Brady Eidson <[email protected]>
+
+ Implement "UpdateWorkerState" and use it
+ https://bugs.webkit.org/show_bug.cgi?id=179318
+
+ Reviewed by Chris Dumez.
+
+ * wtf/ObjectIdentifier.h:
+ (WTF::ObjectIdentifier::loggingString const):
+
2017-11-07 Michael Saboff <[email protected]>
Add SPI function pointers qualifiers for CPU(ARM64E)
Modified: trunk/Source/WTF/wtf/ObjectIdentifier.h (224552 => 224553)
--- trunk/Source/WTF/wtf/ObjectIdentifier.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WTF/wtf/ObjectIdentifier.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -26,6 +26,7 @@
#pragma once
#include <wtf/HashTraits.h>
+#include <wtf/text/WTFString.h>
namespace WTF {
@@ -60,6 +61,13 @@
{
return m_identifier != other.m_identifier;
}
+
+#ifndef NDEBUG
+ String loggingString() const
+ {
+ return String::number(m_identifier);
+ }
+#endif
private:
template<typename U> friend ObjectIdentifier<U> makeObjectIdentifier(uint64_t);
Modified: trunk/Source/WebCore/ChangeLog (224552 => 224553)
--- trunk/Source/WebCore/ChangeLog 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/ChangeLog 2017-11-07 23:06:55 UTC (rev 224553)
@@ -1,3 +1,75 @@
+2017-11-07 Brady Eidson <[email protected]>
+
+ Implement "UpdateWorkerState" and use it
+ https://bugs.webkit.org/show_bug.cgi?id=179318
+
+ Reviewed by Chris Dumez.
+
+ No new tests (Existing tests and changes there-to).
+
+ * workers/service/ServiceWorker.cpp:
+ (WebCore::ServiceWorker::allWorkers):
+ (WebCore::ServiceWorker::mutableAllWorkers):
+ (WebCore::ServiceWorker::ServiceWorker):
+ (WebCore::ServiceWorker::~ServiceWorker):
+ (WebCore::ServiceWorker::updateWorkerState):
+ (WebCore::ServiceWorker::setState): Deleted.
+ * workers/service/ServiceWorker.h:
+
+ * workers/service/ServiceWorkerContainer.cpp:
+ (WebCore::ServiceWorkerContainer::updateRegistrationState):
+ (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
+ * workers/service/ServiceWorkerContainer.h:
+
+ * workers/service/ServiceWorkerRegistration.cpp:
+ (WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration):
+ (WebCore::ServiceWorkerRegistration::~ServiceWorkerRegistration):
+ (WebCore::ServiceWorkerRegistration::updateStateFromServer):
+
+ * workers/service/ServiceWorkerRegistrationData.cpp:
+ (WebCore::ServiceWorkerRegistrationData::isolatedCopy const):
+ * workers/service/ServiceWorkerRegistrationData.h:
+ (WebCore::ServiceWorkerRegistrationData::encode const):
+ (WebCore::ServiceWorkerRegistrationData::decode):
+
+ * workers/service/ServiceWorkerRegistrationKey.cpp:
+ (WebCore::ServiceWorkerRegistrationKey::loggingString const):
+ * workers/service/ServiceWorkerRegistrationKey.h:
+
+ * workers/service/ServiceWorkerTypes.h:
+
+ * workers/service/context/SWContextManager.cpp:
+ (WebCore::SWContextManager::registerServiceWorkerThreadForInstall):
+ (WebCore::SWContextManager::registerServiceWorkerThreadForUpdate): Deleted.
+ * workers/service/context/SWContextManager.h:
+
+ * workers/service/server/SWClientConnection.cpp:
+ (WebCore::SWClientConnection::updateRegistrationState):
+ (WebCore::SWClientConnection::updateWorkerState):
+ * workers/service/server/SWClientConnection.h:
+
+ * workers/service/server/SWServer.cpp:
+ (WebCore::SWServer::updateWorker):
+ * workers/service/server/SWServer.h:
+ (WebCore::SWServer::workerByID const):
+
+ * workers/service/server/SWServerJobQueue.cpp:
+ (WebCore::SWServerJobQueue::scriptFetchFinished):
+ (WebCore::SWServerJobQueue::scriptContextStarted):
+ (WebCore::SWServerJobQueue::install):
+ (WebCore::SWServerJobQueue::tryClearRegistration):
+
+ * workers/service/server/SWServerRegistration.cpp:
+ (WebCore::SWServerRegistration::updateRegistrationState):
+ (WebCore::SWServerRegistration::updateWorkerState):
+ (WebCore::SWServerRegistration::data const):
+ * workers/service/server/SWServerRegistration.h:
+ (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): Deleted.
+
+ * workers/service/server/SWServerWorker.h:
+ (WebCore::SWServerWorker::state const):
+ (WebCore::SWServerWorker::setState):
+
2017-11-07 Zalan Bujtas <[email protected]>
[LayoutState cleanup] Remove explicit LayoutStateMaintainer::pop calls.
Modified: trunk/Source/WebCore/workers/service/ServiceWorker.cpp (224552 => 224553)
--- trunk/Source/WebCore/workers/service/ServiceWorker.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/ServiceWorker.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -35,20 +35,55 @@
#include "SerializedScriptValue.h"
#include "ServiceWorkerProvider.h"
#include <runtime/JSCJSValueInlines.h>
+#include <wtf/NeverDestroyed.h>
namespace WebCore {
+const HashMap<ServiceWorkerIdentifier, HashSet<ServiceWorker*>>& ServiceWorker::allWorkers()
+{
+ return mutableAllWorkers();
+}
+
+HashMap<ServiceWorkerIdentifier, HashSet<ServiceWorker*>>& ServiceWorker::mutableAllWorkers()
+{
+ // FIXME: Once we support service workers from workers, this will need to change.
+ RELEASE_ASSERT(isMainThread());
+
+ static NeverDestroyed<HashMap<ServiceWorkerIdentifier, HashSet<ServiceWorker*>>> allWorkersMap;
+ return allWorkersMap;
+}
+
ServiceWorker::ServiceWorker(ScriptExecutionContext& context, ServiceWorkerIdentifier identifier, const URL& scriptURL)
: ContextDestructionObserver(&context)
, m_identifier(identifier)
, m_scriptURL(scriptURL)
{
+ auto result = mutableAllWorkers().ensure(identifier, [] {
+ return HashSet<ServiceWorker*>();
+ });
+ result.iterator->value.add(this);
}
-void ServiceWorker::setState(State state)
+ServiceWorker::~ServiceWorker()
{
+ auto iterator = mutableAllWorkers().find(m_identifier);
+
+ ASSERT(iterator->value.contains(this));
+ iterator->value.remove(this);
+
+ if (iterator->value.isEmpty())
+ mutableAllWorkers().remove(iterator);
+}
+
+void ServiceWorker::updateWorkerState(State state, ShouldFireStateChangeEvent shouldFire)
+{
+ // FIXME: Once we support service workers from workers, this might need to change.
+ RELEASE_ASSERT(isMainThread());
+
m_state = state;
- dispatchEvent(Event::create(eventNames().statechangeEvent, false, false));
+
+ if (shouldFire == FireStateChangeEvent)
+ dispatchEvent(Event::create(eventNames().statechangeEvent, false, false));
}
ExceptionOr<void> ServiceWorker::postMessage(ScriptExecutionContext& context, JSC::JSValue messageValue, Vector<JSC::Strong<JSC::JSObject>>&& transfer)
Modified: trunk/Source/WebCore/workers/service/ServiceWorker.h (224552 => 224553)
--- trunk/Source/WebCore/workers/service/ServiceWorker.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/ServiceWorker.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -30,6 +30,7 @@
#include "ContextDestructionObserver.h"
#include "EventTarget.h"
#include "ServiceWorkerIdentifier.h"
+#include "ServiceWorkerTypes.h"
#include "URL.h"
#include <heap/Strong.h>
#include <wtf/RefCounted.h>
@@ -49,20 +50,18 @@
return adoptRef(*new ServiceWorker(context, identifier, scriptURL));
}
- virtual ~ServiceWorker() = default;
+ virtual ~ServiceWorker();
- enum class State {
- Installing,
- Installed,
- Activating,
- Activated,
- Redundant,
- };
-
const URL& scriptURL() const { return m_scriptURL; }
+ using State = ServiceWorkerState;
State state() const { return m_state; }
- void setState(State);
+
+ enum ShouldFireStateChangeEvent {
+ FireStateChangeEvent,
+ DoNotFireStateChangeEvent,
+ };
+ void updateWorkerState(State, ShouldFireStateChangeEvent = FireStateChangeEvent);
ExceptionOr<void> postMessage(ScriptExecutionContext&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&);
@@ -71,8 +70,11 @@
using RefCounted::ref;
using RefCounted::deref;
+ static const HashMap<ServiceWorkerIdentifier, HashSet<ServiceWorker*>>& allWorkers();
+
private:
ServiceWorker(ScriptExecutionContext&, ServiceWorkerIdentifier, const URL& scriptURL);
+ static HashMap<ServiceWorkerIdentifier, HashSet<ServiceWorker*>>& mutableAllWorkers();
virtual EventTargetInterface eventTargetInterface() const;
virtual ScriptExecutionContext* scriptExecutionContext() const;
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (224552 => 224553)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -241,7 +241,7 @@
});
}
-void ServiceWorkerContainer::updateRegistration(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, const std::optional<ServiceWorkerIdentifier>& serviceWorkerIdentifier)
+void ServiceWorkerContainer::updateRegistrationState(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, const std::optional<ServiceWorkerIdentifier>& serviceWorkerIdentifier)
{
if (auto* registration = m_registrations.get(key))
registration->updateStateFromServer(state, serviceWorkerIdentifier);
@@ -299,17 +299,17 @@
return;
registration->setInstallingWorker(nullptr);
registration->setWaitingWorker(serviceWorker.copyRef());
- serviceWorker->setState(ServiceWorker::State::Installed);
+ serviceWorker->updateWorkerState(ServiceWorker::State::Installed);
callOnMainThread([container = WTFMove(container), registration = WTFMove(registration), serviceWorker = WTFMove(serviceWorker)] () mutable {
if (container->isStopped())
return;
registration->setWaitingWorker(nullptr);
registration->setActiveWorker(serviceWorker.copyRef());
- serviceWorker->setState(ServiceWorker::State::Activating);
+ serviceWorker->updateWorkerState(ServiceWorker::State::Activating);
callOnMainThread([container = WTFMove(container), serviceWorker = WTFMove(serviceWorker)] () mutable {
if (container->isStopped())
return;
- serviceWorker->setState(ServiceWorker::State::Activated);
+ serviceWorker->updateWorkerState(ServiceWorker::State::Activated);
});
});
});
@@ -346,20 +346,31 @@
}
// FIXME: Implement proper selection of service workers.
- auto* activeServiceWorker = context->activeServiceWorker();
- ASSERT(data.activeServiceWorkerIdentifier);
- if (!activeServiceWorker || activeServiceWorker->identifier() != *data.activeServiceWorkerIdentifier) {
- context->setActiveServiceWorker(ServiceWorker::create(*context, *data.activeServiceWorkerIdentifier, data.scriptURL));
- activeServiceWorker = context->activeServiceWorker();
+ auto* installingServiceWorker = context->activeServiceWorker();
+ ASSERT(data.installingServiceWorkerIdentifier);
+ if (!installingServiceWorker || installingServiceWorker->identifier() != *data.installingServiceWorkerIdentifier) {
+ context->setActiveServiceWorker(ServiceWorker::create(*context, *data.installingServiceWorkerIdentifier, data.scriptURL));
+ installingServiceWorker = context->activeServiceWorker();
}
RefPtr<ServiceWorkerRegistration> registration = m_registrations.get(data.key);
- if (!registration)
+ if (!registration) {
+ // Currently the only registrations that can be created for the first time here should be Installing.
+ ASSERT(data.installingServiceWorkerIdentifier);
+ auto installingIdentifier = *data.installingServiceWorkerIdentifier;
+
registration = ServiceWorkerRegistration::create(*context, *this, WTFMove(data));
+ registration->updateStateFromServer(ServiceWorkerRegistrationState::Installing, installingIdentifier);
+ ASSERT(registration->installing());
- activeServiceWorker->setState(ServiceWorker::State::Installing);
- registration->setInstallingWorker(activeServiceWorker);
+ installingServiceWorker = registration->installing();
+ }
+ installingServiceWorker->updateWorkerState(ServiceWorkerState::Installing, ServiceWorker::DoNotFireStateChangeEvent);
+ registration->setInstallingWorker(installingServiceWorker);
+
+ LOG(ServiceWorker, "Container %p resolved job with registration %p", this, registration.get());
+
job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(*registration);
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (224552 => 224553)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -65,7 +65,7 @@
void updateRegistration(const URL& scopeURL, const URL& scriptURL, WorkerType, Ref<DeferredPromise>&&);
void getRegistration(const String& clientURL, Ref<DeferredPromise>&&);
- void updateRegistration(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerIdentifier>&);
+ void updateRegistrationState(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerIdentifier>&);
void fireUpdateFoundEvent(const ServiceWorkerRegistrationKey&);
void firePostInstallEvents(const ServiceWorkerRegistrationKey&);
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp (224552 => 224553)
--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -29,6 +29,7 @@
#if ENABLE(SERVICE_WORKER)
#include "DOMWindow.h"
#include "Document.h"
+#include "Logging.h"
#include "ServiceWorker.h"
#include "ServiceWorkerContainer.h"
#include "ServiceWorkerTypes.h"
@@ -41,6 +42,7 @@
, m_registrationData(WTFMove(registrationData))
, m_container(WTFMove(container))
{
+ LOG(ServiceWorker, "Creating registration %p for registration key %s", this, m_registrationData.key.loggingString().utf8().data());
suspendIfNeeded();
m_container->addRegistration(*this);
}
@@ -47,6 +49,8 @@
ServiceWorkerRegistration::~ServiceWorkerRegistration()
{
+ LOG(ServiceWorker, "Deleting registration %p for registration key %s", this, m_registrationData.key.loggingString().utf8().data());
+
m_container->removeRegistration(*this);
}
@@ -145,9 +149,25 @@
void ServiceWorkerRegistration::updateStateFromServer(ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
{
- // FIXME: Implement here along with "Update Worker State" algorithm
- UNUSED_PARAM(state);
- UNUSED_PARAM(serviceWorkerIdentifier);
+ auto* context = scriptExecutionContext();
+ if (!context)
+ return;
+
+ RefPtr<ServiceWorker> worker;
+ if (serviceWorkerIdentifier)
+ worker = ServiceWorker::create(*context, *serviceWorkerIdentifier, m_registrationData.scriptURL);
+
+ switch (state) {
+ case ServiceWorkerRegistrationState::Installing:
+ m_installingWorker = WTFMove(worker);
+ break;
+ case ServiceWorkerRegistrationState::Waiting:
+ m_waitingWorker = WTFMove(worker);
+ break;
+ case ServiceWorkerRegistrationState::Active:
+ m_activeWorker = WTFMove(worker);
+ break;
+ }
}
EventTargetInterface ServiceWorkerRegistration::eventTargetInterface() const
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp (224552 => 224553)
--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -35,10 +35,12 @@
return {
key.isolatedCopy(),
identifier,
- activeServiceWorkerIdentifier,
scopeURL.isolatedCopy(),
scriptURL.isolatedCopy(),
- updateViaCache
+ updateViaCache,
+ installingServiceWorkerIdentifier,
+ waitingServiceWorkerIdentifier,
+ activeServiceWorkerIdentifier,
};
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.h (224552 => 224553)
--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -37,11 +37,14 @@
struct ServiceWorkerRegistrationData {
ServiceWorkerRegistrationKey key;
uint64_t identifier;
- std::optional<ServiceWorkerIdentifier> activeServiceWorkerIdentifier; // FIXME: This should not be part of registrationData.
URL scopeURL;
URL scriptURL;
ServiceWorkerUpdateViaCache updateViaCache;
+ std::optional<ServiceWorkerIdentifier> installingServiceWorkerIdentifier;
+ std::optional<ServiceWorkerIdentifier> waitingServiceWorkerIdentifier;
+ std::optional<ServiceWorkerIdentifier> activeServiceWorkerIdentifier;
+
ServiceWorkerRegistrationData isolatedCopy() const;
template<class Encoder> void encode(Encoder&) const;
@@ -52,7 +55,7 @@
template<class Encoder>
void ServiceWorkerRegistrationData::encode(Encoder& encoder) const
{
- encoder << key << identifier << activeServiceWorkerIdentifier << scopeURL << scriptURL << updateViaCache;
+ encoder << key << identifier << scopeURL << scriptURL << updateViaCache << installingServiceWorkerIdentifier << waitingServiceWorkerIdentifier << activeServiceWorkerIdentifier;
}
template<class Decoder>
@@ -68,12 +71,6 @@
if (!identifier)
return std::nullopt;
-
- std::optional<std::optional<ServiceWorkerIdentifier>> activeServiceWorkerIdentifier;
- decoder >> activeServiceWorkerIdentifier;
- if (!activeServiceWorkerIdentifier)
- return std::nullopt;
-
std::optional<URL> scopeURL;
decoder >> scopeURL;
if (!scopeURL)
@@ -89,7 +86,22 @@
if (!updateViaCache)
return std::nullopt;
- return { { WTFMove(*key), WTFMove(*identifier), WTFMove(*activeServiceWorkerIdentifier), WTFMove(*scopeURL), WTFMove(*scriptURL), WTFMove(*updateViaCache) } };
+ std::optional<std::optional<ServiceWorkerIdentifier>> installingServiceWorkerIdentifier;
+ decoder >> installingServiceWorkerIdentifier;
+ if (!installingServiceWorkerIdentifier)
+ return std::nullopt;
+
+ std::optional<std::optional<ServiceWorkerIdentifier>> waitingServiceWorkerIdentifier;
+ decoder >> waitingServiceWorkerIdentifier;
+ if (!waitingServiceWorkerIdentifier)
+ return std::nullopt;
+
+ std::optional<std::optional<ServiceWorkerIdentifier>> activeServiceWorkerIdentifier;
+ decoder >> activeServiceWorkerIdentifier;
+ if (!activeServiceWorkerIdentifier)
+ return std::nullopt;
+
+ return { { WTFMove(*key), WTFMove(*identifier), WTFMove(*scopeURL), WTFMove(*scriptURL), WTFMove(*updateViaCache), WTFMove(*installingServiceWorkerIdentifier), WTFMove(*waitingServiceWorkerIdentifier), WTFMove(*activeServiceWorkerIdentifier) } };
}
} // namespace WTF
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp (224552 => 224553)
--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -76,6 +76,13 @@
return clientURL.string().startsWith(m_scope);
}
+#ifndef NDEBUG
+String ServiceWorkerRegistrationKey::loggingString() const
+{
+ return makeString(m_topOrigin.debugString(), "-", m_clientCreationURL.string(), "-", m_scope.string());
+}
+#endif
+
} // namespace WebCore
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationKey.h (224552 => 224553)
--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationKey.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationKey.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -53,6 +53,10 @@
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<ServiceWorkerRegistrationKey> decode(Decoder&);
+#ifndef NDEBUG
+ String loggingString() const;
+#endif
+
private:
URL m_clientCreationURL;
SecurityOriginData m_topOrigin;
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerTypes.h (224552 => 224553)
--- trunk/Source/WebCore/workers/service/ServiceWorkerTypes.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerTypes.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -35,6 +35,14 @@
Active = 2,
};
+enum class ServiceWorkerState {
+ Installing,
+ Installed,
+ Activating,
+ Activated,
+ Redundant,
+};
+
} // namespace WebCore
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.cpp (224552 => 224553)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -47,7 +47,7 @@
return m_connection.get();
}
-void SWContextManager::registerServiceWorkerThreadForUpdate(Ref<ServiceWorkerThreadProxy>&& serviceWorkerThreadProxy)
+void SWContextManager::registerServiceWorkerThreadForInstall(Ref<ServiceWorkerThreadProxy>&& serviceWorkerThreadProxy)
{
auto serviceWorkerIdentifier = serviceWorkerThreadProxy->identifier();
auto* threadProxy = serviceWorkerThreadProxy.ptr();
Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.h (224552 => 224553)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -53,10 +53,11 @@
WEBCORE_EXPORT void setConnection(std::unique_ptr<Connection>&&);
WEBCORE_EXPORT Connection* connection() const;
- WEBCORE_EXPORT void registerServiceWorkerThreadForUpdate(Ref<ServiceWorkerThreadProxy>&&);
+ WEBCORE_EXPORT void registerServiceWorkerThreadForInstall(Ref<ServiceWorkerThreadProxy>&&);
WEBCORE_EXPORT ServiceWorkerThreadProxy* serviceWorkerThreadProxy(ServiceWorkerIdentifier) const;
WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destination, Ref<SerializedScriptValue>&& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
WEBCORE_EXPORT void fireInstallEvent(ServiceWorkerIdentifier);
+
private:
SWContextManager() = default;
Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp (224552 => 224553)
--- trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -150,10 +150,18 @@
void SWClientConnection::updateRegistrationState(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
{
forEachContainer([&](ServiceWorkerContainer& container) {
- container.updateRegistration(key, state, serviceWorkerIdentifier);
+ container.updateRegistrationState(key, state, serviceWorkerIdentifier);
});
}
+void SWClientConnection::updateWorkerState(ServiceWorkerIdentifier worker, ServiceWorkerState state)
+{
+ const auto& matchingWorkers = ServiceWorker::allWorkers().get(worker);
+
+ for (auto* worker : matchingWorkers)
+ worker->updateWorkerState(state);
+}
+
void SWClientConnection::fireUpdateFoundEvent(const ServiceWorkerRegistrationKey& key)
{
forEachContainer([&](ServiceWorkerContainer& container) {
Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.h (224552 => 224553)
--- trunk/Source/WebCore/workers/service/server/SWClientConnection.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -40,6 +40,7 @@
class ServiceWorkerRegistration;
class SharedBuffer;
enum class ServiceWorkerRegistrationState;
+enum class ServiceWorkerState;
struct ExceptionData;
struct ServiceWorkerFetchResult;
struct ServiceWorkerRegistrationData;
@@ -68,6 +69,7 @@
WEBCORE_EXPORT void startScriptFetchForServer(uint64_t jobIdentifier);
WEBCORE_EXPORT void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier source, const String& sourceOrigin);
WEBCORE_EXPORT void updateRegistrationState(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>);
+ WEBCORE_EXPORT void updateWorkerState(ServiceWorkerIdentifier, ServiceWorkerState);
WEBCORE_EXPORT void fireUpdateFoundEvent(const ServiceWorkerRegistrationKey&);
WEBCORE_EXPORT void firePostInstallEvents(const ServiceWorkerRegistrationKey&);
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (224552 => 224553)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -262,12 +262,12 @@
Ref<SWServerWorker> SWServer::updateWorker(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type)
{
auto serviceWorkerIdentifier = generateServiceWorkerIdentifier();
-
+
auto result = m_workersByID.add(serviceWorkerIdentifier, SWServerWorker::create(registrationKey, url, script, type, serviceWorkerIdentifier));
ASSERT(result.isNewEntry);
+
+ connection.installServiceWorkerContext({ registrationKey, serviceWorkerIdentifier, script, url });
- connection.updateServiceWorkerContext({ registrationKey, serviceWorkerIdentifier, script, url });
-
return result.iterator->value.get();
}
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (224552 => 224553)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -27,6 +27,7 @@
#if ENABLE(SERVICE_WORKER)
+#include "SWServerWorker.h"
#include "ServiceWorkerIdentifier.h"
#include "ServiceWorkerJob.h"
#include "ServiceWorkerRegistrationData.h"
@@ -44,8 +45,8 @@
class SWServerJobQueue;
class SWServerRegistration;
-class SWServerWorker;
enum class ServiceWorkerRegistrationState;
+enum class ServiceWorkerState;
struct ExceptionData;
struct ServiceWorkerContextData;
struct ServiceWorkerFetchResult;
@@ -65,6 +66,7 @@
// Messages to the client WebProcess
virtual void updateRegistrationStateInClient(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>) = 0;
+ virtual void updateWorkerStateInClient(ServiceWorkerIdentifier, ServiceWorkerState) = 0;
virtual void fireUpdateFoundEvent(const ServiceWorkerRegistrationKey&) = 0;
virtual void firePostInstallEvents(const ServiceWorkerRegistrationKey&) = 0;
@@ -85,7 +87,7 @@
virtual void startScriptFetchInClient(uint64_t jobIdentifier) = 0;
// Messages to the SW host WebProcess
- virtual void updateServiceWorkerContext(const ServiceWorkerContextData&) = 0;
+ virtual void installServiceWorkerContext(const ServiceWorkerContextData&) = 0;
virtual void fireInstallEvent(ServiceWorkerIdentifier) = 0;
SWServer& m_server;
@@ -111,6 +113,7 @@
Ref<SWServerWorker> updateWorker(Connection&, const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType);
void fireInstallEvent(Connection&, ServiceWorkerIdentifier);
+ SWServerWorker* workerByID(ServiceWorkerIdentifier identifier) const { return m_workersByID.get(identifier); }
Connection* getConnection(uint64_t identifier) { return m_connections.get(identifier); }
Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp (224552 => 224553)
--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -73,21 +73,12 @@
return;
}
- // If newestWorker is not null, newestWorker's script url equals job's script url with the exclude fragments
+ // FIXME: If newestWorker is not null, newestWorker's script url equals job's script url with the exclude fragments
// flag set, and script's source text is a byte-for-byte match with newestWorker's script resource's source
// text, then:
- if (newestWorker && equalIgnoringFragmentIdentifier(newestWorker->scriptURL(), job.scriptURL) && result.script == newestWorker->script()) {
- // FIXME: if script is a classic script, and script's module record's [[ECMAScriptCode]] is a byte-for-byte
- // match with newestWorker's script resource's module record's [[ECMAScriptCode]] otherwise.
+ // - Invoke Resolve Job Promise with job and registration.
+ // - Invoke Finish Job with job and abort these steps.
- // Invoke Resolve Job Promise with job and registration.
- m_server.resolveRegistrationJob(job, registration->data());
-
- // Invoke Finish Job with job and abort these steps.
- finishCurrentJob();
- return;
- }
-
// FIXME: Support the proper worker type (classic vs module)
m_server.updateWorker(connection, m_registrationKey, job.scriptURL, result.script, WorkerType::Classic);
}
@@ -113,14 +104,20 @@
{
auto* registration = m_server.getRegistration(m_registrationKey);
ASSERT(registration);
- registration->setActiveServiceWorkerIdentifier(identifier);
install(*registration, connection, identifier);
}
// https://w3c.github.io/ServiceWorker/#install
-void SWServerJobQueue::install(SWServerRegistration& registration, SWServer::Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier)
+void SWServerJobQueue::install(SWServerRegistration& registration, SWServer::Connection& connection, ServiceWorkerIdentifier installingWorker)
{
+ // The Install algorithm should never be invoked with a null worker.
+ auto* worker = m_server.workerByID(installingWorker);
+ RELEASE_ASSERT(worker);
+
+ registration.updateRegistrationState(ServiceWorkerRegistrationState::Installing, worker);
+ registration.updateWorkerState(*worker, ServiceWorkerState::Installing);
+
// Invoke Resolve Job Promise with job and registration.
m_server.resolveRegistrationJob(firstJob(), registration.data());
@@ -130,7 +127,7 @@
registration.fireUpdateFoundEvent(firstJob().connectionIdentifier());
// Queue a task to fire the InstallEvent.
- m_server.fireInstallEvent(connection, serviceWorkerIdentifier);
+ m_server.fireInstallEvent(connection, installingWorker);
}
// https://w3c.github.io/ServiceWorker/#install
@@ -250,9 +247,9 @@
{
// FIXME: Make sure that the registration has no service worker client.
- // FIXME: The specification has more complex logic here.
- if (!registration.getNewestWorker())
- clearRegistration(registration);
+ // FIXME: The specification has more complex logic here. We currently clear registrations
+ // too aggressively.
+ clearRegistration(registration);
}
// https://w3c.github.io/ServiceWorker/#clear-registration
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp (224552 => 224553)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -61,6 +61,8 @@
void SWServerRegistration::updateRegistrationState(ServiceWorkerRegistrationState state, SWServerWorker* worker)
{
+ LOG(ServiceWorker, "(%p) Updating registration state to %i with worker %p", this, (int)state, worker);
+
switch (state) {
case ServiceWorkerRegistrationState::Installing:
m_installingWorker = worker;
@@ -83,6 +85,18 @@
}
}
+void SWServerRegistration::updateWorkerState(SWServerWorker& worker, ServiceWorkerState state)
+{
+ LOG(ServiceWorker, "Updating worker %p state to %i (%p)", &worker, (int)state, this);
+
+ worker.setState(state);
+
+ for (auto& connectionIdentifierWithClients : m_clientRegistrationsByConnection.keys()) {
+ if (auto* connection = m_server.getConnection(connectionIdentifierWithClients))
+ connection->updateWorkerStateInClient(worker.identifier(), state);
+ }
+}
+
void SWServerRegistration::fireUpdateFoundEvent(uint64_t connectionIdentifier)
{
// No matter what, we send the event to the connection that scheduled the job. The client registration
@@ -115,7 +129,19 @@
ServiceWorkerRegistrationData SWServerRegistration::data() const
{
- return { m_registrationKey, identifier(), m_activeServiceWorkerIdentifier, m_scopeURL, m_scriptURL, m_updateViaCache };
+ std::optional<ServiceWorkerIdentifier> installingID;
+ if (m_installingWorker)
+ installingID = m_installingWorker->identifier();
+
+ std::optional<ServiceWorkerIdentifier> waitingID;
+ if (m_waitingWorker)
+ waitingID = m_waitingWorker->identifier();
+
+ std::optional<ServiceWorkerIdentifier> activeID;
+ if (m_activeWorker)
+ activeID = m_activeWorker->identifier();
+
+ return { m_registrationKey, identifier(), m_scopeURL, m_scriptURL, m_updateViaCache, installingID, waitingID, activeID };
}
void SWServerRegistration::addClientServiceWorkerRegistration(uint64_t connectionIdentifier, uint64_t clientRegistrationIdentifier)
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.h (224552 => 224553)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -36,6 +36,7 @@
class SWServer;
class SWServerWorker;
enum class ServiceWorkerRegistrationState;
+enum class ServiceWorkerState;
struct ExceptionData;
struct ServiceWorkerFetchResult;
@@ -55,9 +56,8 @@
void setLastUpdateTime(double time) { m_lastUpdateTime = time; }
ServiceWorkerUpdateViaCache updateViaCache() const { return m_updateViaCache; }
- void setActiveServiceWorkerIdentifier(ServiceWorkerIdentifier identifier) { m_activeServiceWorkerIdentifier = identifier; }
-
void updateRegistrationState(ServiceWorkerRegistrationState, SWServerWorker*);
+ void updateWorkerState(SWServerWorker&, ServiceWorkerState);
void fireUpdateFoundEvent(uint64_t connectionIdentifier);
void firePostInstallEvents(uint64_t connectionIdentifier);
@@ -75,8 +75,6 @@
RefPtr<SWServerWorker> m_waitingWorker;
RefPtr<SWServerWorker> m_activeWorker;
- std::optional<ServiceWorkerIdentifier> m_activeServiceWorkerIdentifier;
-
double m_lastUpdateTime { 0 };
HashMap<uint64_t, std::unique_ptr<HashSet<uint64_t>>> m_clientRegistrationsByConnection;
Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.h (224552 => 224553)
--- trunk/Source/WebCore/workers/service/server/SWServerWorker.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -29,6 +29,7 @@
#include "ServiceWorkerIdentifier.h"
#include "ServiceWorkerRegistrationKey.h"
+#include "ServiceWorkerTypes.h"
#include "URL.h"
#include <wtf/ThreadSafeRefCounted.h>
@@ -49,8 +50,12 @@
const URL& scriptURL() const { return m_scriptURL; }
const String& script() const { return m_script; }
WorkerType type() const { return m_type; }
+
ServiceWorkerIdentifier identifier() const { return m_identifier; }
-
+
+ ServiceWorkerState state() const { return m_state; }
+ void setState(ServiceWorkerState state) { m_state = state; }
+
private:
SWServerWorker(const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType, ServiceWorkerIdentifier);
@@ -59,6 +64,8 @@
String m_script;
ServiceWorkerIdentifier m_identifier;
WorkerType m_type;
+
+ ServiceWorkerState m_state { ServiceWorkerState::Redundant };
};
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (224552 => 224553)
--- trunk/Source/WebKit/ChangeLog 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebKit/ChangeLog 2017-11-07 23:06:55 UTC (rev 224553)
@@ -1,3 +1,29 @@
+2017-11-07 Brady Eidson <[email protected]>
+
+ Implement "UpdateWorkerState" and use it
+ https://bugs.webkit.org/show_bug.cgi?id=179318
+
+ Reviewed by Chris Dumez.
+
+ * Scripts/webkit/messages.py:
+ (headers_for_type):
+ * Shared/WebCoreArgumentCoders.h:
+
+ * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::updateWorkerStateInClient):
+ (WebKit::WebSWServerConnection::installServiceWorkerContext):
+ (WebKit::WebSWServerConnection::setContextConnection):
+ (WebKit::WebSWServerConnection::updateServiceWorkerContext): Deleted.
+ * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+
+ * WebProcess/Storage/WebSWClientConnection.messages.in:
+
+ * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+ (WebKit::WebSWContextManagerConnection::installServiceWorker):
+ (WebKit::WebSWContextManagerConnection::updateServiceWorker): Deleted.
+ * WebProcess/Storage/WebSWContextManagerConnection.h:
+ * WebProcess/Storage/WebSWContextManagerConnection.messages.in:
+
2017-11-07 Commit Queue <[email protected]>
Unreviewed, rolling out r224512 and r224521.
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (224552 => 224553)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2017-11-07 23:06:55 UTC (rev 224553)
@@ -373,6 +373,7 @@
'WebCore::PolicyAction': ['<WebCore/FrameLoaderTypes.h>'],
'WebCore::RecentSearch': ['<WebCore/SearchPopupMenu.h>'],
'WebCore::ServiceWorkerRegistrationState': ['<WebCore/ServiceWorkerTypes.h>'],
+ 'WebCore::ServiceWorkerState': ['<WebCore/ServiceWorkerTypes.h>'],
'WebCore::ShippingContactUpdate': ['<WebCore/ApplePaySessionPaymentRequest.h>'],
'WebCore::ShippingMethodUpdate': ['<WebCore/ApplePaySessionPaymentRequest.h>'],
'WebCore::ShouldSample': ['<WebCore/DiagnosticLoggingClient.h>'],
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (224552 => 224553)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -815,6 +815,17 @@
WebCore::ServiceWorkerRegistrationState::Active
>;
};
+
+template <> struct EnumTraits<WebCore::ServiceWorkerState> {
+ using values = EnumValues<
+ WebCore::ServiceWorkerState,
+ WebCore::ServiceWorkerState::Installing,
+ WebCore::ServiceWorkerState::Installed,
+ WebCore::ServiceWorkerState::Activating,
+ WebCore::ServiceWorkerState::Activated,
+ WebCore::ServiceWorkerState::Redundant
+ >;
+};
#endif
} // namespace WTF
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (224552 => 224553)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -111,9 +111,14 @@
send(Messages::WebSWClientConnection::FirePostInstallEvents(key));
}
-void WebSWServerConnection::updateServiceWorkerContext(const ServiceWorkerContextData& data)
+void WebSWServerConnection::updateWorkerStateInClient(ServiceWorkerIdentifier worker, ServiceWorkerState state)
{
- if (sendToContextProcess(Messages::WebSWContextManagerConnection::UpdateServiceWorker(identifier(), data)))
+ send(Messages::WebSWClientConnection::UpdateWorkerState(worker, state));
+}
+
+void WebSWServerConnection::installServiceWorkerContext(const ServiceWorkerContextData& data)
+{
+ if (sendToContextProcess(Messages::WebSWContextManagerConnection::InstallServiceWorker(identifier(), data)))
return;
m_pendingContextDatas.append(data);
@@ -188,7 +193,7 @@
// We can now start any pending service worker updates.
for (auto& pendingContextData : m_pendingContextDatas)
- updateServiceWorkerContext(pendingContextData);
+ installServiceWorkerContext(pendingContextData);
m_pendingContextDatas.clear();
}
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (224552 => 224553)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -66,6 +66,7 @@
void resolveUnregistrationJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationKey&, bool unregistrationResult) final;
void startScriptFetchInClient(uint64_t jobIdentifier) final;
void updateRegistrationStateInClient(const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerRegistrationState, std::optional<WebCore::ServiceWorkerIdentifier>) final;
+ void updateWorkerStateInClient(WebCore::ServiceWorkerIdentifier, WebCore::ServiceWorkerState) final;
void fireUpdateFoundEvent(const WebCore::ServiceWorkerRegistrationKey&) final;
void firePostInstallEvents(const WebCore::ServiceWorkerRegistrationKey&) final;
@@ -76,7 +77,7 @@
void matchRegistration(uint64_t registrationMatchRequestIdentifier, const WebCore::SecurityOriginData&, const WebCore::URL& clientURL);
// Messages to the SW context WebProcess
- void updateServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final;
+ void installServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final;
void fireInstallEvent(WebCore::ServiceWorkerIdentifier) final;
IPC::Connection* messageSenderConnection() final { return m_contentConnection.ptr(); }
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in (224552 => 224553)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in 2017-11-07 23:06:55 UTC (rev 224553)
@@ -29,6 +29,7 @@
UnregistrationJobResolvedInServer(uint64_t identifier, bool unregistrationResult)
StartScriptFetchForServer(uint64_t jobIdentifier)
UpdateRegistrationState(WebCore::ServiceWorkerRegistrationKey key, enum WebCore::ServiceWorkerRegistrationState state, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier)
+ UpdateWorkerState(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, enum WebCore::ServiceWorkerState state)
FireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationKey key)
FirePostInstallEvents(WebCore::ServiceWorkerRegistrationKey key)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (224552 => 224553)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2017-11-07 23:06:55 UTC (rev 224553)
@@ -95,7 +95,7 @@
RuntimeEnabledFeatures::sharedFeatures().setFetchAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::fetchAPIEnabledKey()));
}
-void WebSWContextManagerConnection::updateServiceWorker(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
+void WebSWContextManagerConnection::installServiceWorker(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
{
// FIXME: Provide a sensical session ID.
auto sessionID = PAL::SessionID::defaultSessionID();
@@ -114,7 +114,7 @@
pageConfiguration.loaderClientForMainFrame = frameLoaderClient.release();
auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(pageConfiguration), serverConnectionIdentifier, data, sessionID, WebProcess::singleton().cacheStorageProvider());
- SWContextManager::singleton().registerServiceWorkerThreadForUpdate(WTFMove(serviceWorkerThreadProxy));
+ SWContextManager::singleton().registerServiceWorkerThreadForInstall(WTFMove(serviceWorkerThreadProxy));
LOG(ServiceWorker, "Context process PID: %i created worker thread\n", getpid());
}
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h (224552 => 224553)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h 2017-11-07 23:06:55 UTC (rev 224553)
@@ -56,7 +56,7 @@
// IPC messages.
void serviceWorkerStartedWithMessage(WebCore::ServiceWorkerIdentifier, const String& exceptionMessage) final;
- void updateServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
+ void installServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, WebCore::ResourceRequest&&, WebCore::FetchOptions&&);
void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, const WebCore::ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
void fireInstallEvent(uint64_t serverConnectionIdentifier, WebCore::ServiceWorkerIdentifier);
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in (224552 => 224553)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in 2017-11-07 23:04:34 UTC (rev 224552)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in 2017-11-07 23:06:55 UTC (rev 224553)
@@ -23,7 +23,7 @@
#if ENABLE(SERVICE_WORKER)
messages -> WebSWContextManagerConnection {
- UpdateServiceWorker(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData)
+ InstallServiceWorker(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData)
StartFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientIdentifier sourceIdentifier, String sourceOrigin)
FireInstallEvent(uint64_t serverConnectionIdentifier, WebCore::ServiceWorkerIdentifier identifier)