Diff
Added: trunk/LayoutTests/workers/resources/worker-web-lock-released-on-reload-popup.html (0 => 293329)
--- trunk/LayoutTests/workers/resources/worker-web-lock-released-on-reload-popup.html (rev 0)
+++ trunk/LayoutTests/workers/resources/worker-web-lock-released-on-reload-popup.html 2022-04-25 16:10:59 UTC (rev 293329)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+worker = new Worker("worker-web-lock-released-on-reload-worker.js");
+worker._onmessage_ = () => {
+ opener.lockAcquiredByWorker();
+};
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/workers/resources/worker-web-lock-released-on-reload-worker.js (0 => 293329)
--- trunk/LayoutTests/workers/resources/worker-web-lock-released-on-reload-worker.js (rev 0)
+++ trunk/LayoutTests/workers/resources/worker-web-lock-released-on-reload-worker.js 2022-04-25 16:10:59 UTC (rev 293329)
@@ -0,0 +1,7 @@
+navigator.locks.request('worker-lock-123', function() {
+ postMessage('lock acquired from worker');
+
+ return new Promise(resolve => {
+ // Don't release the lock.
+ });
+});
Added: trunk/LayoutTests/workers/worker-web-lock-released-on-reload-expected.txt (0 => 293329)
--- trunk/LayoutTests/workers/worker-web-lock-released-on-reload-expected.txt (rev 0)
+++ trunk/LayoutTests/workers/worker-web-lock-released-on-reload-expected.txt 2022-04-25 16:10:59 UTC (rev 293329)
@@ -0,0 +1,11 @@
+Makes sure that web locks acquired by web workers are released on page reload.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Lock was acquired by the worker
+PASS Lock was acquired by the worker
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/workers/worker-web-lock-released-on-reload.html (0 => 293329)
--- trunk/LayoutTests/workers/worker-web-lock-released-on-reload.html (rev 0)
+++ trunk/LayoutTests/workers/worker-web-lock-released-on-reload.html 2022-04-25 16:10:59 UTC (rev 293329)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Makes sure that web locks acquired by web workers are released on page reload.");
+jsTestIsAsync = true;
+
+var didReloadPopup = false;
+function lockAcquiredByWorker()
+{
+ testPassed("Lock was acquired by the worker");
+ if (didReloadPopup) {
+ setTimeout(finishJSTest, 0);
+ } else {
+ timeoutHandle = setTimeout(() => {
+ clearTimeout(timeoutHandle);
+ testFailed("Worker failed to acquire the lock after a reload");
+ finishJSTest();
+ }, 20000);
+ setTimeout(() => {
+ popup.location.reload();
+ }, 0);
+ didReloadPopup = true;
+ }
+}
+
+popup = open("resources/worker-web-lock-released-on-reload-popup.html");
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/Modules/web-locks/WebLockManager.cpp (293328 => 293329)
--- trunk/Source/WebCore/Modules/web-locks/WebLockManager.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/Modules/web-locks/WebLockManager.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -73,7 +73,11 @@
if (!clientOrigin)
return nullptr;
- return adoptRef(*new MainThreadBridge(*context, WTFMove(*clientOrigin)));
+ auto sessionID = context->sessionID();
+ if (!sessionID)
+ return nullptr;
+
+ return adoptRef(*new MainThreadBridge(*context, *sessionID, WTFMove(*clientOrigin)));
}
void requestLock(WebLockIdentifier, const String& name, const Options&, Function<void(bool)>&&, Function<void()>&& lockStolenHandler);
@@ -83,18 +87,16 @@
void clientIsGoingAway();
private:
- MainThreadBridge(ScriptExecutionContext&, ClientOrigin&&);
+ MainThreadBridge(ScriptExecutionContext&, PAL::SessionID, ClientOrigin&&);
- void ensureOnMainThread(Function<void(WebLockRegistry&)>&& task);
-
- WeakPtr<ScriptExecutionContext> m_context;
const ScriptExecutionContextIdentifier m_clientID;
+ const PAL::SessionID m_sessionID;
const ClientOrigin m_clientOrigin; // Main thread only.
};
-WebLockManager::MainThreadBridge::MainThreadBridge(ScriptExecutionContext& context, ClientOrigin&& clientOrigin)
- : m_context(context)
- , m_clientID(context.identifier())
+WebLockManager::MainThreadBridge::MainThreadBridge(ScriptExecutionContext& context, PAL::SessionID sessionID, ClientOrigin&& clientOrigin)
+ : m_clientID(context.identifier())
+ , m_sessionID(sessionID)
, m_clientOrigin(WTFMove(clientOrigin).isolatedCopy())
{
}
@@ -101,8 +103,8 @@
void WebLockManager::MainThreadBridge::requestLock(WebLockIdentifier lockIdentifier, const String& name, const Options& options, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler)
{
- ensureOnMainThread([this, name = crossThreadCopy(name), mode = options.mode, steal = options.steal, ifAvailable = options.ifAvailable, lockIdentifier, grantedHandler = WTFMove(grantedHandler), lockStolenHandler = WTFMove(lockStolenHandler)](auto& registry) mutable {
- registry.requestLock(m_clientOrigin, lockIdentifier, m_clientID, name, mode, steal, ifAvailable, [clientID = m_clientID, grantedHandler = WTFMove(grantedHandler)] (bool success) mutable {
+ callOnMainThread([this, protectedThis = Ref { *this }, name = crossThreadCopy(name), mode = options.mode, steal = options.steal, ifAvailable = options.ifAvailable, lockIdentifier, grantedHandler = WTFMove(grantedHandler), lockStolenHandler = WTFMove(lockStolenHandler)]() mutable {
+ WebLockRegistry::shared().requestLock(m_sessionID, m_clientOrigin, lockIdentifier, m_clientID, name, mode, steal, ifAvailable, [clientID = m_clientID, grantedHandler = WTFMove(grantedHandler)] (bool success) mutable {
ScriptExecutionContext::ensureOnContextThread(clientID, [grantedHandler = WTFMove(grantedHandler), success](auto&) mutable {
grantedHandler(success);
});
@@ -116,15 +118,15 @@
void WebLockManager::MainThreadBridge::releaseLock(WebLockIdentifier lockIdentifier, const String& name)
{
- ensureOnMainThread([this, lockIdentifier, name = crossThreadCopy(name)](auto& registry) {
- registry.releaseLock(m_clientOrigin, lockIdentifier, m_clientID, name);
+ callOnMainThread([this, protectedThis = Ref { *this }, lockIdentifier, name = crossThreadCopy(name)] {
+ WebLockRegistry::shared().releaseLock(m_sessionID, m_clientOrigin, lockIdentifier, m_clientID, name);
});
}
void WebLockManager::MainThreadBridge::abortLockRequest(WebLockIdentifier lockIdentifier, const String& name, CompletionHandler<void(bool)>&& completionHandler)
{
- ensureOnMainThread([this, lockIdentifier, name = crossThreadCopy(name), completionHandler = WTFMove(completionHandler)](auto& registry) mutable {
- registry.abortLockRequest(m_clientOrigin, lockIdentifier, m_clientID, name, [clientID = m_clientID, completionHandler = WTFMove(completionHandler)](bool wasAborted) mutable {
+ callOnMainThread([this, protectedThis = Ref { *this }, lockIdentifier, name = crossThreadCopy(name), completionHandler = WTFMove(completionHandler)]() mutable {
+ WebLockRegistry::shared().abortLockRequest(m_sessionID, m_clientOrigin, lockIdentifier, m_clientID, name, [clientID = m_clientID, completionHandler = WTFMove(completionHandler)](bool wasAborted) mutable {
ScriptExecutionContext::ensureOnContextThread(clientID, [completionHandler = WTFMove(completionHandler), wasAborted](auto&) mutable {
completionHandler(wasAborted);
});
@@ -134,8 +136,8 @@
void WebLockManager::MainThreadBridge::query(CompletionHandler<void(Snapshot&&)>&& completionHandler)
{
- ensureOnMainThread([this, completionHandler = WTFMove(completionHandler)](auto& registry) mutable {
- registry.snapshot(m_clientOrigin, [clientID = m_clientID, completionHandler = WTFMove(completionHandler)](Snapshot&& snapshot) mutable {
+ callOnMainThread([this, protectedThis = Ref { *this }, completionHandler = WTFMove(completionHandler)]() mutable {
+ WebLockRegistry::shared().snapshot(m_sessionID, m_clientOrigin, [clientID = m_clientID, completionHandler = WTFMove(completionHandler)](Snapshot&& snapshot) mutable {
ScriptExecutionContext::ensureOnContextThread(clientID, [completionHandler = WTFMove(completionHandler), snapshot = crossThreadCopy(snapshot)](auto&) mutable {
completionHandler(WTFMove(snapshot));
});
@@ -145,30 +147,11 @@
void WebLockManager::MainThreadBridge::clientIsGoingAway()
{
- ensureOnMainThread([this](auto& registry) {
- registry.clientIsGoingAway(m_clientOrigin, m_clientID);
+ callOnMainThread([this, protectedThis = Ref { *this }] {
+ WebLockRegistry::shared().clientIsGoingAway(m_sessionID, m_clientOrigin, m_clientID);
});
}
-void WebLockManager::MainThreadBridge::ensureOnMainThread(Function<void(WebLockRegistry&)>&& task)
-{
- if (!m_context)
- return;
- ASSERT(m_context->isContextThread());
-
- if (is<Document>(*m_context)) {
- if (auto page = downcast<Document>(*m_context).page()) {
- Ref protectedThis { *this };
- task(page->webLockRegistry());
- }
- } else {
- downcast<WorkerGlobalScope>(*m_context).thread().workerLoaderProxy().postTaskToLoader([task = WTFMove(task), protectedThis = Ref { *this }](auto& context) {
- if (auto page = downcast<Document>(context).page())
- task(page->webLockRegistry());
- });
- }
-}
-
Ref<WebLockManager> WebLockManager::create(NavigatorBase& navigator)
{
auto manager = adoptRef(*new WebLockManager(navigator));
Modified: trunk/Source/WebCore/Modules/web-locks/WebLockRegistry.cpp (293328 => 293329)
--- trunk/Source/WebCore/Modules/web-locks/WebLockRegistry.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/Modules/web-locks/WebLockRegistry.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -35,9 +35,29 @@
namespace WebCore {
+static RefPtr<WebLockRegistry>& sharedRegistry()
+{
+ static MainThreadNeverDestroyed<RefPtr<WebLockRegistry>> registry;
+ return registry;
+}
+
+WebLockRegistry& WebLockRegistry::shared()
+{
+ auto& registry = sharedRegistry();
+ if (!registry)
+ registry= LocalWebLockRegistry::create();
+ return *registry;
+}
+
+void WebLockRegistry::setSharedRegistry(Ref<WebLockRegistry>&& registry)
+{
+ ASSERT(!sharedRegistry());
+ sharedRegistry() = WTFMove(registry);
+}
+
class LocalWebLockRegistry::PerOriginRegistry : public RefCounted<PerOriginRegistry>, public CanMakeWeakPtr<PerOriginRegistry> {
public:
- static Ref<PerOriginRegistry> create(LocalWebLockRegistry&, const ClientOrigin&);
+ static Ref<PerOriginRegistry> create(LocalWebLockRegistry&, PAL::SessionID, const ClientOrigin&);
~PerOriginRegistry();
struct LockInfo {
@@ -55,7 +75,7 @@
void clientsAreGoingAway(const Function<bool(const LockInfo&)>& matchClient);
private:
- PerOriginRegistry(LocalWebLockRegistry&, const ClientOrigin&);
+ PerOriginRegistry(LocalWebLockRegistry&, PAL::SessionID, const ClientOrigin&);
struct LockRequest : LockInfo {
String name;
@@ -66,6 +86,7 @@
bool isGrantable(const LockRequest&) const;
WeakPtr<LocalWebLockRegistry> m_globalRegistry;
+ PAL::SessionID m_sessionID;
ClientOrigin m_clientOrigin;
FastRobinHoodHashMap<String, Deque<LockRequest>> m_lockRequestQueueMap;
FastRobinHoodHashMap<String, Vector<LockInfo>> m_heldLocks;
@@ -75,40 +96,41 @@
LocalWebLockRegistry::~LocalWebLockRegistry() = default;
-auto LocalWebLockRegistry::ensureRegistryForOrigin(const ClientOrigin& clientOrigin) -> Ref<PerOriginRegistry>
+auto LocalWebLockRegistry::ensureRegistryForOrigin(PAL::SessionID sessionID, const ClientOrigin& clientOrigin) -> Ref<PerOriginRegistry>
{
- if (auto existingRegistry = m_perOriginRegistries.get(clientOrigin))
+ if (auto existingRegistry = m_perOriginRegistries.get({ sessionID, clientOrigin }))
return *existingRegistry;
- return PerOriginRegistry::create(*this, clientOrigin);
+ return PerOriginRegistry::create(*this, sessionID, clientOrigin);
}
-auto LocalWebLockRegistry::existingRegistryForOrigin(const ClientOrigin& clientOrigin) const -> RefPtr<PerOriginRegistry>
+auto LocalWebLockRegistry::existingRegistryForOrigin(PAL::SessionID sessionID, const ClientOrigin& clientOrigin) const -> RefPtr<PerOriginRegistry>
{
- return m_perOriginRegistries.get(clientOrigin).get();
+ return m_perOriginRegistries.get({ sessionID, clientOrigin }).get();
}
-Ref<LocalWebLockRegistry::PerOriginRegistry> LocalWebLockRegistry::PerOriginRegistry::create(LocalWebLockRegistry& globalRegistry, const ClientOrigin& clientOrigin)
+Ref<LocalWebLockRegistry::PerOriginRegistry> LocalWebLockRegistry::PerOriginRegistry::create(LocalWebLockRegistry& globalRegistry, PAL::SessionID sessionID, const ClientOrigin& clientOrigin)
{
- return adoptRef(*new PerOriginRegistry(globalRegistry, clientOrigin));
+ return adoptRef(*new PerOriginRegistry(globalRegistry, sessionID, clientOrigin));
}
-LocalWebLockRegistry::PerOriginRegistry::PerOriginRegistry(LocalWebLockRegistry& globalRegistry, const ClientOrigin& clientOrigin)
+LocalWebLockRegistry::PerOriginRegistry::PerOriginRegistry(LocalWebLockRegistry& globalRegistry, PAL::SessionID sessionID, const ClientOrigin& clientOrigin)
: m_globalRegistry(globalRegistry)
+ , m_sessionID(sessionID)
, m_clientOrigin(clientOrigin)
{
- globalRegistry.m_perOriginRegistries.add(clientOrigin, WeakPtr { * this });
+ globalRegistry.m_perOriginRegistries.add({ sessionID, clientOrigin }, WeakPtr { * this });
}
LocalWebLockRegistry::PerOriginRegistry::~PerOriginRegistry()
{
if (m_globalRegistry)
- m_globalRegistry->m_perOriginRegistries.remove(m_clientOrigin);
+ m_globalRegistry->m_perOriginRegistries.remove({ m_sessionID, m_clientOrigin });
}
-void LocalWebLockRegistry::requestLock(const ClientOrigin& clientOrigin, WebLockIdentifier lockIdentifier, ScriptExecutionContextIdentifier clientID, const String& name, WebLockMode mode, bool steal, bool ifAvailable, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler)
+void LocalWebLockRegistry::requestLock(PAL::SessionID sessionID, const ClientOrigin& clientOrigin, WebLockIdentifier lockIdentifier, ScriptExecutionContextIdentifier clientID, const String& name, WebLockMode mode, bool steal, bool ifAvailable, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler)
{
- ensureRegistryForOrigin(clientOrigin)->requestLock(lockIdentifier, clientID, name, mode, steal, ifAvailable, WTFMove(grantedHandler), WTFMove(lockStolenHandler));
+ ensureRegistryForOrigin(sessionID, clientOrigin)->requestLock(lockIdentifier, clientID, name, mode, steal, ifAvailable, WTFMove(grantedHandler), WTFMove(lockStolenHandler));
}
// https://wicg.github.io/web-locks/#request-a-lock
@@ -135,9 +157,9 @@
processLockRequestQueue(name, queue);
}
-void LocalWebLockRegistry::releaseLock(const ClientOrigin& clientOrigin, WebLockIdentifier lockIdentifier, ScriptExecutionContextIdentifier, const String& name)
+void LocalWebLockRegistry::releaseLock(PAL::SessionID sessionID, const ClientOrigin& clientOrigin, WebLockIdentifier lockIdentifier, ScriptExecutionContextIdentifier, const String& name)
{
- if (auto registry = existingRegistryForOrigin(clientOrigin))
+ if (auto registry = existingRegistryForOrigin(sessionID, clientOrigin))
registry->releaseLock(lockIdentifier, name);
}
@@ -158,9 +180,9 @@
processLockRequestQueue(name, queueIterator->value);
}
-void LocalWebLockRegistry::abortLockRequest(const ClientOrigin& clientOrigin, WebLockIdentifier lockIdentifier, ScriptExecutionContextIdentifier, const String& name, CompletionHandler<void(bool)>&& completionHandler)
+void LocalWebLockRegistry::abortLockRequest(PAL::SessionID sessionID, const ClientOrigin& clientOrigin, WebLockIdentifier lockIdentifier, ScriptExecutionContextIdentifier, const String& name, CompletionHandler<void(bool)>&& completionHandler)
{
- auto registry = existingRegistryForOrigin(clientOrigin);
+ auto registry = existingRegistryForOrigin(sessionID, clientOrigin);
if (!registry)
return completionHandler(false);
@@ -222,9 +244,9 @@
ASSERT_UNUSED(removedQueue, removedQueue.isEmpty());
}
-void LocalWebLockRegistry::snapshot(const ClientOrigin& clientOrigin, CompletionHandler<void(WebLockManager::Snapshot&&)>&& completionHandler)
+void LocalWebLockRegistry::snapshot(PAL::SessionID sessionID, const ClientOrigin& clientOrigin, CompletionHandler<void(WebLockManager::Snapshot&&)>&& completionHandler)
{
- auto registry = existingRegistryForOrigin(clientOrigin);
+ auto registry = existingRegistryForOrigin(sessionID, clientOrigin);
if (!registry)
return completionHandler({ });
@@ -247,9 +269,9 @@
completionHandler(WTFMove(snapshot));
}
-void LocalWebLockRegistry::clientIsGoingAway(const ClientOrigin& clientOrigin, ScriptExecutionContextIdentifier clientID)
+void LocalWebLockRegistry::clientIsGoingAway(PAL::SessionID sessionID, const ClientOrigin& clientOrigin, ScriptExecutionContextIdentifier clientID)
{
- if (auto registry = existingRegistryForOrigin(clientOrigin))
+ if (auto registry = existingRegistryForOrigin(sessionID, clientOrigin))
registry->clientsAreGoingAway([clientID](auto& lockInfo) { return lockInfo.clientID == clientID; });
}
@@ -291,9 +313,9 @@
void LocalWebLockRegistry::clientsAreGoingAway(ProcessIdentifier processIdentifier)
{
- Vector<ClientOrigin> clientOrigins = copyToVector(m_perOriginRegistries.keys());
- for (auto& clientOrigin : clientOrigins) {
- if (auto registry = existingRegistryForOrigin(clientOrigin))
+ Vector<std::pair<PAL::SessionID, ClientOrigin>> clientOrigins = copyToVector(m_perOriginRegistries.keys());
+ for (auto& [sessionID, clientOrigin] : clientOrigins) {
+ if (auto registry = existingRegistryForOrigin(sessionID, clientOrigin))
registry->clientsAreGoingAway([processIdentifier](auto& lockInfo) { return lockInfo.clientID.processIdentifier() == processIdentifier; });
}
}
Modified: trunk/Source/WebCore/Modules/web-locks/WebLockRegistry.h (293328 => 293329)
--- trunk/Source/WebCore/Modules/web-locks/WebLockRegistry.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/Modules/web-locks/WebLockRegistry.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -29,6 +29,7 @@
#include "ScriptExecutionContextIdentifier.h"
#include "WebLockIdentifier.h"
#include "WebLockMode.h"
+#include <pal/SessionID.h>
#include <wtf/Deque.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
@@ -42,13 +43,16 @@
class WebLockRegistry : public RefCounted<WebLockRegistry> {
public:
+ static WebLockRegistry& shared();
+ WEBCORE_EXPORT static void setSharedRegistry(Ref<WebLockRegistry>&&);
+
virtual ~WebLockRegistry() { }
- virtual void requestLock(const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name, WebLockMode, bool steal, bool ifAvailable, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler) = 0;
- virtual void releaseLock(const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name) = 0;
- virtual void abortLockRequest(const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name, CompletionHandler<void(bool)>&&) = 0;
- virtual void snapshot(const ClientOrigin&, CompletionHandler<void(WebLockManagerSnapshot&&)>&&) = 0;
- virtual void clientIsGoingAway(const ClientOrigin&, ScriptExecutionContextIdentifier) = 0;
+ virtual void requestLock(PAL::SessionID, const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name, WebLockMode, bool steal, bool ifAvailable, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler) = 0;
+ virtual void releaseLock(PAL::SessionID, const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name) = 0;
+ virtual void abortLockRequest(PAL::SessionID, const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name, CompletionHandler<void(bool)>&&) = 0;
+ virtual void snapshot(PAL::SessionID, const ClientOrigin&, CompletionHandler<void(WebLockManagerSnapshot&&)>&&) = 0;
+ virtual void clientIsGoingAway(PAL::SessionID, const ClientOrigin&, ScriptExecutionContextIdentifier) = 0;
protected:
WebLockRegistry() = default;
@@ -59,11 +63,11 @@
static Ref<LocalWebLockRegistry> create() { return adoptRef(*new LocalWebLockRegistry); }
~LocalWebLockRegistry();
- WEBCORE_EXPORT void requestLock(const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name, WebLockMode, bool steal, bool ifAvailable, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler) final;
- WEBCORE_EXPORT void releaseLock(const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name) final;
- WEBCORE_EXPORT void abortLockRequest(const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name, CompletionHandler<void(bool)>&&) final;
- WEBCORE_EXPORT void snapshot(const ClientOrigin&, CompletionHandler<void(WebLockManagerSnapshot&&)>&&) final;
- WEBCORE_EXPORT void clientIsGoingAway(const ClientOrigin&, ScriptExecutionContextIdentifier) final;
+ WEBCORE_EXPORT void requestLock(PAL::SessionID, const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name, WebLockMode, bool steal, bool ifAvailable, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler) final;
+ WEBCORE_EXPORT void releaseLock(PAL::SessionID, const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name) final;
+ WEBCORE_EXPORT void abortLockRequest(PAL::SessionID, const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String& name, CompletionHandler<void(bool)>&&) final;
+ WEBCORE_EXPORT void snapshot(PAL::SessionID, const ClientOrigin&, CompletionHandler<void(WebLockManagerSnapshot&&)>&&) final;
+ WEBCORE_EXPORT void clientIsGoingAway(PAL::SessionID, const ClientOrigin&, ScriptExecutionContextIdentifier) final;
WEBCORE_EXPORT void clientsAreGoingAway(ProcessIdentifier);
private:
@@ -70,10 +74,10 @@
WEBCORE_EXPORT LocalWebLockRegistry();
class PerOriginRegistry;
- Ref<PerOriginRegistry> ensureRegistryForOrigin(const ClientOrigin&);
- RefPtr<PerOriginRegistry> existingRegistryForOrigin(const ClientOrigin&) const;
+ Ref<PerOriginRegistry> ensureRegistryForOrigin(PAL::SessionID, const ClientOrigin&);
+ RefPtr<PerOriginRegistry> existingRegistryForOrigin(PAL::SessionID, const ClientOrigin&) const;
- HashMap<ClientOrigin, WeakPtr<PerOriginRegistry>> m_perOriginRegistries;
+ HashMap<std::pair<PAL::SessionID, ClientOrigin>, WeakPtr<PerOriginRegistry>> m_perOriginRegistries;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp (293328 => 293329)
--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -49,6 +49,7 @@
{
auto* document = worklet.document();
auto jsRuntimeFlags = document->settings()._javascript_RuntimeFlags();
+ RELEASE_ASSERT(document->sessionID());
return {
document->url(),
@@ -55,6 +56,7 @@
jsRuntimeFlags,
worklet.audioContext() ? worklet.audioContext()->sampleRate() : 0.0f,
worklet.identifier(),
+ *document->sessionID(),
document->settingsValues(),
worklet.audioContext() ? !worklet.audioContext()->isOfflineContext() : false
};
Modified: trunk/Source/WebCore/dom/Document.h (293328 => 293329)
--- trunk/Source/WebCore/dom/Document.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/dom/Document.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -1683,6 +1683,8 @@
void addElementWithPendingUserAgentShadowTreeUpdate(Element&);
WEBCORE_EXPORT void removeElementWithPendingUserAgentShadowTreeUpdate(Element&);
+ std::optional<PAL::SessionID> sessionID() const final;
+
protected:
enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
WEBCORE_EXPORT Document(Frame*, const Settings&, const URL&, DocumentClasses = { }, unsigned constructionFlags = 0, ScriptExecutionContextIdentifier = { });
@@ -1805,7 +1807,6 @@
void removeFromDocumentsMap();
NotificationClient* notificationClient() final;
- std::optional<PAL::SessionID> sessionID() const final;
const Ref<const Settings> m_settings;
Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (293328 => 293329)
--- trunk/Source/WebCore/loader/EmptyClients.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -82,7 +82,6 @@
#include "ThreadableWebSocketChannel.h"
#include "UserContentProvider.h"
#include "VisitedLinkStore.h"
-#include "WebLockRegistry.h"
#include <_javascript_Core/HeapInlines.h>
#include <pal/SessionID.h>
#include <wtf/NeverDestroyed.h>
@@ -1192,20 +1191,6 @@
void postMessage(const PartitionedSecurityOrigin&, const String&, BroadcastChannelIdentifier, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) final { }
};
-class EmptyWebLockRegistry final : public WebLockRegistry {
-public:
- static Ref<EmptyWebLockRegistry> create()
- {
- return adoptRef(*new EmptyWebLockRegistry);
- }
-private:
- void requestLock(const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String&, WebLockMode, bool, bool, Function<void(bool)>&&, Function<void()>&&) { }
- void releaseLock(const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String&) final { }
- void abortLockRequest(const ClientOrigin&, WebLockIdentifier, ScriptExecutionContextIdentifier, const String&, CompletionHandler<void(bool)>&&) final { }
- void snapshot(const ClientOrigin&, CompletionHandler<void(WebLockManagerSnapshot&&)>&&) { }
- void clientIsGoingAway(const ClientOrigin&, ScriptExecutionContextIdentifier) { }
-};
-
PageConfiguration pageConfigurationWithEmptyClients(PAL::SessionID sessionID)
{
PageConfiguration pageConfiguration {
@@ -1222,7 +1207,6 @@
makeUniqueRef<DummySpeechRecognitionProvider>(),
makeUniqueRef<EmptyMediaRecorderProvider>(),
EmptyBroadcastChannelRegistry::create(),
- EmptyWebLockRegistry::create(),
DummyPermissionController::create(),
makeUniqueRef<DummyStorageProvider>(),
makeUniqueRef<DummyModelPlayerProvider>()
Modified: trunk/Source/WebCore/page/Page.cpp (293328 => 293329)
--- trunk/Source/WebCore/page/Page.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/page/Page.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -164,7 +164,6 @@
#include "VisitedLinkStore.h"
#include "VoidCallback.h"
#include "WebCoreJSClientData.h"
-#include "WebLockRegistry.h"
#include "WheelEventDeltaFilter.h"
#include "WheelEventTestMonitor.h"
#include "Widget.h"
@@ -312,7 +311,6 @@
, m_userContentProvider(WTFMove(pageConfiguration.userContentProvider))
, m_visitedLinkStore(*WTFMove(pageConfiguration.visitedLinkStore))
, m_broadcastChannelRegistry(WTFMove(pageConfiguration.broadcastChannelRegistry))
- , m_webLockRegistry(WTFMove(pageConfiguration.webLockRegistry))
, m_sessionID(pageConfiguration.sessionID)
#if ENABLE(VIDEO)
, m_playbackControlsManagerUpdateTimer(*this, &Page::playbackControlsManagerUpdateTimerFired)
Modified: trunk/Source/WebCore/page/Page.h (293328 => 293329)
--- trunk/Source/WebCore/page/Page.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/page/Page.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -171,7 +171,6 @@
class VisibleSelection;
class VisitedLinkStore;
class WebGLStateTracker;
-class WebLockRegistry;
class WheelEventDeltaFilter;
class WheelEventTestMonitor;
@@ -308,8 +307,6 @@
BroadcastChannelRegistry& broadcastChannelRegistry() { return m_broadcastChannelRegistry; }
WEBCORE_EXPORT void setBroadcastChannelRegistry(Ref<BroadcastChannelRegistry>&&); // Only used by WebKitLegacy.
- WebLockRegistry& webLockRegistry() { return m_webLockRegistry; }
-
WEBCORE_EXPORT static void forEachPage(const Function<void(Page&)>&);
WEBCORE_EXPORT static unsigned nonUtilityPageCount();
@@ -1182,7 +1179,6 @@
Ref<UserContentProvider> m_userContentProvider;
Ref<VisitedLinkStore> m_visitedLinkStore;
Ref<BroadcastChannelRegistry> m_broadcastChannelRegistry;
- Ref<WebLockRegistry> m_webLockRegistry;
RefPtr<WheelEventTestMonitor> m_wheelEventTestMonitor;
WeakHashSet<ActivityStateChangeObserver> m_activityStateChangeObservers;
Modified: trunk/Source/WebCore/page/PageConfiguration.cpp (293328 => 293329)
--- trunk/Source/WebCore/page/PageConfiguration.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/page/PageConfiguration.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -54,7 +54,6 @@
#include "UserContentURLPattern.h"
#include "ValidationMessageClient.h"
#include "VisitedLinkStore.h"
-#include "WebLockRegistry.h"
#if ENABLE(WEBGL)
#include "WebGLStateTracker.h"
#endif
@@ -64,7 +63,7 @@
namespace WebCore {
-PageConfiguration::PageConfiguration(PAL::SessionID sessionID, UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider, Ref<UserContentProvider>&& userContentProvider, Ref<BackForwardClient>&& backForwardClient, Ref<CookieJar>&& cookieJar, UniqueRef<ProgressTrackerClient>&& progressTrackerClient, UniqueRef<FrameLoaderClient>&& loaderClientForMainFrame, UniqueRef<SpeechRecognitionProvider>&& speechRecognitionProvider, UniqueRef<MediaRecorderProvider>&& mediaRecorderProvider, Ref<BroadcastChannelRegistry>&& broadcastChannelRegistry, Ref<WebLockRegistry>&& webLockRegistry, Ref<PermissionController>&& permissionController, UniqueRef<StorageProvider>&&
; storageProvider, UniqueRef<ModelPlayerProvider>&& modelPlayerProvider)
+PageConfiguration::PageConfiguration(PAL::SessionID sessionID, UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider, Ref<UserContentProvider>&& userContentProvider, Ref<BackForwardClient>&& backForwardClient, Ref<CookieJar>&& cookieJar, UniqueRef<ProgressTrackerClient>&& progressTrackerClient, UniqueRef<FrameLoaderClient>&& loaderClientForMainFrame, UniqueRef<SpeechRecognitionProvider>&& speechRecognitionProvider, UniqueRef<MediaRecorderProvider>&& mediaRecorderProvider, Ref<BroadcastChannelRegistry>&& broadcastChannelRegistry, Ref<PermissionController>&& permissionController, UniqueRef<StorageProvider>&& storageProvider, UniqueRef<ModelPlayerProvider>
&& modelPlayerProvider)
: sessionID(sessionID)
, editorClient(WTFMove(editorClient))
, socketProvider(WTFMove(socketProvider))
@@ -76,7 +75,6 @@
, cacheStorageProvider(WTFMove(cacheStorageProvider))
, userContentProvider(WTFMove(userContentProvider))
, broadcastChannelRegistry(WTFMove(broadcastChannelRegistry))
- , webLockRegistry(WTFMove(webLockRegistry))
, speechRecognitionProvider(WTFMove(speechRecognitionProvider))
, mediaRecorderProvider(WTFMove(mediaRecorderProvider))
, permissionController(WTFMove(permissionController))
Modified: trunk/Source/WebCore/page/PageConfiguration.h (293328 => 293329)
--- trunk/Source/WebCore/page/PageConfiguration.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/page/PageConfiguration.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -80,12 +80,11 @@
class ValidationMessageClient;
class VisitedLinkStore;
class WebGLStateTracker;
-class WebLockRegistry;
class PageConfiguration {
WTF_MAKE_NONCOPYABLE(PageConfiguration); WTF_MAKE_FAST_ALLOCATED;
public:
- WEBCORE_EXPORT PageConfiguration(PAL::SessionID, UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&, Ref<UserContentProvider>&&, Ref<BackForwardClient>&&, Ref<CookieJar>&&, UniqueRef<ProgressTrackerClient>&&, UniqueRef<FrameLoaderClient>&&, UniqueRef<SpeechRecognitionProvider>&&, UniqueRef<MediaRecorderProvider>&&, Ref<BroadcastChannelRegistry>&&, Ref<WebLockRegistry>&&, Ref<PermissionController>&&, UniqueRef<StorageProvider>&&, UniqueRef<ModelPlayerProvider>&&);
+ WEBCORE_EXPORT PageConfiguration(PAL::SessionID, UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&, Ref<UserContentProvider>&&, Ref<BackForwardClient>&&, Ref<CookieJar>&&, UniqueRef<ProgressTrackerClient>&&, UniqueRef<FrameLoaderClient>&&, UniqueRef<SpeechRecognitionProvider>&&, UniqueRef<MediaRecorderProvider>&&, Ref<BroadcastChannelRegistry>&&, Ref<PermissionController>&&, UniqueRef<StorageProvider>&&, UniqueRef<ModelPlayerProvider>&&);
WEBCORE_EXPORT ~PageConfiguration();
PageConfiguration(PageConfiguration&&);
@@ -135,7 +134,6 @@
Ref<UserContentProvider> userContentProvider;
RefPtr<VisitedLinkStore> visitedLinkStore;
Ref<BroadcastChannelRegistry> broadcastChannelRegistry;
- Ref<WebLockRegistry> webLockRegistry;
#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
RefPtr<DeviceOrientationUpdateProvider> deviceOrientationUpdateProvider;
Modified: trunk/Source/WebCore/workers/Worker.cpp (293328 => 293329)
--- trunk/Source/WebCore/workers/Worker.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/Worker.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -205,6 +205,10 @@
if (!context)
return;
+ auto sessionID = context->sessionID();
+ if (!sessionID)
+ return;
+
if (m_scriptLoader->failed()) {
queueTaskToDispatchEvent(*this, TaskSource::DOMManipulation, Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::Yes));
return;
@@ -222,7 +226,7 @@
m_clientIdentifier,
context->userAgent(m_scriptLoader->lastRequestURL())
};
- m_contextProxy.startWorkerGlobalScope(m_scriptLoader->lastRequestURL(), m_options.name, WTFMove(initializationData), m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_scriptLoader->crossOriginEmbedderPolicy(), m_workerCreationTime, referrerPolicy, m_options.type, m_options.credentials, m_runtimeFlags);
+ m_contextProxy.startWorkerGlobalScope(m_scriptLoader->lastRequestURL(), *sessionID, m_options.name, WTFMove(initializationData), m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_scriptLoader->crossOriginEmbedderPolicy(), m_workerCreationTime, referrerPolicy, m_options.type, m_options.credentials, m_runtimeFlags);
InspectorInstrumentation::scriptImported(*context, m_scriptLoader->identifier(), m_scriptLoader->script().toString());
}
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (293328 => 293329)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -93,7 +93,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(WorkerGlobalScope);
WorkerGlobalScope::WorkerGlobalScope(WorkerThreadType type, const WorkerParameters& params, Ref<SecurityOrigin>&& origin, WorkerThread& thread, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)
- : WorkerOrWorkletGlobalScope(type, isMainThread() ? Ref { commonVM() } : JSC::VM::create(), &thread, params.clientIdentifier)
+ : WorkerOrWorkletGlobalScope(type, params.sessionID, isMainThread() ? Ref { commonVM() } : JSC::VM::create(), &thread, params.clientIdentifier)
, m_url(params.scriptURL)
, m_inspectorIdentifier(params.inspectorIdentifier)
, m_userAgent(params.userAgent)
Modified: trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h (293328 => 293329)
--- trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -52,7 +52,7 @@
public:
static WorkerGlobalScopeProxy& create(Worker&);
- virtual void startWorkerGlobalScope(const URL& scriptURL, const String& name, WorkerInitializationData&&, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const CrossOriginEmbedderPolicy&, MonotonicTime timeOrigin, ReferrerPolicy, WorkerType, FetchRequestCredentials, JSC::RuntimeFlags) = 0;
+ virtual void startWorkerGlobalScope(const URL& scriptURL, PAL::SessionID, const String& name, WorkerInitializationData&&, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const CrossOriginEmbedderPolicy&, MonotonicTime timeOrigin, ReferrerPolicy, WorkerType, FetchRequestCredentials, JSC::RuntimeFlags) = 0;
virtual void terminateWorkerGlobalScope() = 0;
virtual void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) = 0;
virtual void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&) = 0;
Modified: trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp (293328 => 293329)
--- trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -78,7 +78,7 @@
|| (is<WorkerGlobalScope>(*m_scriptExecutionContext) && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().thread() == &Thread::current()));
}
-void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& name, WorkerInitializationData&& initializationData, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const CrossOriginEmbedderPolicy& crossOriginEmbedderPolicy, MonotonicTime timeOrigin, ReferrerPolicy referrerPolicy, WorkerType workerType, FetchRequestCredentials credentials, JSC::RuntimeFlags runtimeFlags)
+void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, PAL::SessionID sessionID, const String& name, WorkerInitializationData&& initializationData, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const CrossOriginEmbedderPolicy& crossOriginEmbedderPolicy, MonotonicTime timeOrigin, ReferrerPolicy referrerPolicy, WorkerType workerType, FetchRequestCredentials credentials, JSC::RuntimeFlags runtimeFlags)
{
// FIXME: This need to be revisited when we support nested worker one day
ASSERT(m_scriptExecutionContext);
@@ -90,7 +90,7 @@
SocketProvider* socketProvider = document.socketProvider();
- WorkerParameters params { scriptURL, name, identifier, WTFMove(initializationData.userAgent), platformStrategies()->loaderStrategy()->isOnLine(), contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, crossOriginEmbedderPolicy, timeOrigin, referrerPolicy, workerType, credentials, document.settingsValues(), WorkerThreadMode::CreateNewThread, { },
+ WorkerParameters params { scriptURL, name, identifier, WTFMove(initializationData.userAgent), platformStrategies()->loaderStrategy()->isOnLine(), contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, crossOriginEmbedderPolicy, timeOrigin, referrerPolicy, workerType, credentials, document.settingsValues(), WorkerThreadMode::CreateNewThread, sessionID,
#if ENABLE(SERVICE_WORKER)
WTFMove(initializationData.serviceWorkerData),
#endif
Modified: trunk/Source/WebCore/workers/WorkerMessagingProxy.h (293328 => 293329)
--- trunk/Source/WebCore/workers/WorkerMessagingProxy.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/WorkerMessagingProxy.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -50,7 +50,7 @@
private:
// Implementations of WorkerGlobalScopeProxy.
// (Only use these functions in the worker object thread.)
- void startWorkerGlobalScope(const URL& scriptURL, const String& name, WorkerInitializationData&&, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const CrossOriginEmbedderPolicy&, MonotonicTime timeOrigin, ReferrerPolicy, WorkerType, FetchRequestCredentials, JSC::RuntimeFlags) final;
+ void startWorkerGlobalScope(const URL& scriptURL, PAL::SessionID, const String& name, WorkerInitializationData&&, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const CrossOriginEmbedderPolicy&, MonotonicTime timeOrigin, ReferrerPolicy, WorkerType, FetchRequestCredentials, JSC::RuntimeFlags) final;
void terminateWorkerGlobalScope() final;
void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final;
void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&) final;
Modified: trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.cpp (293328 => 293329)
--- trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -40,12 +40,13 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(WorkerOrWorkletGlobalScope);
-WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope(WorkerThreadType type, Ref<JSC::VM>&& vm, WorkerOrWorkletThread* thread, ScriptExecutionContextIdentifier contextIdentifier)
+WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope(WorkerThreadType type, PAL::SessionID sessionID, Ref<JSC::VM>&& vm, WorkerOrWorkletThread* thread, ScriptExecutionContextIdentifier contextIdentifier)
: ScriptExecutionContext(contextIdentifier)
, m_script(makeUnique<WorkerOrWorkletScriptController>(type, WTFMove(vm), this))
, m_moduleLoader(makeUnique<ScriptModuleLoader>(*this, ScriptModuleLoader::OwnerType::WorkerOrWorklet))
, m_thread(thread)
, m_inspectorController(makeUnique<WorkerInspectorController>(*this))
+ , m_sessionID(sessionID)
{
}
Modified: trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h (293328 => 293329)
--- trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -64,6 +64,7 @@
EventLoopTaskGroup& eventLoop() final;
bool isContextThread() const final;
void postTask(Task&&) final; // Executes the task on context's thread asynchronously.
+ std::optional<PAL::SessionID> sessionID() const final { return m_sessionID; }
// Defined specifcially for WorkerOrWorkletGlobalScope for cooperation with
// WorkerEventLoop and WorkerRunLoop, not part of ScriptExecutionContext.
@@ -80,7 +81,7 @@
virtual FetchOptions::Destination destination() const = 0;
protected:
- WorkerOrWorkletGlobalScope(WorkerThreadType, Ref<JSC::VM>&&, WorkerOrWorkletThread*, ScriptExecutionContextIdentifier = { });
+ WorkerOrWorkletGlobalScope(WorkerThreadType, PAL::SessionID, Ref<JSC::VM>&&, WorkerOrWorkletThread*, ScriptExecutionContextIdentifier = { });
// ScriptExecutionContext.
bool isJSExecutionForbidden() const final;
@@ -108,6 +109,7 @@
RefPtr<WorkerEventLoop> m_eventLoop;
std::unique_ptr<EventLoopTaskGroup> m_defaultTaskGroup;
std::unique_ptr<WorkerInspectorController> m_inspectorController;
+ PAL::SessionID m_sessionID;
bool m_isClosing { false };
};
Modified: trunk/Source/WebCore/workers/WorkerThread.h (293328 => 293329)
--- trunk/Source/WebCore/workers/WorkerThread.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/WorkerThread.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -77,7 +77,7 @@
FetchRequestCredentials credentials;
Settings::Values settingsValues;
WorkerThreadMode workerThreadMode { WorkerThreadMode::CreateNewThread };
- std::optional<PAL::SessionID> sessionID { std::nullopt };
+ PAL::SessionID sessionID;
#if ENABLE(SERVICE_WORKER)
std::optional<ServiceWorkerData> serviceWorkerData;
#endif
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp (293328 => 293329)
--- trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -52,21 +52,20 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(ServiceWorkerGlobalScope);
-Ref<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::create(ServiceWorkerContextData&& contextData, ServiceWorkerData&& workerData, const WorkerParameters& params, Ref<SecurityOrigin>&& origin, ServiceWorkerThread& thread, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, std::unique_ptr<NotificationClient>&& notificationClient, PAL::SessionID sessionID)
+Ref<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::create(ServiceWorkerContextData&& contextData, ServiceWorkerData&& workerData, const WorkerParameters& params, Ref<SecurityOrigin>&& origin, ServiceWorkerThread& thread, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, std::unique_ptr<NotificationClient>&& notificationClient)
{
- auto scope = adoptRef(*new ServiceWorkerGlobalScope { WTFMove(contextData), WTFMove(workerData), params, WTFMove(origin), thread, WTFMove(topOrigin), connectionProxy, socketProvider, WTFMove(notificationClient), sessionID });
+ auto scope = adoptRef(*new ServiceWorkerGlobalScope { WTFMove(contextData), WTFMove(workerData), params, WTFMove(origin), thread, WTFMove(topOrigin), connectionProxy, socketProvider, WTFMove(notificationClient) });
scope->applyContentSecurityPolicyResponseHeaders(params.contentSecurityPolicyResponseHeaders);
scope->notifyServiceWorkerPageOfCreationIfNecessary();
return scope;
}
-ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(ServiceWorkerContextData&& contextData, ServiceWorkerData&& workerData, const WorkerParameters& params, Ref<SecurityOrigin>&& origin, ServiceWorkerThread& thread, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, std::unique_ptr<NotificationClient>&& notificationClient, PAL::SessionID sessionID)
+ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(ServiceWorkerContextData&& contextData, ServiceWorkerData&& workerData, const WorkerParameters& params, Ref<SecurityOrigin>&& origin, ServiceWorkerThread& thread, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, std::unique_ptr<NotificationClient>&& notificationClient)
: WorkerGlobalScope(WorkerThreadType::ServiceWorker, params, WTFMove(origin), thread, WTFMove(topOrigin), connectionProxy, socketProvider)
, m_contextData(WTFMove(contextData))
, m_registration(ServiceWorkerRegistration::getOrCreate(*this, navigator().serviceWorker(), WTFMove(m_contextData.registration)))
, m_serviceWorker(ServiceWorker::getOrCreate(*this, WTFMove(workerData)))
, m_clients(ServiceWorkerClients::create())
- , m_sessionID(sessionID)
, m_notificationClient(WTFMove(notificationClient))
, m_userGestureTimer(*this, &ServiceWorkerGlobalScope::resetUserGesture)
{
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h (293328 => 293329)
--- trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -51,7 +51,7 @@
class ServiceWorkerGlobalScope final : public WorkerGlobalScope {
WTF_MAKE_ISO_ALLOCATED(ServiceWorkerGlobalScope);
public:
- static Ref<ServiceWorkerGlobalScope> create(ServiceWorkerContextData&&, ServiceWorkerData&&, const WorkerParameters&, Ref<SecurityOrigin>&&, ServiceWorkerThread&, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, std::unique_ptr<NotificationClient>&&, PAL::SessionID);
+ static Ref<ServiceWorkerGlobalScope> create(ServiceWorkerContextData&&, ServiceWorkerData&&, const WorkerParameters&, Ref<SecurityOrigin>&&, ServiceWorkerThread&, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, std::unique_ptr<NotificationClient>&&);
~ServiceWorkerGlobalScope();
@@ -90,7 +90,7 @@
void setIsProcessingUserGestureForTesting(bool value) { m_isProcessingUserGesture = value; }
private:
- ServiceWorkerGlobalScope(ServiceWorkerContextData&&, ServiceWorkerData&&, const WorkerParameters&, Ref<SecurityOrigin>&&, ServiceWorkerThread&, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, std::unique_ptr<NotificationClient>&&, PAL::SessionID);
+ ServiceWorkerGlobalScope(ServiceWorkerContextData&&, ServiceWorkerData&&, const WorkerParameters&, Ref<SecurityOrigin>&&, ServiceWorkerThread&, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, std::unique_ptr<NotificationClient>&&);
void notifyServiceWorkerPageOfCreationIfNecessary();
Type type() const final { return Type::ServiceWorker; }
@@ -98,8 +98,6 @@
NotificationClient* notificationClient() final { return m_notificationClient.get(); }
- std::optional<PAL::SessionID> sessionID() const final { return m_sessionID; }
-
void resetUserGesture() { m_isProcessingUserGesture = false; }
ServiceWorkerContextData m_contextData;
@@ -110,7 +108,6 @@
uint64_t m_lastRequestIdentifier { 0 };
HashMap<uint64_t, RefPtr<DeferredPromise>> m_pendingSkipWaitingPromises;
- PAL::SessionID m_sessionID;
std::unique_ptr<NotificationClient> m_notificationClient;
bool m_hasPendingSilentPushEvent { false };
bool m_isProcessingUserGesture { false };
Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (293328 => 293329)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -122,8 +122,7 @@
Ref<WorkerGlobalScope> ServiceWorkerThread::createWorkerGlobalScope(const WorkerParameters& params, Ref<SecurityOrigin>&& origin, Ref<SecurityOrigin>&& topOrigin)
{
RELEASE_ASSERT(m_contextData);
- RELEASE_ASSERT(params.sessionID);
- return ServiceWorkerGlobalScope::create(*std::exchange(m_contextData, std::nullopt), *std::exchange(m_workerData, std::nullopt), params, WTFMove(origin), *this, WTFMove(topOrigin), idbConnectionProxy(), socketProvider(), WTFMove(m_notificationClient), *params.sessionID);
+ return ServiceWorkerGlobalScope::create(*std::exchange(m_contextData, std::nullopt), *std::exchange(m_workerData, std::nullopt), params, WTFMove(origin), *this, WTFMove(topOrigin), idbConnectionProxy(), socketProvider(), WTFMove(m_notificationClient));
}
void ServiceWorkerThread::runEventLoop()
Modified: trunk/Source/WebCore/workers/shared/context/SharedWorkerThreadProxy.cpp (293328 => 293329)
--- trunk/Source/WebCore/workers/shared/context/SharedWorkerThreadProxy.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/workers/shared/context/SharedWorkerThreadProxy.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -57,6 +57,7 @@
static WorkerParameters generateWorkerParameters(const WorkerFetchResult& workerFetchResult, WorkerOptions&& workerOptions, const String& userAgent, Document& document)
{
+ RELEASE_ASSERT(document.sessionID());
return {
workerFetchResult.lastRequestURL,
workerOptions.name,
@@ -72,7 +73,7 @@
workerOptions.credentials,
document.settingsValues(),
WorkerThreadMode::CreateNewThread,
- { },
+ *document.sessionID(),
#if ENABLE(SERVICE_WORKER)
{ },
#endif
Modified: trunk/Source/WebCore/worklets/Worklet.cpp (293328 => 293329)
--- trunk/Source/WebCore/worklets/Worklet.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/worklets/Worklet.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -59,7 +59,7 @@
void Worklet::addModule(const String& moduleURLString, WorkletOptions&& options, DOMPromiseDeferred<void>&& promise)
{
auto* document = this->document();
- if (!document) {
+ if (!document || !document->page()) {
promise.reject(Exception { InvalidStateError, "This frame is detached"_s });
return;
}
Modified: trunk/Source/WebCore/worklets/WorkletGlobalScope.cpp (293328 => 293329)
--- trunk/Source/WebCore/worklets/WorkletGlobalScope.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/worklets/WorkletGlobalScope.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -50,7 +50,7 @@
static std::atomic<unsigned> gNumberOfWorkletGlobalScopes { 0 };
WorkletGlobalScope::WorkletGlobalScope(WorkerOrWorkletThread& thread, Ref<JSC::VM>&& vm, const WorkletParameters& parameters)
- : WorkerOrWorkletGlobalScope(WorkerThreadType::Worklet, WTFMove(vm), &thread)
+ : WorkerOrWorkletGlobalScope(WorkerThreadType::Worklet, parameters.sessionID, WTFMove(vm), &thread)
, m_topOrigin(SecurityOrigin::createUnique())
, m_url(parameters.windowURL)
, m_jsRuntimeFlags(parameters.jsRuntimeFlags)
@@ -64,7 +64,7 @@
}
WorkletGlobalScope::WorkletGlobalScope(Document& document, Ref<JSC::VM>&& vm, ScriptSourceCode&& code)
- : WorkerOrWorkletGlobalScope(WorkerThreadType::Worklet, WTFMove(vm), nullptr)
+ : WorkerOrWorkletGlobalScope(WorkerThreadType::Worklet, *document.sessionID(), WTFMove(vm), nullptr)
, m_document(document)
, m_topOrigin(SecurityOrigin::createUnique())
, m_url(code.url())
Modified: trunk/Source/WebCore/worklets/WorkletParameters.h (293328 => 293329)
--- trunk/Source/WebCore/worklets/WorkletParameters.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebCore/worklets/WorkletParameters.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -36,11 +36,12 @@
JSC::RuntimeFlags jsRuntimeFlags;
float sampleRate;
String identifier;
+ PAL::SessionID sessionID;
Settings::Values settingsValues;
bool isAudioContextRealTime;
- WorkletParameters isolatedCopy() const & { return { windowURL.isolatedCopy(), jsRuntimeFlags, sampleRate, identifier.isolatedCopy(), settingsValues.isolatedCopy(), isAudioContextRealTime }; }
- WorkletParameters isolatedCopy() && { return { WTFMove(windowURL).isolatedCopy(), jsRuntimeFlags, sampleRate, WTFMove(identifier).isolatedCopy(), WTFMove(settingsValues).isolatedCopy(), isAudioContextRealTime }; }
+ WorkletParameters isolatedCopy() const & { return { windowURL.isolatedCopy(), jsRuntimeFlags, sampleRate, identifier.isolatedCopy(), sessionID, settingsValues.isolatedCopy(), isAudioContextRealTime }; }
+ WorkletParameters isolatedCopy() && { return { WTFMove(windowURL).isolatedCopy(), jsRuntimeFlags, sampleRate, WTFMove(identifier).isolatedCopy(), sessionID, WTFMove(settingsValues).isolatedCopy(), isAudioContextRealTime }; }
};
} // namespace WebCore
Modified: trunk/Source/WebKit/UIProcess/WebLockRegistryProxy.cpp (293328 => 293329)
--- trunk/Source/WebKit/UIProcess/WebLockRegistryProxy.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebKit/UIProcess/WebLockRegistryProxy.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -55,7 +55,7 @@
MESSAGE_CHECK(clientID.processIdentifier() == m_process.coreProcessIdentifier());
m_hasEverRequestedLocks = true;
- m_process.websiteDataStore().webLockRegistry().requestLock(WTFMove(clientOrigin), lockIdentifier, clientID, WTFMove(name), lockMode, steal, ifAvailable, [weakThis = WeakPtr { *this }, lockIdentifier, clientID](bool success) {
+ m_process.websiteDataStore().webLockRegistry().requestLock(m_process.sessionID(), WTFMove(clientOrigin), lockIdentifier, clientID, WTFMove(name), lockMode, steal, ifAvailable, [weakThis = WeakPtr { *this }, lockIdentifier, clientID](bool success) {
if (weakThis)
weakThis->m_process.send(Messages::RemoteWebLockRegistry::DidCompleteLockRequest(lockIdentifier, clientID, success), 0);
}, [weakThis = WeakPtr { *this }, lockIdentifier, clientID] {
@@ -68,7 +68,7 @@
{
MESSAGE_CHECK(lockIdentifier.processIdentifier() == m_process.coreProcessIdentifier());
MESSAGE_CHECK(clientID.processIdentifier() == m_process.coreProcessIdentifier());
- m_process.websiteDataStore().webLockRegistry().releaseLock(WTFMove(clientOrigin), lockIdentifier, clientID, WTFMove(name));
+ m_process.websiteDataStore().webLockRegistry().releaseLock(m_process.sessionID(), WTFMove(clientOrigin), lockIdentifier, clientID, WTFMove(name));
}
void WebLockRegistryProxy::abortLockRequest(WebCore::ClientOrigin&& clientOrigin, WebCore::WebLockIdentifier lockIdentifier, WebCore::ScriptExecutionContextIdentifier clientID, String&& name, CompletionHandler<void(bool)>&& completionHandler)
@@ -75,18 +75,18 @@
{
MESSAGE_CHECK(lockIdentifier.processIdentifier() == m_process.coreProcessIdentifier());
MESSAGE_CHECK(clientID.processIdentifier() == m_process.coreProcessIdentifier());
- m_process.websiteDataStore().webLockRegistry().abortLockRequest(WTFMove(clientOrigin), lockIdentifier, clientID, WTFMove(name), WTFMove(completionHandler));
+ m_process.websiteDataStore().webLockRegistry().abortLockRequest(m_process.sessionID(), WTFMove(clientOrigin), lockIdentifier, clientID, WTFMove(name), WTFMove(completionHandler));
}
void WebLockRegistryProxy::snapshot(WebCore::ClientOrigin&& clientOrigin, CompletionHandler<void(WebCore::WebLockManagerSnapshot&&)>&& completionHandler)
{
- m_process.websiteDataStore().webLockRegistry().snapshot(WTFMove(clientOrigin), WTFMove(completionHandler));
+ m_process.websiteDataStore().webLockRegistry().snapshot(m_process.sessionID(), WTFMove(clientOrigin), WTFMove(completionHandler));
}
void WebLockRegistryProxy::clientIsGoingAway(WebCore::ClientOrigin&& clientOrigin, WebCore::ScriptExecutionContextIdentifier clientID)
{
MESSAGE_CHECK(clientID.processIdentifier() == m_process.coreProcessIdentifier());
- m_process.websiteDataStore().webLockRegistry().clientIsGoingAway(WTFMove(clientOrigin), clientID);
+ m_process.websiteDataStore().webLockRegistry().clientIsGoingAway(m_process.sessionID(), WTFMove(clientOrigin), clientID);
}
void WebLockRegistryProxy::processDidExit()
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (293328 => 293329)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -125,7 +125,6 @@
pageConfiguration.databaseProvider = WebDatabaseProvider::getOrCreate(m_pageGroupID);
pageConfiguration.socketProvider = WebSocketProvider::create(m_webPageProxyID);
pageConfiguration.broadcastChannelRegistry = WebProcess::singleton().broadcastChannelRegistry();
- pageConfiguration.webLockRegistry = WebProcess::singleton().webLockRegistry();
pageConfiguration.userContentProvider = m_userContentController;
#if ENABLE(WEB_RTC)
pageConfiguration.libWebRTCProvider = makeUniqueRef<RemoteWorkerLibWebRTCProvider>();
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSharedWorkerContextManagerConnection.cpp (293328 => 293329)
--- trunk/Source/WebKit/WebProcess/Storage/WebSharedWorkerContextManagerConnection.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSharedWorkerContextManagerConnection.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -97,7 +97,6 @@
pageConfiguration.databaseProvider = WebDatabaseProvider::getOrCreate(m_pageGroupID);
pageConfiguration.socketProvider = WebSocketProvider::create(m_webPageProxyID);
pageConfiguration.broadcastChannelRegistry = WebProcess::singleton().broadcastChannelRegistry();
- pageConfiguration.webLockRegistry = WebProcess::singleton().webLockRegistry();
pageConfiguration.userContentProvider = m_userContentController;
#if ENABLE(WEB_RTC)
pageConfiguration.libWebRTCProvider = makeUniqueRef<RemoteWorkerLibWebRTCProvider>();
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/RemoteWebLockRegistry.cpp (293328 => 293329)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/RemoteWebLockRegistry.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/RemoteWebLockRegistry.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -57,8 +57,9 @@
WebProcess::singleton().removeMessageReceiver(*this);
}
-void RemoteWebLockRegistry::requestLock(const WebCore::ClientOrigin& clientOrigin, WebCore::WebLockIdentifier lockIdentifier, WebCore::ScriptExecutionContextIdentifier clientID, const String& name, WebCore::WebLockMode lockMode, bool steal, bool ifAvailable, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler)
+void RemoteWebLockRegistry::requestLock(PAL::SessionID sessionID, const WebCore::ClientOrigin& clientOrigin, WebCore::WebLockIdentifier lockIdentifier, WebCore::ScriptExecutionContextIdentifier clientID, const String& name, WebCore::WebLockMode lockMode, bool steal, bool ifAvailable, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler)
{
+ ASSERT_UNUSED(sessionID, WebProcess::singleton().sessionID());
LockRequest request { { WTFMove(lockStolenHandler) }, WTFMove(grantedHandler) };
auto& snapshot = m_locksSnapshotPerClient.ensure(clientID, [] { return LocksSnapshot { }; }).iterator->value;
snapshot.pendingRequests.add(lockIdentifier, WTFMove(request));
@@ -66,8 +67,9 @@
WebProcess::singleton().send(Messages::WebLockRegistryProxy::RequestLock(clientOrigin, lockIdentifier, clientID, name, lockMode, steal, ifAvailable), 0);
}
-void RemoteWebLockRegistry::releaseLock(const WebCore::ClientOrigin& clientOrigin, WebCore::WebLockIdentifier lockIdentifier, WebCore::ScriptExecutionContextIdentifier clientID, const String& name)
+void RemoteWebLockRegistry::releaseLock(PAL::SessionID sessionID, const WebCore::ClientOrigin& clientOrigin, WebCore::WebLockIdentifier lockIdentifier, WebCore::ScriptExecutionContextIdentifier clientID, const String& name)
{
+ ASSERT_UNUSED(sessionID, WebProcess::singleton().sessionID());
auto it = m_locksSnapshotPerClient.find(clientID);
if (it != m_locksSnapshotPerClient.end()) {
it->value.heldLocks.remove(lockIdentifier);
@@ -78,8 +80,9 @@
WebProcess::singleton().send(Messages::WebLockRegistryProxy::ReleaseLock(clientOrigin, lockIdentifier, clientID, name), 0);
}
-void RemoteWebLockRegistry::abortLockRequest(const WebCore::ClientOrigin& clientOrigin, WebCore::WebLockIdentifier lockIdentifier, WebCore::ScriptExecutionContextIdentifier clientID, const String& name, CompletionHandler<void(bool)>&& completionHandler)
+void RemoteWebLockRegistry::abortLockRequest(PAL::SessionID sessionID, const WebCore::ClientOrigin& clientOrigin, WebCore::WebLockIdentifier lockIdentifier, WebCore::ScriptExecutionContextIdentifier clientID, const String& name, CompletionHandler<void(bool)>&& completionHandler)
{
+ ASSERT_UNUSED(sessionID, WebProcess::singleton().sessionID());
WebProcess::singleton().sendWithAsyncReply(Messages::WebLockRegistryProxy::AbortLockRequest(clientOrigin, lockIdentifier, clientID, name), [weakThis = WeakPtr { *this }, lockIdentifier, clientID, completionHandler = WTFMove(completionHandler)](bool didAbort) mutable {
if (weakThis && didAbort) {
auto it = weakThis->m_locksSnapshotPerClient.find(clientID);
@@ -93,13 +96,15 @@
}, 0);
}
-void RemoteWebLockRegistry::snapshot(const WebCore::ClientOrigin& clientOrigin, CompletionHandler<void(WebCore::WebLockManagerSnapshot&&)>&& completionHandler)
+void RemoteWebLockRegistry::snapshot(PAL::SessionID sessionID, const WebCore::ClientOrigin& clientOrigin, CompletionHandler<void(WebCore::WebLockManagerSnapshot&&)>&& completionHandler)
{
+ ASSERT_UNUSED(sessionID, WebProcess::singleton().sessionID());
WebProcess::singleton().sendWithAsyncReply(Messages::WebLockRegistryProxy::Snapshot(clientOrigin), WTFMove(completionHandler), 0);
}
-void RemoteWebLockRegistry::clientIsGoingAway(const WebCore::ClientOrigin& clientOrigin, WebCore::ScriptExecutionContextIdentifier clientID)
+void RemoteWebLockRegistry::clientIsGoingAway(PAL::SessionID sessionID, const WebCore::ClientOrigin& clientOrigin, WebCore::ScriptExecutionContextIdentifier clientID)
{
+ ASSERT_UNUSED(sessionID, WebProcess::singleton().sessionID());
m_locksSnapshotPerClient.remove(clientID);
WebProcess::singleton().send(Messages::WebLockRegistryProxy::ClientIsGoingAway(clientOrigin, clientID), 0);
}
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/RemoteWebLockRegistry.h (293328 => 293329)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/RemoteWebLockRegistry.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/RemoteWebLockRegistry.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -41,11 +41,11 @@
~RemoteWebLockRegistry();
// WebCore::WebLockRegistry.
- void requestLock(const WebCore::ClientOrigin&, WebCore::WebLockIdentifier, WebCore::ScriptExecutionContextIdentifier, const String& name, WebCore::WebLockMode, bool steal, bool ifAvailable, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler) final;
- void releaseLock(const WebCore::ClientOrigin&, WebCore::WebLockIdentifier, WebCore::ScriptExecutionContextIdentifier, const String& name) final;
- void abortLockRequest(const WebCore::ClientOrigin&, WebCore::WebLockIdentifier, WebCore::ScriptExecutionContextIdentifier, const String& name, CompletionHandler<void(bool)>&&) final;
- void snapshot(const WebCore::ClientOrigin&, CompletionHandler<void(WebCore::WebLockManagerSnapshot&&)>&&) final;
- void clientIsGoingAway(const WebCore::ClientOrigin&, WebCore::ScriptExecutionContextIdentifier) final;
+ void requestLock(PAL::SessionID, const WebCore::ClientOrigin&, WebCore::WebLockIdentifier, WebCore::ScriptExecutionContextIdentifier, const String& name, WebCore::WebLockMode, bool steal, bool ifAvailable, Function<void(bool)>&& grantedHandler, Function<void()>&& lockStolenHandler) final;
+ void releaseLock(PAL::SessionID, const WebCore::ClientOrigin&, WebCore::WebLockIdentifier, WebCore::ScriptExecutionContextIdentifier, const String& name) final;
+ void abortLockRequest(PAL::SessionID, const WebCore::ClientOrigin&, WebCore::WebLockIdentifier, WebCore::ScriptExecutionContextIdentifier, const String& name, CompletionHandler<void(bool)>&&) final;
+ void snapshot(PAL::SessionID, const WebCore::ClientOrigin&, CompletionHandler<void(WebCore::WebLockManagerSnapshot&&)>&&) final;
+ void clientIsGoingAway(PAL::SessionID, const WebCore::ClientOrigin&, WebCore::ScriptExecutionContextIdentifier) final;
// IPC::MessageReceiver.
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (293328 => 293329)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -58,7 +58,6 @@
#include "RemoteRenderingBackendProxy.h"
#include "RemoteWebInspectorUI.h"
#include "RemoteWebInspectorUIMessages.h"
-#include "RemoteWebLockRegistry.h"
#include "SessionState.h"
#include "SessionStateConversion.h"
#include "ShareableBitmap.h"
@@ -596,7 +595,6 @@
makeUniqueRef<WebSpeechRecognitionProvider>(m_identifier),
makeUniqueRef<MediaRecorderProvider>(*this),
WebProcess::singleton().broadcastChannelRegistry(),
- WebProcess::singleton().webLockRegistry(),
WebPermissionController::create(*this),
makeUniqueRef<WebStorageProvider>(),
makeUniqueRef<WebModelPlayerProvider>(*this)
Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (293328 => 293329)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -293,7 +293,6 @@
, m_webLoaderStrategy(*new WebLoaderStrategy)
, m_cacheStorageProvider(WebCacheStorageProvider::create())
, m_broadcastChannelRegistry(WebBroadcastChannelRegistry::create())
- , m_webLockRegistry(RemoteWebLockRegistry::create(*this))
, m_cookieJar(WebCookieJar::create())
, m_dnsPrefetchHystereris([this](PAL::HysteresisState state) { if (state == PAL::HysteresisState::Stopped) m_dnsPrefetchedHosts.clear(); })
, m_nonVisibleProcessGraphicsCleanupTimer(*this, &WebProcess::nonVisibleProcessGraphicsCleanupTimerFired)
@@ -353,6 +352,8 @@
#if ENABLE(CONTENT_FILTERING_IN_NETWORKING_PROCESS)
WebMockContentFilterManager::singleton().startObservingSettings();
#endif
+
+ WebCore::WebLockRegistry::setSharedRegistry(RemoteWebLockRegistry::create(*this));
}
WebProcess::~WebProcess()
Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (293328 => 293329)
--- trunk/Source/WebKit/WebProcess/WebProcess.h 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h 2022-04-25 16:10:59 UTC (rev 293329)
@@ -127,7 +127,6 @@
class RemoteCDMFactory;
class RemoteLegacyCDMFactory;
class RemoteMediaEngineConfigurationFactory;
-class RemoteWebLockRegistry;
class StorageAreaMap;
class UserData;
class WaylandCompositorDisplay;
@@ -335,7 +334,6 @@
WebCacheStorageProvider& cacheStorageProvider() { return m_cacheStorageProvider.get(); }
WebBroadcastChannelRegistry& broadcastChannelRegistry() { return m_broadcastChannelRegistry.get(); }
- RemoteWebLockRegistry& webLockRegistry() { return m_webLockRegistry.get(); }
WebCookieJar& cookieJar() { return m_cookieJar.get(); }
WebSocketChannelManager& webSocketChannelManager() { return m_webSocketChannelManager; }
@@ -667,7 +665,6 @@
Ref<WebCacheStorageProvider> m_cacheStorageProvider;
Ref<WebBroadcastChannelRegistry> m_broadcastChannelRegistry;
- Ref<RemoteWebLockRegistry> m_webLockRegistry;
Ref<WebCookieJar> m_cookieJar;
WebSocketChannelManager m_webSocketChannelManager;
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (293328 => 293329)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2022-04-25 16:10:59 UTC (rev 293329)
@@ -231,7 +231,6 @@
#import <WebCore/WebCoreJITOperations.h>
#import <WebCore/WebCoreObjCExtras.h>
#import <WebCore/WebCoreView.h>
-#import <WebCore/WebLockRegistry.h>
#import <WebCore/WebViewVisualIdentificationOverlay.h>
#import <WebCore/Widget.h>
#import <WebKitLegacy/DOM.h>
@@ -1440,18 +1439,6 @@
}
#endif
-static Ref<WebCore::LocalWebLockRegistry> getOrCreateWebLockRegistry(bool isPrivateBrowsingEnabled)
-{
- static NeverDestroyed<WeakPtr<WebCore::LocalWebLockRegistry>> defaultRegistry;
- static NeverDestroyed<WeakPtr<WebCore::LocalWebLockRegistry>> privateRegistry;
- auto& existingRegistry = isPrivateBrowsingEnabled ? privateRegistry : defaultRegistry;
- if (existingRegistry.get())
- return *existingRegistry.get();
- auto registry = WebCore::LocalWebLockRegistry::create();
- existingRegistry.get() = registry;
- return registry;
-}
-
- (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSString *)groupName
{
WebCoreThreadViolationCheckRoundTwo();
@@ -1557,7 +1544,6 @@
makeUniqueRef<WebCore::DummySpeechRecognitionProvider>(),
makeUniqueRef<WebCore::MediaRecorderProvider>(),
WebBroadcastChannelRegistry::getOrCreate([[self preferences] privateBrowsingEnabled]),
- getOrCreateWebLockRegistry([[self preferences] privateBrowsingEnabled]),
WebCore::DummyPermissionController::create(),
makeUniqueRef<WebCore::DummyStorageProvider>(),
makeUniqueRef<WebCore::DummyModelPlayerProvider>()
@@ -1839,7 +1825,6 @@
makeUniqueRef<WebCore::DummySpeechRecognitionProvider>(),
makeUniqueRef<WebCore::MediaRecorderProvider>(),
WebBroadcastChannelRegistry::getOrCreate([[self preferences] privateBrowsingEnabled]),
- getOrCreateWebLockRegistry([[self preferences] privateBrowsingEnabled]),
WebCore::DummyPermissionController::create(),
makeUniqueRef<WebCore::DummyStorageProvider>(),
makeUniqueRef<WebCore::DummyModelPlayerProvider>()
Modified: trunk/Source/WebKitLegacy/win/WebView.cpp (293328 => 293329)
--- trunk/Source/WebKitLegacy/win/WebView.cpp 2022-04-25 15:37:33 UTC (rev 293328)
+++ trunk/Source/WebKitLegacy/win/WebView.cpp 2022-04-25 16:10:59 UTC (rev 293329)
@@ -173,7 +173,6 @@
#include <WebCore/UserStyleSheet.h>
#include <WebCore/WebCoreJITOperations.h>
#include <WebCore/WebCoreTextRenderer.h>
-#include <WebCore/WebLockRegistry.h>
#include <WebCore/WindowMessageBroadcaster.h>
#include <WebCore/WindowsTouch.h>
#include <comdef.h>
@@ -2839,16 +2838,6 @@
return shouldCreateScrollbars;
}
-static Ref<WebCore::LocalWebLockRegistry> getOrCreateWebLockRegistry()
-{
- static NeverDestroyed<WeakPtr<WebCore::LocalWebLockRegistry>> existingRegistry;
- if (existingRegistry.get())
- return *existingRegistry.get();
- auto registry = WebCore::LocalWebLockRegistry::create();
- existingRegistry.get() = registry;
- return registry;
-}
-
HRESULT WebView::initWithFrame(RECT frame, _In_ BSTR frameName, _In_ BSTR groupName)
{
HRESULT hr = S_OK;
@@ -2922,7 +2911,6 @@
makeUniqueRef<DummySpeechRecognitionProvider>(),
makeUniqueRef<MediaRecorderProvider>(),
WebBroadcastChannelRegistry::getOrCreate(false),
- getOrCreateWebLockRegistry(),
WebCore::DummyPermissionController::create(),
makeUniqueRef<WebCore::DummyStorageProvider>(),
makeUniqueRef<WebCore::DummyModelPlayerProvider>()