Diff
Modified: trunk/Source/WebKit/ChangeLog (289507 => 289508)
--- trunk/Source/WebKit/ChangeLog 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/ChangeLog 2022-02-10 00:46:37 UTC (rev 289508)
@@ -1,3 +1,96 @@
+2022-02-09 Chris Dumez <[email protected]>
+
+ [iOS] Take adequate process assertion for the SharedWorker process
+ https://bugs.webkit.org/show_bug.cgi?id=236271
+
+ Reviewed by Brent Fulgham.
+
+ Keep track of client processes that rely on a particular SharedWorker process and take the adequate
+ process assertion to keep the process running on iOS when necessary. This allows us to get rid of
+ the hack I landed previously to always take a process assertion on behalf of the shared worker
+ process (even if all its clients are suspended).
+
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::sharedWorkerServerToContextConnectionIsNoLongerNeeded):
+ (WebKit::NetworkConnectionToWebProcess::serviceWorkerServerToContextConnectionNoLongerNeeded):
+ * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::registerServiceWorkerClient):
+ (WebKit::WebSWServerConnection::unregisterServiceWorkerClient):
+ (WebKit::WebSWServerConnection::contextConnectionCreated):
+ * NetworkProcess/SharedWorker/WebSharedWorker.cpp:
+ (WebKit::WebSharedWorker::WebSharedWorker):
+ (WebKit::WebSharedWorker::didCreateContextConnection):
+ (WebKit::WebSharedWorker::addSharedWorkerObject):
+ (WebKit::WebSharedWorker::removeSharedWorkerObject):
+ (WebKit::WebSharedWorker::forEachSharedWorkerObject const):
+ (WebKit::WebSharedWorker::contextConnection const):
+ * NetworkProcess/SharedWorker/WebSharedWorker.h:
+ (WebKit::WebSharedWorker::sharedWorkerObjectsCount const):
+ (WebKit::WebSharedWorker::sharedWorkerObjects): Deleted.
+ * NetworkProcess/SharedWorker/WebSharedWorkerServer.cpp:
+ (WebKit::WebSharedWorkerServer::requestSharedWorker):
+ (WebKit::WebSharedWorkerServer::didFinishFetchingSharedWorkerScript):
+ (WebKit::WebSharedWorkerServer::createContextConnection):
+ (WebKit::WebSharedWorkerServer::removeContextConnection):
+ (WebKit::WebSharedWorkerServer::contextConnectionCreated):
+ (WebKit::WebSharedWorkerServer::sharedWorkerObjectIsGoingAway):
+ (WebKit::WebSharedWorkerServer::shutDownSharedWorker):
+ (WebKit::WebSharedWorkerServer::removeConnection):
+ (WebKit::WebSharedWorkerServer::postExceptionToWorkerObject):
+ * NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.cpp:
+ (WebKit::WebSharedWorkerServerToContextConnection::launchSharedWorker):
+ (WebKit::WebSharedWorkerServerToContextConnection::addSharedWorkerObject):
+ (WebKit::WebSharedWorkerServerToContextConnection::removeSharedWorkerObject):
+ * NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.h:
+ * Shared/RemoteWorkerType.h: Copied from Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.cpp.
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::terminateUnresponsiveServiceWorkerProcesses):
+ (WebKit::NetworkProcessProxy::registerRemoteWorkerClientProcess):
+ (WebKit::NetworkProcessProxy::unregisterRemoteWorkerClientProcess):
+ (WebKit::NetworkProcessProxy::remoteWorkerContextConnectionNoLongerNeeded):
+ (WebKit::NetworkProcessProxy::establishServiceWorkerContextConnectionToNetworkProcess):
+ (WebKit::NetworkProcessProxy::serviceWorkerContextConnectionNoLongerNeeded): Deleted.
+ (WebKit::NetworkProcessProxy::registerServiceWorkerClientProcess): Deleted.
+ (WebKit::NetworkProcessProxy::unregisterServiceWorkerClientProcess): Deleted.
+ (WebKit::NetworkProcessProxy::sharedWorkerContextConnectionNoLongerNeeded): Deleted.
+ * UIProcess/Network/NetworkProcessProxy.h:
+ * UIProcess/Network/NetworkProcessProxy.messages.in:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::setUserAgent):
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::establishServiceWorkerContextConnectionToNetworkProcess):
+ (WebKit::WebProcessPool::establishSharedWorkerContextConnectionToNetworkProcess):
+ (WebKit::WebProcessPool::createWebPage):
+ (WebKit::WebProcessPool::updateRemoteWorkerUserAgent):
+ (WebKit::WebProcessPool::terminateServiceWorkers):
+ (WebKit::WebProcessPool::updateProcessAssertions):
+ (WebKit::WebProcessPool::updateWorkerUserAgent): Deleted.
+ * UIProcess/WebProcessPool.h:
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::createForRemoteWorkers):
+ (WebKit::WebProcessProxy::didBecomeUnresponsive):
+ (WebKit::WebProcessProxy::didStartProvisionalLoadForMainFrame):
+ (WebKit::WebProcessProxy::setRemoteWorkerUserAgent):
+ (WebKit::WebProcessProxy::updateRemoteWorkerPreferencesStore):
+ (WebKit::WebProcessProxy::updateRemoteWorkerProcessAssertion):
+ (WebKit::WebProcessProxy::registerRemoteWorkerClientProcess):
+ (WebKit::WebProcessProxy::unregisterRemoteWorkerClientProcess):
+ (WebKit::WebProcessProxy::startServiceWorkerBackgroundProcessing):
+ (WebKit::WebProcessProxy::endServiceWorkerBackgroundProcessing):
+ (WebKit::WebProcessProxy::disableRemoteWorkers):
+ (WebKit::WebProcessProxy::enableRemoteWorkers):
+ (WebKit::WebProcessProxy::createForWorkers): Deleted.
+ (WebKit::WebProcessProxy::setWorkerUserAgent): Deleted.
+ (WebKit::WebProcessProxy::updateWorkerPreferencesStore): Deleted.
+ (WebKit::WebProcessProxy::updateWorkerProcessAssertion): Deleted.
+ (WebKit::WebProcessProxy::registerServiceWorkerClientProcess): Deleted.
+ (WebKit::WebProcessProxy::unregisterServiceWorkerClientProcess): Deleted.
+ (WebKit::WebProcessProxy::disableWorkers): Deleted.
+ (WebKit::WebProcessProxy::enableWorkers): Deleted.
+ * UIProcess/WebProcessProxy.h:
+ (WebKit::WebProcessProxy::hasServiceWorkerPageProxy):
+ * WebKit.xcodeproj/project.pbxproj:
+
2022-02-09 Antoine Quint <[email protected]>
[model] improve sizing on macOS
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (289507 => 289508)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2022-02-10 00:46:37 UTC (rev 289508)
@@ -56,6 +56,7 @@
#include "PingLoad.h"
#include "PreconnectTask.h"
#include "RTCDataChannelRemoteManagerProxy.h"
+#include "RemoteWorkerType.h"
#include "ServiceWorkerFetchTaskMessages.h"
#include "WebCoreArgumentCoders.h"
#include "WebErrors.h"
@@ -1254,7 +1255,7 @@
void NetworkConnectionToWebProcess::sharedWorkerServerToContextConnectionIsNoLongerNeeded()
{
CONNECTION_RELEASE_LOG(SharedWorker, "sharedWorkerServerToContextConnectionIsNoLongerNeeded:");
- m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::SharedWorkerContextConnectionNoLongerNeeded { webProcessIdentifier() }, 0);
+ m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::RemoteWorkerContextConnectionNoLongerNeeded { RemoteWorkerType::SharedWorker, webProcessIdentifier() }, 0);
m_sharedWorkerContextConnection = nullptr;
}
@@ -1305,7 +1306,7 @@
void NetworkConnectionToWebProcess::serviceWorkerServerToContextConnectionNoLongerNeeded()
{
CONNECTION_RELEASE_LOG(ServiceWorker, "serviceWorkerServerToContextConnectionNoLongerNeeded: WebProcess no longer useful for running service workers");
- m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::ServiceWorkerContextConnectionNoLongerNeeded { webProcessIdentifier() }, 0);
+ m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::RemoteWorkerContextConnectionNoLongerNeeded { RemoteWorkerType::ServiceWorker, webProcessIdentifier() }, 0);
m_swContextConnection = nullptr;
}
Modified: trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp (289507 => 289508)
--- trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp 2022-02-10 00:46:37 UTC (rev 289508)
@@ -37,6 +37,7 @@
#include "NetworkProcessProxyMessages.h"
#include "NetworkResourceLoader.h"
#include "NetworkSession.h"
+#include "RemoteWorkerType.h"
#include "WebCoreArgumentCoders.h"
#include "WebProcess.h"
#include "WebProcessMessages.h"
@@ -378,7 +379,7 @@
if (contextConnection) {
auto& connection = static_cast<WebSWServerToContextConnection&>(*contextConnection);
- m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::RegisterServiceWorkerClientProcess { identifier(), connection.webProcessIdentifier() }, 0);
+ m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::RegisterRemoteWorkerClientProcess { RemoteWorkerType::ServiceWorker, identifier(), connection.webProcessIdentifier() }, 0);
}
}
@@ -403,7 +404,7 @@
if (isDeletedOrigin) {
if (auto* contextConnection = server().contextConnectionForRegistrableDomain(RegistrableDomain { clientOrigin.clientOrigin })) {
auto& connection = static_cast<WebSWServerToContextConnection&>(*contextConnection);
- m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::UnregisterServiceWorkerClientProcess { identifier(), connection.webProcessIdentifier() }, 0);
+ m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::UnregisterRemoteWorkerClientProcess { RemoteWorkerType::ServiceWorker, identifier(), connection.webProcessIdentifier() }, 0);
}
}
}
@@ -544,7 +545,7 @@
connection.setThrottleState(computeThrottleState(connection.registrableDomain()));
if (hasMatchingClient(connection.registrableDomain()))
- m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::RegisterServiceWorkerClientProcess { identifier(), connection.webProcessIdentifier() }, 0);
+ m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::RegisterRemoteWorkerClientProcess { RemoteWorkerType::ServiceWorker, identifier(), connection.webProcessIdentifier() }, 0);
}
void WebSWServerConnection::terminateWorkerFromClient(ServiceWorkerIdentifier serviceWorkerIdentifier, CompletionHandler<void()>&& callback)
Modified: trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.cpp (289507 => 289508)
--- trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.cpp 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.cpp 2022-02-10 00:46:37 UTC (rev 289508)
@@ -26,6 +26,8 @@
#include "config.h"
#include "WebSharedWorker.h"
+#include "WebSharedWorkerServer.h"
+#include "WebSharedWorkerServerToContextConnection.h"
#include <wtf/HashMap.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/RunLoop.h>
@@ -39,8 +41,9 @@
return allWorkers;
}
-WebSharedWorker::WebSharedWorker(const WebCore::SharedWorkerKey& key, const WebCore::WorkerOptions& workerOptions)
- : m_identifier(WebCore::SharedWorkerIdentifier::generate())
+WebSharedWorker::WebSharedWorker(WebSharedWorkerServer& server, const WebCore::SharedWorkerKey& key, const WebCore::WorkerOptions& workerOptions)
+ : m_server(server)
+ , m_identifier(WebCore::SharedWorkerIdentifier::generate())
, m_key(key)
, m_workerOptions(workerOptions)
{
@@ -50,6 +53,11 @@
WebSharedWorker::~WebSharedWorker()
{
+ if (auto* connection = contextConnection()) {
+ for (auto& sharedWorkerObjectIdentifier : m_sharedWorkerObjects.keys())
+ connection->removeSharedWorkerObject(sharedWorkerObjectIdentifier);
+ }
+
ASSERT(allWorkers().get(m_identifier) == this);
allWorkers().remove(m_identifier);
}
@@ -64,4 +72,35 @@
return WebCore::RegistrableDomain { url() };
}
+void WebSharedWorker::didCreateContextConnection(WebSharedWorkerServerToContextConnection& contextConnection)
+{
+ for (auto& sharedWorkerObjectIdentifier : m_sharedWorkerObjects.keys())
+ contextConnection.addSharedWorkerObject(sharedWorkerObjectIdentifier);
+}
+
+void WebSharedWorker::addSharedWorkerObject(WebCore::SharedWorkerObjectIdentifier sharedWorkerObjectIdentifier, const WebCore::TransferredMessagePort& port)
+{
+ m_sharedWorkerObjects.add(sharedWorkerObjectIdentifier, port);
+ if (auto* connection = contextConnection())
+ connection->addSharedWorkerObject(sharedWorkerObjectIdentifier);
+}
+
+void WebSharedWorker::removeSharedWorkerObject(WebCore::SharedWorkerObjectIdentifier sharedWorkerObjectIdentifier)
+{
+ m_sharedWorkerObjects.remove(sharedWorkerObjectIdentifier);
+ if (auto* connection = contextConnection())
+ connection->removeSharedWorkerObject(sharedWorkerObjectIdentifier);
+}
+
+void WebSharedWorker::forEachSharedWorkerObject(const Function<void(WebCore::SharedWorkerObjectIdentifier, const WebCore::TransferredMessagePort&)>& apply) const
+{
+ for (auto& [sharedWorkerObjectIdentifier, port] : m_sharedWorkerObjects)
+ apply(sharedWorkerObjectIdentifier, port);
+}
+
+WebSharedWorkerServerToContextConnection* WebSharedWorker::contextConnection() const
+{
+ return m_server.contextConnectionForRegistrableDomain(registrableDomain());
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.h (289507 => 289508)
--- trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.h 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.h 2022-02-10 00:46:37 UTC (rev 289508)
@@ -39,10 +39,13 @@
namespace WebKit {
+class WebSharedWorkerServer;
+class WebSharedWorkerServerToContextConnection;
+
class WebSharedWorker : public CanMakeWeakPtr<WebSharedWorker> {
WTF_MAKE_FAST_ALLOCATED;
public:
- WebSharedWorker(const WebCore::SharedWorkerKey&, const WebCore::WorkerOptions&);
+ WebSharedWorker(WebSharedWorkerServer&, const WebCore::SharedWorkerKey&, const WebCore::WorkerOptions&);
~WebSharedWorker();
static WebSharedWorker* fromIdentifier(WebCore::SharedWorkerIdentifier);
@@ -53,8 +56,15 @@
const WebCore::ClientOrigin& origin() const { return m_key.origin; }
const URL& url() const { return m_key.url; }
WebCore::RegistrableDomain registrableDomain() const;
- HashMap<WebCore::SharedWorkerObjectIdentifier, WebCore::TransferredMessagePort>& sharedWorkerObjects() { return m_sharedWorkerObjects; }
+ WebSharedWorkerServerToContextConnection* contextConnection() const;
+ void addSharedWorkerObject(WebCore::SharedWorkerObjectIdentifier, const WebCore::TransferredMessagePort&);
+ void removeSharedWorkerObject(WebCore::SharedWorkerObjectIdentifier);
+ unsigned sharedWorkerObjectsCount() const { return m_sharedWorkerObjects.size(); }
+ void forEachSharedWorkerObject(const Function<void(WebCore::SharedWorkerObjectIdentifier, const WebCore::TransferredMessagePort&)>&) const;
+
+ void didCreateContextConnection(WebSharedWorkerServerToContextConnection&);
+
bool isRunning() const { return m_isRunning; }
void markAsRunning() { m_isRunning = true; }
@@ -68,6 +78,7 @@
WebSharedWorker(const WebSharedWorker&) = delete;
WebSharedWorker& operator=(const WebSharedWorker&) = delete;
+ WebSharedWorkerServer& m_server;
WebCore::SharedWorkerIdentifier m_identifier;
WebCore::SharedWorkerKey m_key;
WebCore::WorkerOptions m_workerOptions;
Modified: trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServer.cpp (289507 => 289508)
--- trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServer.cpp 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServer.cpp 2022-02-10 00:46:37 UTC (rev 289508)
@@ -53,7 +53,7 @@
void WebSharedWorkerServer::requestSharedWorker(WebCore::SharedWorkerKey&& sharedWorkerKey, WebCore::SharedWorkerObjectIdentifier sharedWorkerObjectIdentifier, WebCore::TransferredMessagePort&& port, WebCore::WorkerOptions&& workerOptions)
{
auto& sharedWorker = m_sharedWorkers.ensure(sharedWorkerKey, [&] {
- return makeUnique<WebSharedWorker>(sharedWorkerKey, workerOptions);
+ return makeUnique<WebSharedWorker>(*this, sharedWorkerKey, workerOptions);
}).iterator->value;
RELEASE_LOG(SharedWorker, "WebSharedWorkerServer::requestSharedWorker: sharedWorkerObjectIdentifier=%{private}s, sharedWorkerIdentifier=%" PRIu64, sharedWorkerObjectIdentifier.toString().utf8().data(), sharedWorker->identifier().toUInt64());
@@ -64,16 +64,16 @@
return;
}
- sharedWorker->sharedWorkerObjects().add(sharedWorkerObjectIdentifier, port);
+ sharedWorker->addSharedWorkerObject(sharedWorkerObjectIdentifier, port);
- if (sharedWorker->sharedWorkerObjects().size() > 1) {
- RELEASE_LOG(SharedWorker, "WebSharedWorkerServer::requestSharedWorker: A shared worker with this URL already exists (now shared by %u shared worker objects)", sharedWorker->sharedWorkerObjects().size());
+ if (sharedWorker->sharedWorkerObjectsCount() > 1) {
+ RELEASE_LOG(SharedWorker, "WebSharedWorkerServer::requestSharedWorker: A shared worker with this URL already exists (now shared by %u shared worker objects)", sharedWorker->sharedWorkerObjectsCount());
if (sharedWorker->didFinishFetching()) {
if (auto* serverConnection = m_connections.get(sharedWorkerObjectIdentifier.processIdentifier()))
serverConnection->notifyWorkerObjectOfLoadCompletion(sharedWorkerObjectIdentifier, { });
}
if (sharedWorker->isRunning()) {
- auto* contextConnection = m_contextConnections.get(sharedWorker->registrableDomain());
+ auto* contextConnection = sharedWorker->contextConnection();
ASSERT(contextConnection);
if (contextConnection)
contextConnection->postConnectEvent(*sharedWorker, port);
@@ -96,10 +96,10 @@
{
RELEASE_LOG(SharedWorker, "WebSharedWorkerServer::didFinishFetchingSharedWorkerScript sharedWorkerIdentifier=%" PRIu64 ", sharedWorker=%p, success=%d", sharedWorker.identifier().toUInt64(), &sharedWorker, fetchResult.error.isNull());
- for (auto sharedWorkerObjectIdentifier : sharedWorker.sharedWorkerObjects().keys()) {
+ sharedWorker.forEachSharedWorkerObject([&](auto sharedWorkerObjectIdentifier, auto&) {
if (auto* serverConnection = m_connections.get(sharedWorkerObjectIdentifier.processIdentifier()))
serverConnection->notifyWorkerObjectOfLoadCompletion(sharedWorkerObjectIdentifier, fetchResult.error);
- }
+ });
if (!fetchResult.error.isNull()) {
m_sharedWorkers.remove(sharedWorker.key());
@@ -108,14 +108,11 @@
sharedWorker.setFetchResult(WTFMove(fetchResult));
- auto registrableDomain = sharedWorker.registrableDomain();
- auto* contextConnection = contextConnectionForRegistrableDomain(registrableDomain);
- if (!contextConnection) {
- createContextConnection(registrableDomain);
+ if (auto* contextConnection = sharedWorker.contextConnection()) {
+ contextConnection->launchSharedWorker(sharedWorker);
return;
}
-
- contextConnection->launchSharedWorker(sharedWorker);
+ createContextConnection(sharedWorker.registrableDomain());
}
bool WebSharedWorkerServer::needsContextConnectionForRegistrableDomain(const WebCore::RegistrableDomain& registrableDomain) const
@@ -144,7 +141,6 @@
ASSERT(m_pendingContextConnectionDomains.contains(registrableDomain));
m_pendingContextConnectionDomains.remove(registrableDomain);
-
if (m_contextConnections.contains(registrableDomain))
return;
@@ -174,7 +170,7 @@
m_contextConnections.remove(registrableDomain);
- if (needsContextConnectionForRegistrableDomain(registrableDomain))
+ if (contextConnection.hasSharedWorkerObjects())
createContextConnection(registrableDomain);
}
@@ -183,7 +179,11 @@
RELEASE_LOG(SharedWorker, "WebSharedWorkerServer::contextConnectionCreated(%p) webProcessIdentifier=%" PRIu64, &contextConnection, contextConnection.webProcessIdentifier().toUInt64());
auto& registrableDomain = contextConnection.registrableDomain();
for (auto& sharedWorker : m_sharedWorkers.values()) {
- if (sharedWorker->didFinishFetching() && registrableDomain.matches(sharedWorker->url()))
+ if (!registrableDomain.matches(sharedWorker->url()))
+ continue;
+
+ sharedWorker->didCreateContextConnection(contextConnection);
+ if (sharedWorker->didFinishFetching())
contextConnection.launchSharedWorker(*sharedWorker);
}
}
@@ -195,8 +195,8 @@
if (!sharedWorker)
return;
- sharedWorker->sharedWorkerObjects().remove(sharedWorkerObjectIdentifier);
- if (!sharedWorker->sharedWorkerObjects().isEmpty())
+ sharedWorker->removeSharedWorkerObject(sharedWorkerObjectIdentifier);
+ if (sharedWorker->sharedWorkerObjectsCount())
return;
shutDownSharedWorker(sharedWorkerKey);
@@ -209,13 +209,13 @@
if (!sharedWorker)
return;
- auto* contextConnection = contextConnectionForRegistrableDomain(sharedWorker->registrableDomain());
+ auto* contextConnection = sharedWorker->contextConnection();
if (!contextConnection)
return;
contextConnection->terminateSharedWorker(*sharedWorker);
- if (!needsContextConnectionForRegistrableDomain(sharedWorker->registrableDomain()))
+ if (!contextConnection->hasSharedWorkerObjects())
contextConnection->connectionIsNoLongerNeeded();
}
@@ -235,10 +235,10 @@
Vector<std::pair<WebCore::SharedWorkerKey, WebCore::SharedWorkerObjectIdentifier>> sharedWorkerObjectsGoingAway;
for (auto& sharedWorker : m_sharedWorkers.values()) {
- for (auto& sharedWorkerObjectIdentifier : sharedWorker->sharedWorkerObjects().keys()) {
+ sharedWorker->forEachSharedWorkerObject([&](auto sharedWorkerObjectIdentifier, auto&) {
if (sharedWorkerObjectIdentifier.processIdentifier() == processIdentifier)
sharedWorkerObjectsGoingAway.append(std::make_pair(sharedWorker->key(), sharedWorkerObjectIdentifier));
- }
+ });
}
for (auto& [sharedWorkerKey, sharedWorkerObjectIdentifier] : sharedWorkerObjectsGoingAway)
sharedWorkerObjectIsGoingAway(sharedWorkerKey, sharedWorkerObjectIdentifier);
@@ -256,10 +256,10 @@
if (!sharedWorker)
return;
- for (auto sharedWorkerObjectIdentifier : sharedWorker->sharedWorkerObjects().keys()) {
+ sharedWorker->forEachSharedWorkerObject([&](auto sharedWorkerObjectIdentifier, auto&) {
if (auto* serverConnection = m_connections.get(sharedWorkerObjectIdentifier.processIdentifier()))
serverConnection->postExceptionToWorkerObject(sharedWorkerObjectIdentifier, errorMessage, lineNumber, columnNumber, sourceURL);
- }
+ });
}
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.cpp (289507 => 289508)
--- trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.cpp 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.cpp 2022-02-10 00:46:37 UTC (rev 289508)
@@ -28,6 +28,9 @@
#include "Logging.h"
#include "NetworkConnectionToWebProcess.h"
+#include "NetworkProcess.h"
+#include "NetworkProcessProxyMessages.h"
+#include "RemoteWorkerType.h"
#include "WebCoreArgumentCoders.h"
#include "WebSharedWorker.h"
#include "WebSharedWorkerContextManagerConnectionMessages.h"
@@ -91,8 +94,9 @@
CONTEXT_CONNECTION_RELEASE_LOG("launchSharedWorker: sharedWorkerIdentifier=%" PRIu64, sharedWorker.identifier().toUInt64());
sharedWorker.markAsRunning();
send(Messages::WebSharedWorkerContextManagerConnection::LaunchSharedWorker { sharedWorker.origin(), sharedWorker.identifier(), sharedWorker.workerOptions(), sharedWorker.fetchResult() });
- for (auto& port : sharedWorker.sharedWorkerObjects().values())
+ sharedWorker.forEachSharedWorkerObject([&](auto, auto& port) {
postConnectEvent(sharedWorker, port);
+ });
}
void WebSharedWorkerServerToContextConnection::postConnectEvent(const WebSharedWorker& sharedWorker, const WebCore::TransferredMessagePort& port)
@@ -107,6 +111,29 @@
send(Messages::WebSharedWorkerContextManagerConnection::TerminateSharedWorker { sharedWorker.identifier() });
}
+void WebSharedWorkerServerToContextConnection::addSharedWorkerObject(WebCore::SharedWorkerObjectIdentifier sharedWorkerObjectIdentifier)
+{
+ auto& sharedWorkerObjects = m_sharedWorkerObjects.ensure(sharedWorkerObjectIdentifier.processIdentifier(), [] { return HashSet<WebCore::SharedWorkerObjectIdentifier> { }; }).iterator->value;
+ sharedWorkerObjects.add(sharedWorkerObjectIdentifier);
+
+ if (webProcessIdentifier() != sharedWorkerObjectIdentifier.processIdentifier() && sharedWorkerObjects.size() == 1)
+ m_connection.networkProcess().send(Messages::NetworkProcessProxy::RegisterRemoteWorkerClientProcess { RemoteWorkerType::SharedWorker, sharedWorkerObjectIdentifier.processIdentifier(), webProcessIdentifier() }, 0);
+}
+
+void WebSharedWorkerServerToContextConnection::removeSharedWorkerObject(WebCore::SharedWorkerObjectIdentifier sharedWorkerObjectIdentifier)
+{
+ auto it = m_sharedWorkerObjects.find(sharedWorkerObjectIdentifier.processIdentifier());
+ if (it == m_sharedWorkerObjects.end())
+ return;
+ it->value.remove(sharedWorkerObjectIdentifier);
+ if (!it->value.isEmpty())
+ return;
+
+ m_sharedWorkerObjects.remove(it);
+ if (webProcessIdentifier() != sharedWorkerObjectIdentifier.processIdentifier())
+ m_connection.networkProcess().send(Messages::NetworkProcessProxy::UnregisterRemoteWorkerClientProcess { RemoteWorkerType::SharedWorker, sharedWorkerObjectIdentifier.processIdentifier(), webProcessIdentifier() }, 0);
+}
+
#undef CONTEXT_CONNECTION_RELEASE_LOG
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.h (289507 => 289508)
--- trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.h 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.h 2022-02-10 00:46:37 UTC (rev 289508)
@@ -30,6 +30,7 @@
#include "WebPageProxyIdentifier.h"
#include <WebCore/RegistrableDomain.h>
#include <WebCore/SharedWorkerIdentifier.h>
+#include <WebCore/SharedWorkerObjectIdentifier.h>
#include <WebCore/TransferredMessagePort.h>
namespace WebCore {
@@ -61,9 +62,13 @@
void terminateSharedWorker(const WebSharedWorker&);
void connectionIsNoLongerNeeded();
+ bool hasSharedWorkerObjects() const { return !m_sharedWorkerObjects.isEmpty(); }
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+ void addSharedWorkerObject(WebCore::SharedWorkerObjectIdentifier);
+ void removeSharedWorkerObject(WebCore::SharedWorkerObjectIdentifier);
+
private:
// IPC messages.
void postExceptionToWorkerObject(WebCore::SharedWorkerIdentifier, const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL);
@@ -75,6 +80,7 @@
NetworkConnectionToWebProcess& m_connection;
WeakPtr<WebSharedWorkerServer> m_server;
WebCore::RegistrableDomain m_registrableDomain;
+ HashMap<WebCore::ProcessIdentifier, HashSet<WebCore::SharedWorkerObjectIdentifier>> m_sharedWorkerObjects;
};
} // namespace WebKit
Copied: trunk/Source/WebKit/Shared/RemoteWorkerType.h (from rev 289507, trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.cpp) (0 => 289508)
--- trunk/Source/WebKit/Shared/RemoteWorkerType.h (rev 0)
+++ trunk/Source/WebKit/Shared/RemoteWorkerType.h 2022-02-10 00:46:37 UTC (rev 289508)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebKit {
+
+enum class RemoteWorkerType : uint32_t {
+ ServiceWorker = 1 << 0,
+ SharedWorker = 1 << 1
+};
+
+} // namespace WebKit
+
+namespace WTF {
+template<> struct EnumTraits<WebKit::RemoteWorkerType> {
+ using values = EnumValues<
+ WebKit::RemoteWorkerType,
+ WebKit::RemoteWorkerType::ServiceWorker,
+ WebKit::RemoteWorkerType::SharedWorker
+ >;
+};
+}
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (289507 => 289508)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2022-02-10 00:46:37 UTC (rev 289508)
@@ -529,7 +529,7 @@
void NetworkProcessProxy::terminateUnresponsiveServiceWorkerProcesses(WebCore::ProcessIdentifier processIdentifier)
{
if (RefPtr process = WebProcessProxy::processForIdentifier(processIdentifier)) {
- process->disableWorkers(WebProcessProxy::WorkerType::ServiceWorker);
+ process->disableRemoteWorkers(RemoteWorkerType::ServiceWorker);
process->requestTermination(ProcessTerminationReason::ExceededCPULimit);
}
}
@@ -1420,36 +1420,36 @@
WebProcessPool::establishSharedWorkerContextConnectionToNetworkProcess(WTFMove(registrableDomain), sessionID, WTFMove(completionHandler));
}
-#if ENABLE(SERVICE_WORKER)
-void NetworkProcessProxy::establishServiceWorkerContextConnectionToNetworkProcess(RegistrableDomain&& registrableDomain, std::optional<ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier, PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
+void NetworkProcessProxy::registerRemoteWorkerClientProcess(RemoteWorkerType workerType, WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier sharedWorkerProcessIdentifier)
{
- WebProcessPool::establishServiceWorkerContextConnectionToNetworkProcess(WTFMove(registrableDomain), serviceWorkerPageIdentifier, sessionID, WTFMove(completionHandler));
-}
+ auto* webProcess = WebProcessProxy::processForIdentifier(webProcessIdentifier);
+ auto* sharedWorkerProcess = WebProcessProxy::processForIdentifier(sharedWorkerProcessIdentifier);
+ if (!webProcess || !sharedWorkerProcess)
+ return;
-void NetworkProcessProxy::serviceWorkerContextConnectionNoLongerNeeded(WebCore::ProcessIdentifier identifier)
-{
- if (auto* process = WebProcessProxy::processForIdentifier(identifier))
- process->disableWorkers(WebProcessProxy::WorkerType::ServiceWorker);
+ sharedWorkerProcess->registerRemoteWorkerClientProcess(workerType, *webProcess);
}
-void NetworkProcessProxy::registerServiceWorkerClientProcess(WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier serviceWorkerProcessIdentifier)
+void NetworkProcessProxy::unregisterRemoteWorkerClientProcess(RemoteWorkerType workerType, WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier sharedWorkerProcessIdentifier)
{
auto* webProcess = WebProcessProxy::processForIdentifier(webProcessIdentifier);
- auto* serviceWorkerProcess = WebProcessProxy::processForIdentifier(serviceWorkerProcessIdentifier);
- if (!webProcess || !serviceWorkerProcess)
+ auto* sharedWorkerProcess = WebProcessProxy::processForIdentifier(sharedWorkerProcessIdentifier);
+ if (!webProcess || !sharedWorkerProcess)
return;
- serviceWorkerProcess->registerServiceWorkerClientProcess(*webProcess);
+ sharedWorkerProcess->unregisterRemoteWorkerClientProcess(workerType, *webProcess);
}
-void NetworkProcessProxy::unregisterServiceWorkerClientProcess(WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier serviceWorkerProcessIdentifier)
+void NetworkProcessProxy::remoteWorkerContextConnectionNoLongerNeeded(RemoteWorkerType workerType, WebCore::ProcessIdentifier identifier)
{
- auto* webProcess = WebProcessProxy::processForIdentifier(webProcessIdentifier);
- auto* serviceWorkerProcess = WebProcessProxy::processForIdentifier(webProcessIdentifier);
- if (!webProcess || !serviceWorkerProcess)
- return;
+ if (auto* process = WebProcessProxy::processForIdentifier(identifier))
+ process->disableRemoteWorkers(workerType);
+}
- serviceWorkerProcess->unregisterServiceWorkerClientProcess(*webProcess);
+#if ENABLE(SERVICE_WORKER)
+void NetworkProcessProxy::establishServiceWorkerContextConnectionToNetworkProcess(RegistrableDomain&& registrableDomain, std::optional<ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier, PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
+{
+ WebProcessPool::establishServiceWorkerContextConnectionToNetworkProcess(WTFMove(registrableDomain), serviceWorkerPageIdentifier, sessionID, WTFMove(completionHandler));
}
void NetworkProcessProxy::startServiceWorkerBackgroundProcessing(WebCore::ProcessIdentifier serviceWorkerProcessIdentifier)
@@ -1465,12 +1465,6 @@
}
#endif
-void NetworkProcessProxy::sharedWorkerContextConnectionNoLongerNeeded(WebCore::ProcessIdentifier identifier)
-{
- if (auto* process = WebProcessProxy::processForIdentifier(identifier))
- process->disableWorkers(WebProcessProxy::WorkerType::SharedWorker);
-}
-
void NetworkProcessProxy::requestStorageSpace(PAL::SessionID sessionID, const WebCore::ClientOrigin& origin, uint64_t currentQuota, uint64_t currentSize, uint64_t spaceRequired, CompletionHandler<void(std::optional<uint64_t> quota)>&& completionHandler)
{
RELEASE_LOG(Storage, "%p - NetworkProcessProxy::requestStorageSpace", this);
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (289507 => 289508)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2022-02-10 00:46:37 UTC (rev 289508)
@@ -86,6 +86,7 @@
class WebPageProxy;
class WebUserContentControllerProxy;
+enum class RemoteWorkerType : uint32_t;
enum class ShouldGrandfatherStatistics : bool;
enum class StorageAccessStatus : uint8_t;
enum class WebsiteDataFetchOption : uint8_t;
@@ -329,14 +330,13 @@
#if ENABLE(SERVICE_WORKER)
void establishServiceWorkerContextConnectionToNetworkProcess(WebCore::RegistrableDomain&&, std::optional<WebCore::ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier, PAL::SessionID, CompletionHandler<void()>&&);
- void serviceWorkerContextConnectionNoLongerNeeded(WebCore::ProcessIdentifier);
- void registerServiceWorkerClientProcess(WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier serviceWorkerProcessIdentifier);
- void unregisterServiceWorkerClientProcess(WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier serviceWorkerProcessIdentifier);
void startServiceWorkerBackgroundProcessing(WebCore::ProcessIdentifier serviceWorkerProcessIdentifier);
void endServiceWorkerBackgroundProcessing(WebCore::ProcessIdentifier serviceWorkerProcessIdentifier);
#endif
- void sharedWorkerContextConnectionNoLongerNeeded(WebCore::ProcessIdentifier);
+ void remoteWorkerContextConnectionNoLongerNeeded(RemoteWorkerType, WebCore::ProcessIdentifier);
void establishSharedWorkerContextConnectionToNetworkProcess(WebCore::RegistrableDomain&&, PAL::SessionID, CompletionHandler<void()>&&);
+ void registerRemoteWorkerClientProcess(RemoteWorkerType, WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier sharedWorkerProcessIdentifier);
+ void unregisterRemoteWorkerClientProcess(RemoteWorkerType, WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier sharedWorkerProcessIdentifier);
void terminateWebProcess(WebCore::ProcessIdentifier);
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (289507 => 289508)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in 2022-02-10 00:46:37 UTC (rev 289508)
@@ -54,14 +54,13 @@
#if ENABLE(SERVICE_WORKER)
EstablishServiceWorkerContextConnectionToNetworkProcess(WebCore::RegistrableDomain registrableDomain, std::optional<WebCore::ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier, PAL::SessionID sessionID) -> () Async
- ServiceWorkerContextConnectionNoLongerNeeded(WebCore::ProcessIdentifier identifier)
- RegisterServiceWorkerClientProcess(WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier serviceWorkerProcessIdentifier)
- UnregisterServiceWorkerClientProcess(WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier serviceWorkerProcessIdentifier)
StartServiceWorkerBackgroundProcessing(WebCore::ProcessIdentifier serviceWorkerProcessIdentifier)
EndServiceWorkerBackgroundProcessing(WebCore::ProcessIdentifier serviceWorkerProcessIdentifier)
#endif
EstablishSharedWorkerContextConnectionToNetworkProcess(WebCore::RegistrableDomain registrableDomain, PAL::SessionID sessionID) -> () Async
- SharedWorkerContextConnectionNoLongerNeeded(WebCore::ProcessIdentifier identifier)
+ RemoteWorkerContextConnectionNoLongerNeeded(enum:uint32_t WebKit::RemoteWorkerType workerType, WebCore::ProcessIdentifier identifier)
+ RegisterRemoteWorkerClientProcess(enum:uint32_t WebKit::RemoteWorkerType workerType, WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier remoteWorkerProcessIdentifier);
+ UnregisterRemoteWorkerClientProcess(enum:uint32_t WebKit::RemoteWorkerType workerType, WebCore::ProcessIdentifier webProcessIdentifier, WebCore::ProcessIdentifier remoteWorkerProcessIdentifier);
SetWebProcessHasUploads(WebCore::ProcessIdentifier processID, bool hasUpload)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (289507 => 289508)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-02-10 00:46:37 UTC (rev 289508)
@@ -3696,7 +3696,7 @@
// We update the service worker there at the moment to be sure we use values used by actual web pages.
// FIXME: Refactor this when we have a better User-Agent story.
- process().processPool().updateWorkerUserAgent(m_userAgent);
+ process().processPool().updateRemoteWorkerUserAgent(m_userAgent);
if (!hasRunningProcess())
return;
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (289507 => 289508)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2022-02-10 00:46:37 UTC (rev 289508)
@@ -546,7 +546,7 @@
if (serviceWorkerPageIdentifier) {
// This is a service worker for a service worker page so we need to make sure we use use the page's WebProcess for the service worker.
if ((serviceWorkerProcessProxy = WebProcessProxy::processForIdentifier(serviceWorkerPageIdentifier->processIdentifier()))) {
- serviceWorkerProcessProxy->enableWorkers(WebProcessProxy::WorkerType::ServiceWorker, processPool->userContentControllerIdentifierForWorkers());
+ serviceWorkerProcessProxy->enableRemoteWorkers(RemoteWorkerType::ServiceWorker, processPool->userContentControllerIdentifierForRemoteWorkers());
if (serviceWorkerProcessProxy->isInProcessCache()) {
processPool->webProcessCache().removeProcess(*serviceWorkerProcessProxy, WebProcessCache::ShouldShutDownProcess::No);
ASSERT(!serviceWorkerProcessProxy->isInProcessCache());
@@ -564,7 +564,7 @@
continue;
serviceWorkerProcessProxy = process.ptr();
- serviceWorkerProcessProxy->enableWorkers(WebProcessProxy::WorkerType::ServiceWorker, processPool->userContentControllerIdentifierForWorkers());
+ serviceWorkerProcessProxy->enableRemoteWorkers(RemoteWorkerType::ServiceWorker, processPool->userContentControllerIdentifierForRemoteWorkers());
if (serviceWorkerProcessProxy->isInProcessCache()) {
processPool->webProcessCache().removeProcess(*serviceWorkerProcessProxy, WebProcessCache::ShouldShutDownProcess::No);
@@ -577,7 +577,7 @@
}
if (!serviceWorkerProcessProxy) {
- auto newProcessProxy = WebProcessProxy::createForWorkers(WebProcessProxy::WorkerType::ServiceWorker, *processPool, RegistrableDomain { registrableDomain }, *websiteDataStore);
+ auto newProcessProxy = WebProcessProxy::createForRemoteWorkers(RemoteWorkerType::ServiceWorker, *processPool, RegistrableDomain { registrableDomain }, *websiteDataStore);
serviceWorkerProcessProxy = newProcessProxy.ptr();
WEBPROCESSPOOL_RELEASE_LOG_STATIC(ServiceWorker, "establishServiceWorkerContextConnectionToNetworkProcess creating a new service worker process (proces=%p, PID=%d)", serviceWorkerProcessProxy, serviceWorkerProcessProxy->processIdentifier());
@@ -586,18 +586,18 @@
processPool->m_processes.append(WTFMove(newProcessProxy));
}
- workerProcesses().add(*serviceWorkerProcessProxy);
+ remoteWorkerProcesses().add(*serviceWorkerProcessProxy);
- serviceWorkerProcessProxy->establishServiceWorkerContext(processPool->m_workerPreferences ? processPool->m_workerPreferences.value() : processPool->m_defaultPageGroup->preferences().store(), registrableDomain, serviceWorkerPageIdentifier, WTFMove(completionHandler));
- if (!processPool->m_workerUserAgent.isNull())
- serviceWorkerProcessProxy->setWorkerUserAgent(processPool->m_workerUserAgent);
+ serviceWorkerProcessProxy->establishServiceWorkerContext(processPool->m_remoteWorkerPreferences ? processPool->m_remoteWorkerPreferences.value() : processPool->m_defaultPageGroup->preferences().store(), registrableDomain, serviceWorkerPageIdentifier, WTFMove(completionHandler));
+ if (!processPool->m_remoteWorkerUserAgent.isNull())
+ serviceWorkerProcessProxy->setRemoteWorkerUserAgent(processPool->m_remoteWorkerUserAgent);
}
#endif
-void WebProcessPool::removeFromWorkerProcesses(WebProcessProxy& process)
+void WebProcessPool::removeFromRemoteWorkerProcesses(WebProcessProxy& process)
{
- ASSERT(workerProcesses().contains(process));
- workerProcesses().remove(process);
+ ASSERT(remoteWorkerProcesses().contains(process));
+ remoteWorkerProcesses().remove(process);
}
void WebProcessPool::establishSharedWorkerContextConnectionToNetworkProcess(WebCore::RegistrableDomain&& registrableDomain, PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
@@ -623,7 +623,7 @@
continue;
sharedWorkerProcessProxy = process.ptr();
- sharedWorkerProcessProxy->enableWorkers(WebProcessProxy::WorkerType::SharedWorker, processPool->userContentControllerIdentifierForWorkers());
+ sharedWorkerProcessProxy->enableRemoteWorkers(RemoteWorkerType::SharedWorker, processPool->userContentControllerIdentifierForRemoteWorkers());
if (sharedWorkerProcessProxy->isInProcessCache()) {
processPool->webProcessCache().removeProcess(*sharedWorkerProcessProxy, WebProcessCache::ShouldShutDownProcess::No);
@@ -635,7 +635,7 @@
}
if (!sharedWorkerProcessProxy) {
- auto newProcessProxy = WebProcessProxy::createForWorkers(WebProcessProxy::WorkerType::SharedWorker, *processPool, RegistrableDomain { registrableDomain }, *websiteDataStore);
+ auto newProcessProxy = WebProcessProxy::createForRemoteWorkers(RemoteWorkerType::SharedWorker, *processPool, RegistrableDomain { registrableDomain }, *websiteDataStore);
sharedWorkerProcessProxy = newProcessProxy.ptr();
WEBPROCESSPOOL_RELEASE_LOG_STATIC(SharedWorker, "establishSharedWorkerContextConnectionToNetworkProcess creating a new service worker process (process=%p, PID=%d)", sharedWorkerProcessProxy, sharedWorkerProcessProxy->processIdentifier());
@@ -644,11 +644,11 @@
processPool->m_processes.append(WTFMove(newProcessProxy));
}
- workerProcesses().add(*sharedWorkerProcessProxy);
+ remoteWorkerProcesses().add(*sharedWorkerProcessProxy);
- sharedWorkerProcessProxy->establishSharedWorkerContext(processPool->m_workerPreferences ? processPool->m_workerPreferences.value() : processPool->m_defaultPageGroup->preferences().store(), registrableDomain, WTFMove(completionHandler));
- if (!processPool->m_workerUserAgent.isNull())
- sharedWorkerProcessProxy->setWorkerUserAgent(processPool->m_workerUserAgent);
+ sharedWorkerProcessProxy->establishSharedWorkerContext(processPool->m_remoteWorkerPreferences ? processPool->m_remoteWorkerPreferences.value() : processPool->m_defaultPageGroup->preferences().store(), registrableDomain, WTFMove(completionHandler));
+ if (!processPool->m_remoteWorkerUserAgent.isNull())
+ sharedWorkerProcessProxy->setRemoteWorkerUserAgent(processPool->m_remoteWorkerUserAgent);
}
void WebProcessPool::windowServerConnectionStateChanged()
@@ -1054,7 +1054,7 @@
m_backForwardCache->removeEntriesForProcess(process);
if (process.isRunningWorkers())
- removeFromWorkerProcesses(process);
+ removeFromRemoteWorkerProcesses(process);
static_cast<WebContextSupplement*>(supplement<WebGeolocationManagerProxy>())->processDidClose(&process);
@@ -1114,12 +1114,12 @@
return createNewWebProcess(&websiteDataStore, captivePortalMode);
}
-UserContentControllerIdentifier WebProcessPool::userContentControllerIdentifierForWorkers()
+UserContentControllerIdentifier WebProcessPool::userContentControllerIdentifierForRemoteWorkers()
{
- if (!m_userContentControllerForWorkers)
- m_userContentControllerForWorkers = WebUserContentControllerProxy::create();
+ if (!m_userContentControllerForRemoteWorkers)
+ m_userContentControllerForRemoteWorkers = WebUserContentControllerProxy::create();
- return m_userContentControllerForWorkers->identifier();
+ return m_userContentControllerForRemoteWorkers->identifier();
}
Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API::PageConfiguration>&& pageConfiguration)
@@ -1165,13 +1165,13 @@
auto page = process->createWebPage(pageClient, WTFMove(pageConfiguration));
- if (!m_workerPreferences) {
- m_workerPreferences = page->preferencesStore();
- for (auto& workerProcess : workerProcesses())
- workerProcess.updateWorkerPreferencesStore(*m_workerPreferences);
+ if (!m_remoteWorkerPreferences) {
+ m_remoteWorkerPreferences = page->preferencesStore();
+ for (auto& workerProcess : remoteWorkerProcesses())
+ workerProcess.updateRemoteWorkerPreferencesStore(*m_remoteWorkerPreferences);
}
if (userContentController)
- m_userContentControllerForWorkers = userContentController;
+ m_userContentControllerForRemoteWorkers = userContentController;
bool enableProcessSwapOnCrossSiteNavigation = page->preferences().processSwapOnCrossSiteNavigationEnabled();
#if PLATFORM(IOS_FAMILY)
@@ -1194,13 +1194,13 @@
return page;
}
-void WebProcessPool::updateWorkerUserAgent(const String& userAgent)
+void WebProcessPool::updateRemoteWorkerUserAgent(const String& userAgent)
{
- if (m_workerUserAgent == userAgent)
+ if (m_remoteWorkerUserAgent == userAgent)
return;
- m_workerUserAgent = userAgent;
- for (auto& workerProcess : workerProcesses())
- workerProcess.setWorkerUserAgent(m_workerUserAgent);
+ m_remoteWorkerUserAgent = userAgent;
+ for (auto& workerProcess : remoteWorkerProcesses())
+ workerProcess.setRemoteWorkerUserAgent(m_remoteWorkerUserAgent);
}
void WebProcessPool::pageBeginUsingWebsiteDataStore(WebPageProxyIdentifier pageID, WebsiteDataStore& dataStore)
@@ -1581,12 +1581,12 @@
#if ENABLE(SERVICE_WORKER)
Ref protectedThis { *this };
Vector<Ref<WebProcessProxy>> serviceWorkerProcesses;
- workerProcesses().forEach([&](auto& process) {
+ remoteWorkerProcesses().forEach([&](auto& process) {
if (process.isRunningServiceWorkers())
serviceWorkerProcesses.append(process);
});
for (auto& serviceWorkerProcess : serviceWorkerProcesses)
- serviceWorkerProcess->disableWorkers(WebProcessProxy::WorkerType::ServiceWorker);
+ serviceWorkerProcess->disableRemoteWorkers(RemoteWorkerType::ServiceWorker);
#endif
}
@@ -1814,7 +1814,7 @@
#endif
}
-WeakHashSet<WebProcessProxy>& WebProcessPool::workerProcesses()
+WeakHashSet<WebProcessProxy>& WebProcessPool::remoteWorkerProcesses()
{
static NeverDestroyed<WeakHashSet<WebProcessProxy>> processes;
return processes;
@@ -1833,13 +1833,13 @@
// Check on next run loop since the web process proxy tokens are probably being updated.
callOnMainRunLoop([] {
- workerProcesses().forEach([](auto& workerProcess) {
+ remoteWorkerProcesses().forEach([](auto& workerProcess) {
#if ENABLE(SERVICE_WORKER)
if (workerProcess.isRunningServiceWorkers())
- workerProcess.updateWorkerProcessAssertion(WebProcessProxy::WorkerType::ServiceWorker);
+ workerProcess.updateRemoteWorkerProcessAssertion(RemoteWorkerType::ServiceWorker);
#endif
if (workerProcess.isRunningSharedWorkers())
- workerProcess.updateWorkerProcessAssertion(WebProcessProxy::WorkerType::SharedWorker);
+ workerProcess.updateRemoteWorkerProcessAssertion(RemoteWorkerType::SharedWorker);
});
});
}
@@ -1848,7 +1848,7 @@
{
#if ENABLE(SERVICE_WORKER)
// FIXME: This is inefficient.
- return WTF::anyOf(workerProcesses(), [pageID](auto& process) {
+ return WTF::anyOf(remoteWorkerProcesses(), [pageID](auto& process) {
return process.hasServiceWorkerPageProxy(pageID);
});
#endif
@@ -2177,7 +2177,7 @@
size_t WebProcessPool::serviceWorkerProxiesCount() const
{
unsigned count = 0;
- workerProcesses().forEach([&](auto& process) {
+ remoteWorkerProcesses().forEach([&](auto& process) {
if (process.isRunningServiceWorkers())
++count;
});
@@ -2186,7 +2186,7 @@
bool WebProcessPool::hasServiceWorkerForegroundActivityForTesting() const
{
- return WTF::anyOf(workerProcesses(), [](auto& process) {
+ return WTF::anyOf(remoteWorkerProcesses(), [](auto& process) {
return process.hasServiceWorkerForegroundActivityForTesting();
});
}
@@ -2193,7 +2193,7 @@
bool WebProcessPool::hasServiceWorkerBackgroundActivityForTesting() const
{
- return WTF::anyOf(workerProcesses(), [](auto& process) {
+ return WTF::anyOf(remoteWorkerProcesses(), [](auto& process) {
return process.hasServiceWorkerBackgroundActivityForTesting();
});
}
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (289507 => 289508)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.h 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h 2022-02-10 00:46:37 UTC (rev 289508)
@@ -374,7 +374,7 @@
void networkProcessDidTerminate(NetworkProcessProxy&, NetworkProcessProxy::TerminationReason);
bool isServiceWorkerPageID(WebPageProxyIdentifier) const;
- void removeFromWorkerProcesses(WebProcessProxy&);
+ void removeFromRemoteWorkerProcesses(WebProcessProxy&);
#if ENABLE(SERVICE_WORKER)
static void establishServiceWorkerContextConnectionToNetworkProcess(WebCore::RegistrableDomain&&, std::optional<WebCore::ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier, PAL::SessionID, CompletionHandler<void()>&&);
@@ -384,8 +384,8 @@
#endif
void serviceWorkerProcessCrashed(WebProcessProxy&);
- void updateWorkerUserAgent(const String& userAgent);
- UserContentControllerIdentifier userContentControllerIdentifierForWorkers();
+ void updateRemoteWorkerUserAgent(const String& userAgent);
+ UserContentControllerIdentifier userContentControllerIdentifierForRemoteWorkers();
static void establishSharedWorkerContextConnectionToNetworkProcess(WebCore::RegistrableDomain&&, PAL::SessionID, CompletionHandler<void()>&&);
#if PLATFORM(COCOA)
@@ -621,11 +621,11 @@
HashMap<PAL::SessionID, WeakPtr<WebProcessProxy>> m_dummyProcessProxies; // Lightweight WebProcessProxy objects without backing process.
- static WeakHashSet<WebProcessProxy>& workerProcesses();
+ static WeakHashSet<WebProcessProxy>& remoteWorkerProcesses();
- std::optional<WebPreferencesStore> m_workerPreferences;
- RefPtr<WebUserContentControllerProxy> m_userContentControllerForWorkers;
- String m_workerUserAgent;
+ std::optional<WebPreferencesStore> m_remoteWorkerPreferences;
+ RefPtr<WebUserContentControllerProxy> m_userContentControllerForRemoteWorkers;
+ String m_remoteWorkerUserAgent;
#if ENABLE(GPU_PROCESS)
RefPtr<GPUProcessProxy> m_gpuProcess;
Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (289507 => 289508)
--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp 2022-02-10 00:46:37 UTC (rev 289508)
@@ -182,11 +182,11 @@
return proxy;
}
-Ref<WebProcessProxy> WebProcessProxy::createForWorkers(WorkerType workerType, WebProcessPool& processPool, RegistrableDomain&& registrableDomain, WebsiteDataStore& websiteDataStore)
+Ref<WebProcessProxy> WebProcessProxy::createForRemoteWorkers(RemoteWorkerType workerType, WebProcessPool& processPool, RegistrableDomain&& registrableDomain, WebsiteDataStore& websiteDataStore)
{
auto proxy = adoptRef(*new WebProcessProxy(processPool, &websiteDataStore, IsPrewarmed::No, CrossOriginMode::Shared, CaptivePortalMode::Disabled));
proxy->m_registrableDomain = WTFMove(registrableDomain);
- proxy->enableWorkers(workerType, processPool.userContentControllerIdentifierForWorkers());
+ proxy->enableRemoteWorkers(workerType, processPool.userContentControllerIdentifierForRemoteWorkers());
proxy->connect();
return proxy;
}
@@ -997,7 +997,7 @@
// If the web process becomes unresponsive and only runs service/shared workers, kill it ourselves since there are no native clients to do it.
if (isRunningWorkers() && m_pageMap.isEmpty()) {
WEBPROCESSPROXY_RELEASE_LOG_ERROR(PerformanceLogging, "didBecomeUnresponsive: Terminating worker-only web process because it is unresponsive");
- disableWorkers({ WorkerType::ServiceWorker, WorkerType::SharedWorker });
+ disableRemoteWorkers({ RemoteWorkerType::ServiceWorker, RemoteWorkerType::SharedWorker });
terminate();
}
}
@@ -1693,7 +1693,7 @@
auto registrableDomain = WebCore::RegistrableDomain { url };
if (m_registrableDomain && *m_registrableDomain != registrableDomain) {
#if ENABLE(SERVICE_WORKER)
- disableWorkers(WorkerType::ServiceWorker);
+ disableRemoteWorkers(RemoteWorkerType::ServiceWorker);
#endif
// Null out registrable domain since this process has now been used for several domains.
@@ -1874,7 +1874,7 @@
}
#endif
-void WebProcessProxy::setWorkerUserAgent(const String& userAgent)
+void WebProcessProxy::setRemoteWorkerUserAgent(const String& userAgent)
{
#if ENABLE(SERVICE_WORKER)
if (m_serviceWorkerInformation)
@@ -1884,7 +1884,7 @@
send(Messages::WebSharedWorkerContextManagerConnection::SetUserAgent { userAgent }, 0);
}
-void WebProcessProxy::updateWorkerPreferencesStore(const WebPreferencesStore& store)
+void WebProcessProxy::updateRemoteWorkerPreferencesStore(const WebPreferencesStore& store)
{
#if ENABLE(SERVICE_WORKER)
if (m_serviceWorkerInformation)
@@ -1894,22 +1894,15 @@
send(Messages::WebSharedWorkerContextManagerConnection::UpdatePreferencesStore { store }, 0);
}
-void WebProcessProxy::updateWorkerProcessAssertion(WorkerType workerType)
+void WebProcessProxy::updateRemoteWorkerProcessAssertion(RemoteWorkerType workerType)
{
- auto& workerInformation = workerType == WorkerType::SharedWorker ? m_sharedWorkerInformation : m_serviceWorkerInformation;
+ auto& workerInformation = workerType == RemoteWorkerType::SharedWorker ? m_sharedWorkerInformation : m_serviceWorkerInformation;
ASSERT(workerInformation);
if (!workerInformation)
return;
- WEBPROCESSPROXY_RELEASE_LOG(ProcessSuspension, "updateWorkerProcessAssertion: workerType=%{public}s", workerType == WorkerType::SharedWorker ? "shared" : "service");
+ WEBPROCESSPROXY_RELEASE_LOG(ProcessSuspension, "updateRemoteWorkerProcessAssertion: workerType=%{public}s", workerType == RemoteWorkerType::SharedWorker ? "shared" : "service");
- // FIXME: Clients do not properly get populated in m_sharedWorkerInformation so we currently take an assertion no matter what.
- if (workerType == WorkerType::SharedWorker) {
- if (!ProcessThrottler::isValidForegroundActivity(workerInformation->activity))
- workerInformation->activity = m_throttler.foregroundActivity("Worker for foreground view(s)"_s);
- return;
- }
-
bool shouldTakeForegroundActivity = WTF::anyOf(workerInformation->clientProcesses, [&](auto& process) {
return &process != this && !!process.m_foregroundToken;
});
@@ -1928,7 +1921,7 @@
return;
}
- if (workerType == WorkerType::ServiceWorker && m_hasServiceWorkerBackgroundProcessing) {
+ if (workerType == RemoteWorkerType::ServiceWorker && m_hasServiceWorkerBackgroundProcessing) {
WEBPROCESSPROXY_RELEASE_LOG(ProcessSuspension, "Service Worker for background processing");
if (!ProcessThrottler::isValidBackgroundActivity(workerInformation->activity))
workerInformation->activity = m_throttler.backgroundActivity("Service Worker for background processing"_s);
@@ -1949,28 +1942,30 @@
}, 0);
}
-#if ENABLE(SERVICE_WORKER)
-
-void WebProcessProxy::registerServiceWorkerClientProcess(WebProcessProxy& proxy)
+void WebProcessProxy::registerRemoteWorkerClientProcess(RemoteWorkerType workerType, WebProcessProxy& proxy)
{
- if (!m_serviceWorkerInformation)
+ auto& workerInformation = workerType == RemoteWorkerType::SharedWorker ? m_sharedWorkerInformation : m_serviceWorkerInformation;
+ if (!workerInformation)
return;
- WEBPROCESSPROXY_RELEASE_LOG(ServiceWorker, "registerServiceWorkerClientProcess: clientProcess=%p, clientPID=%d", &proxy, proxy.processIdentifier());
- m_serviceWorkerInformation->clientProcesses.add(proxy);
- updateWorkerProcessAssertion(WorkerType::ServiceWorker);
+ WEBPROCESSPROXY_RELEASE_LOG(Worker, "registerWorkerClientProcess: workerType=%{public}s, clientProcess=%p, clientPID=%d", workerType == RemoteWorkerType::SharedWorker ? "shared" : "service", &proxy, proxy.processIdentifier());
+ workerInformation->clientProcesses.add(proxy);
+ updateRemoteWorkerProcessAssertion(workerType);
}
-void WebProcessProxy::unregisterServiceWorkerClientProcess(WebProcessProxy& proxy)
+void WebProcessProxy::unregisterRemoteWorkerClientProcess(RemoteWorkerType workerType, WebProcessProxy& proxy)
{
- if (!m_serviceWorkerInformation)
+ auto& workerInformation = workerType == RemoteWorkerType::SharedWorker ? m_sharedWorkerInformation : m_serviceWorkerInformation;
+ if (!workerInformation)
return;
- WEBPROCESSPROXY_RELEASE_LOG(ServiceWorker, "unregisterServiceWorkerClientProcess: clientProcess=%p, clientPID=%d", &proxy, proxy.processIdentifier());
- m_serviceWorkerInformation->clientProcesses.remove(proxy);
- updateWorkerProcessAssertion(WorkerType::ServiceWorker);
+ WEBPROCESSPROXY_RELEASE_LOG(Worker, "unregisterWorkerClientProcess: workerType=%{public}s, clientProcess=%p, clientPID=%d", workerType == RemoteWorkerType::SharedWorker ? "shared" : "service", &proxy, proxy.processIdentifier());
+ workerInformation->clientProcesses.remove(proxy);
+ updateRemoteWorkerProcessAssertion(workerType);
}
+#if ENABLE(SERVICE_WORKER)
+
bool WebProcessProxy::hasServiceWorkerForegroundActivityForTesting() const
{
return m_serviceWorkerInformation ? ProcessThrottler::isValidForegroundActivity(m_serviceWorkerInformation->activity) : false;
@@ -1988,7 +1983,7 @@
WEBPROCESSPROXY_RELEASE_LOG(ProcessSuspension, "startServiceWorkerBackgroundProcessing");
m_hasServiceWorkerBackgroundProcessing = true;
- updateWorkerProcessAssertion(WorkerType::ServiceWorker);
+ updateRemoteWorkerProcessAssertion(RemoteWorkerType::ServiceWorker);
}
void WebProcessProxy::endServiceWorkerBackgroundProcessing()
@@ -1998,20 +1993,20 @@
WEBPROCESSPROXY_RELEASE_LOG(ProcessSuspension, "endServiceWorkerBackgroundProcessing");
m_hasServiceWorkerBackgroundProcessing = false;
- updateWorkerProcessAssertion(WorkerType::ServiceWorker);
+ updateRemoteWorkerProcessAssertion(RemoteWorkerType::ServiceWorker);
}
#endif // ENABLE(SERVICE_WORKER)
-void WebProcessProxy::disableWorkers(OptionSet<WorkerType> workerType)
+void WebProcessProxy::disableRemoteWorkers(OptionSet<RemoteWorkerType> workerType)
{
ASSERT(!workerType.isEmpty());
bool didChange = false;
- if (workerType.contains(WorkerType::ServiceWorker) && m_serviceWorkerInformation) {
+ if (workerType.contains(RemoteWorkerType::ServiceWorker) && m_serviceWorkerInformation) {
m_serviceWorkerInformation = { };
didChange = true;
}
- if (workerType.contains(WorkerType::SharedWorker) && m_sharedWorkerInformation) {
+ if (workerType.contains(RemoteWorkerType::SharedWorker) && m_sharedWorkerInformation) {
m_sharedWorkerInformation = { };
didChange = true;
}
@@ -2018,18 +2013,18 @@
if (!didChange)
return;
- WEBPROCESSPROXY_RELEASE_LOG(Process, "disableWorkers: Disabling workers (SharedWorkers=%d, ServiceWorkers=%d)", workerType.contains(WorkerType::SharedWorker), workerType.contains(WorkerType::ServiceWorker));
+ WEBPROCESSPROXY_RELEASE_LOG(Process, "disableWorkers: Disabling workers (SharedWorkers=%d, ServiceWorkers=%d)", workerType.contains(RemoteWorkerType::SharedWorker), workerType.contains(RemoteWorkerType::ServiceWorker));
updateBackgroundResponsivenessTimer();
if (!isRunningWorkers())
- processPool().removeFromWorkerProcesses(*this);
+ processPool().removeFromRemoteWorkerProcesses(*this);
#if ENABLE(SERVICE_WORKER)
- if (workerType.contains(WorkerType::ServiceWorker))
+ if (workerType.contains(RemoteWorkerType::ServiceWorker))
send(Messages::WebSWContextManagerConnection::Close { }, 0);
#endif
- if (workerType.contains(WorkerType::SharedWorker))
+ if (workerType.contains(RemoteWorkerType::SharedWorker))
send(Messages::WebSharedWorkerContextManagerConnection::Close { }, 0);
maybeShutDown();
@@ -2051,10 +2046,10 @@
}
#endif
-void WebProcessProxy::enableWorkers(WorkerType workerType, const UserContentControllerIdentifier& userContentControllerIdentifier)
+void WebProcessProxy::enableRemoteWorkers(RemoteWorkerType workerType, const UserContentControllerIdentifier& userContentControllerIdentifier)
{
WEBPROCESSPROXY_RELEASE_LOG(ServiceWorker, "enableWorkers: workerType=%u", static_cast<unsigned>(workerType));
- auto& workerInformation = workerType == WorkerType::SharedWorker ? m_sharedWorkerInformation : m_serviceWorkerInformation;
+ auto& workerInformation = workerType == RemoteWorkerType::SharedWorker ? m_sharedWorkerInformation : m_serviceWorkerInformation;
ASSERT(!workerInformation);
workerInformation = RemoteWorkerInformation {
@@ -2071,7 +2066,7 @@
};
updateBackgroundResponsivenessTimer();
- updateWorkerProcessAssertion(workerType);
+ updateRemoteWorkerProcessAssertion(workerType);
}
void WebProcessProxy::didCreateSleepDisabler(SleepDisablerIdentifier identifier, const String& reason, bool display)
Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (289507 => 289508)
--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h 2022-02-10 00:46:37 UTC (rev 289508)
@@ -36,6 +36,7 @@
#include "ProcessThrottler.h"
#include "ProcessThrottlerClient.h"
#include "RemoteWorkerInitializationData.h"
+#include "RemoteWorkerType.h"
#include "ResponsivenessTimer.h"
#include "SpeechRecognitionServer.h"
#include "UserContentControllerIdentifier.h"
@@ -136,13 +137,9 @@
enum class ShouldLaunchProcess : bool { No, Yes };
enum class CaptivePortalMode : bool { Disabled, Enabled };
- enum class WorkerType : uint32_t {
- ServiceWorker = 1 << 0,
- SharedWorker = 1 << 1
- };
static Ref<WebProcessProxy> create(WebProcessPool&, WebsiteDataStore*, CaptivePortalMode, IsPrewarmed, WebCore::CrossOriginMode = WebCore::CrossOriginMode::Shared, ShouldLaunchProcess = ShouldLaunchProcess::Yes);
- static Ref<WebProcessProxy> createForWorkers(WorkerType, WebProcessPool&, WebCore::RegistrableDomain&&, WebsiteDataStore&);
+ static Ref<WebProcessProxy> createForRemoteWorkers(RemoteWorkerType, WebProcessPool&, WebCore::RegistrableDomain&&, WebsiteDataStore&);
~WebProcessProxy();
@@ -165,8 +162,8 @@
void setIsInProcessCache(bool, WillShutDown = WillShutDown::No);
bool isInProcessCache() const { return m_isInProcessCache; }
- void enableWorkers(WorkerType, const UserContentControllerIdentifier&);
- void disableWorkers(OptionSet<WorkerType>);
+ void enableRemoteWorkers(RemoteWorkerType, const UserContentControllerIdentifier&);
+ void disableRemoteWorkers(OptionSet<RemoteWorkerType>);
WebsiteDataStore& websiteDataStore() const { ASSERT(m_websiteDataStore); return *m_websiteDataStore; }
void setWebsiteDataStore(WebsiteDataStore&);
@@ -366,15 +363,15 @@
void updateAudibleMediaAssertions();
- void setWorkerUserAgent(const String&);
- void updateWorkerPreferencesStore(const WebPreferencesStore&);
+ void setRemoteWorkerUserAgent(const String&);
+ void updateRemoteWorkerPreferencesStore(const WebPreferencesStore&);
void establishSharedWorkerContext(const WebPreferencesStore&, const WebCore::RegistrableDomain&, CompletionHandler<void()>&&);
- void updateWorkerProcessAssertion(WorkerType);
+ void registerRemoteWorkerClientProcess(RemoteWorkerType, WebProcessProxy&);
+ void unregisterRemoteWorkerClientProcess(RemoteWorkerType, WebProcessProxy&);
+ void updateRemoteWorkerProcessAssertion(RemoteWorkerType);
#if ENABLE(SERVICE_WORKER)
void establishServiceWorkerContext(const WebPreferencesStore&, const WebCore::RegistrableDomain&, std::optional<WebCore::ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier, CompletionHandler<void()>&&);
bool hasServiceWorkerPageProxy(WebPageProxyIdentifier pageProxyID) { return m_serviceWorkerInformation && m_serviceWorkerInformation->remoteWorkerPageProxyID == pageProxyID; }
- void registerServiceWorkerClientProcess(WebProcessProxy&);
- void unregisterServiceWorkerClientProcess(WebProcessProxy&);
bool hasServiceWorkerForegroundActivityForTesting() const;
bool hasServiceWorkerBackgroundActivityForTesting() const;
void startServiceWorkerBackgroundProcessing();
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (289507 => 289508)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2022-02-09 23:57:16 UTC (rev 289507)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2022-02-10 00:46:37 UTC (rev 289508)
@@ -893,6 +893,7 @@
4671FF1F23217EFF001B64C7 /* WebResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 4671FF1D23217EFF001B64C7 /* WebResourceLoadObserver.h */; };
467E43E82243FF7D00B13924 /* WebProcessDataStoreParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 467E43E72243FF6D00B13924 /* WebProcessDataStoreParameters.h */; };
46809A7C23D9225E00C297D0 /* WebCookieCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 46809A7A23D9225300C297D0 /* WebCookieCache.h */; };
+ 4691CB9B27B2DD2D00B29AAF /* RemoteWorkerType.h in Headers */ = {isa = PBXBuildFile; fileRef = 4691CB9A27B2DD1800B29AAF /* RemoteWorkerType.h */; };
46A2B6091E5676A600C3DEDA /* BackgroundProcessResponsivenessTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A2B6071E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.h */; };
46B0524722668D8500265B97 /* WebDeviceOrientationAndMotionAccessController.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B0524422668D2300265B97 /* WebDeviceOrientationAndMotionAccessController.h */; };
46BEB6D722FB9BD700269867 /* StorageArea.h in Headers */ = {isa = PBXBuildFile; fileRef = 46BEB6D522FB9BD600269867 /* StorageArea.h */; };
@@ -4276,6 +4277,7 @@
468386682763FAB100CF9182 /* WebSharedWorkerServerConnection.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebSharedWorkerServerConnection.cpp; sourceTree = "<group>"; };
4689B90F2756D1430007C651 /* RemoteWebLockRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteWebLockRegistry.h; sourceTree = "<group>"; };
4689B9102756D1430007C651 /* RemoteWebLockRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteWebLockRegistry.cpp; sourceTree = "<group>"; };
+ 4691CB9A27B2DD1800B29AAF /* RemoteWorkerType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteWorkerType.h; sourceTree = "<group>"; };
46943DCB2763F834004B610E /* WebSharedWorkerObjectConnection.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebSharedWorkerObjectConnection.messages.in; sourceTree = "<group>"; };
469DE802273ECC5D00930276 /* ProcessLauncherCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProcessLauncherCocoa.mm; sourceTree = "<group>"; };
46A2B6061E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackgroundProcessResponsivenessTimer.cpp; sourceTree = "<group>"; };
@@ -7275,6 +7277,7 @@
9B1229D023FF2A5E008CA751 /* RemoteAudioDestinationIdentifier.h */,
5C80B3DD23690F100086E6DE /* RemoteWorkerInitializationData.cpp */,
5C80B3DB23690D8D0086E6DE /* RemoteWorkerInitializationData.h */,
+ 4691CB9A27B2DD1800B29AAF /* RemoteWorkerType.h */,
7203449B26A6C476000A5F54 /* RenderingUpdateID.h */,
5CB7AFE623C681B000E49CF3 /* ResourceLoadInfo.h */,
5C00993B2417FB7E00D53C25 /* ResourceLoadStatisticsParameters.h */,
@@ -13389,6 +13392,7 @@
A55BA8251BA25CFB007CD33D /* RemoteWebInspectorUIProxyMessages.h in Headers */,
46C5B7CE27AADDD3000C5B47 /* RemoteWorkerFrameLoaderClient.h in Headers */,
46C5B7CF27AADDD6000C5B47 /* RemoteWorkerLibWebRTCProvider.h in Headers */,
+ 4691CB9B27B2DD2D00B29AAF /* RemoteWorkerType.h in Headers */,
5CB7AFE723C6820700E49CF3 /* ResourceLoadInfo.h in Headers */,
6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */,
6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */,