Diff
Modified: trunk/Source/WTF/ChangeLog (225007 => 225008)
--- trunk/Source/WTF/ChangeLog 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WTF/ChangeLog 2017-11-18 02:27:13 UTC (rev 225008)
@@ -1,3 +1,16 @@
+2017-11-17 Chris Dumez <[email protected]>
+
+ Use a strongly typed identifier for SWServer::Connection
+ https://bugs.webkit.org/show_bug.cgi?id=179848
+
+ Reviewed by Brady Eidson.
+
+ Make ObjectIdentifier a little more flexible to support more use cases.
+
+ * wtf/ObjectIdentifier.h:
+ (WTF::ObjectIdentifier::toUInt64 const):
+ (WTF::makeObjectIdentifier):
+
2017-11-17 Simon Fraser <[email protected]>
Add a TimingScope class for microbenchmarking sections of code
Modified: trunk/Source/WTF/wtf/ObjectIdentifier.h (225007 => 225008)
--- trunk/Source/WTF/wtf/ObjectIdentifier.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WTF/wtf/ObjectIdentifier.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -61,6 +61,8 @@
{
return m_identifier != other.m_identifier;
}
+
+ uint64_t toUInt64() const { return m_identifier; }
#ifndef NDEBUG
String loggingString() const
@@ -71,6 +73,7 @@
private:
template<typename U> friend ObjectIdentifier<U> generateObjectIdentifier();
+ template<typename U> friend ObjectIdentifier<U> makeObjectIdentifier(uint64_t);
friend struct HashTraits<ObjectIdentifier>;
template<typename U> friend struct ObjectIdentifierHash;
@@ -93,6 +96,11 @@
return ObjectIdentifier<T> { ++ObjectIdentifier<T>::s_currentIdentifier };
}
+template<typename T> inline ObjectIdentifier<T> makeObjectIdentifier(uint64_t identifier)
+{
+ return ObjectIdentifier<T> { identifier };
+}
+
template<typename T> struct ObjectIdentifierHash {
static unsigned hash(const ObjectIdentifier<T>& identifier) { return intHash(identifier.m_identifier); }
static bool equal(const ObjectIdentifier<T>& a, const ObjectIdentifier<T>& b) { return a == b; }
@@ -109,3 +117,4 @@
using WTF::ObjectIdentifier;
using WTF::generateObjectIdentifier;
+using WTF::makeObjectIdentifier;
Modified: trunk/Source/WebCore/ChangeLog (225007 => 225008)
--- trunk/Source/WebCore/ChangeLog 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/ChangeLog 2017-11-18 02:27:13 UTC (rev 225008)
@@ -1,3 +1,72 @@
+2017-11-17 Chris Dumez <[email protected]>
+
+ Use a strongly typed identifier for SWServer::Connection
+ https://bugs.webkit.org/show_bug.cgi?id=179848
+
+ Reviewed by Brady Eidson.
+
+ Use a strongly typed identifier for SWServer::Connection, for clarity.
+
+ * workers/service/ServiceWorker.cpp:
+ (WebCore::ServiceWorker::postMessage):
+ * workers/service/ServiceWorkerClient.cpp:
+ (WebCore::ServiceWorkerClient::ServiceWorkerClient):
+ (WebCore::ServiceWorkerClient::id const):
+ (WebCore::ServiceWorkerClient::postMessage):
+ * workers/service/ServiceWorkerClient.h:
+ (WebCore::ServiceWorkerClient::create):
+ (WebCore::ServiceWorkerClient::identifier const):
+ * workers/service/ServiceWorkerClientData.cpp:
+ (WebCore::ServiceWorkerClientData::isolatedCopy const):
+ (WebCore::ServiceWorkerClientData::from):
+ * workers/service/ServiceWorkerClientData.h:
+ (WebCore::ServiceWorkerClientData::encode const):
+ (WebCore::ServiceWorkerClientData::decode):
+ * workers/service/ServiceWorkerClientIdentifier.h:
+ (WebCore::ServiceWorkerClientIdentifier::toString const):
+ (WebCore::ServiceWorkerClientIdentifier::decode):
+ * workers/service/ServiceWorkerContainer.cpp:
+ (WebCore::ServiceWorkerContainer::addRegistration):
+ (WebCore::ServiceWorkerContainer::removeRegistration):
+ (WebCore::ServiceWorkerContainer::updateRegistration):
+ (WebCore::ServiceWorkerContainer::connectionIdentifier):
+ * workers/service/ServiceWorkerContainer.h:
+ * workers/service/ServiceWorkerFetchResult.h:
+ (WebCore::ServiceWorkerFetchResult::decode):
+ * workers/service/ServiceWorkerJobClient.h:
+ * workers/service/ServiceWorkerJobData.cpp:
+ (WebCore::ServiceWorkerJobData::ServiceWorkerJobData):
+ * workers/service/ServiceWorkerJobData.h:
+ (WebCore::ServiceWorkerJobData::connectionIdentifier const):
+ (WebCore::ServiceWorkerJobData::decode):
+ * workers/service/ServiceWorkerTypes.h:
+ * workers/service/ServiceWorkerWindowClient.cpp:
+ (WebCore::ServiceWorkerWindowClient::ServiceWorkerWindowClient):
+ * workers/service/ServiceWorkerWindowClient.h:
+ * workers/service/context/SWContextManager.cpp:
+ (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope):
+ * workers/service/context/SWContextManager.h:
+ * workers/service/context/ServiceWorkerThread.cpp:
+ (WebCore::ServiceWorkerThread::postMessageToServiceWorkerGlobalScope):
+ * workers/service/context/ServiceWorkerThread.h:
+ * workers/service/server/SWClientConnection.h:
+ * workers/service/server/SWServer.cpp:
+ (WebCore::SWServer::Connection::Connection):
+ (WebCore::SWServer::Connection::scheduleJobInServer):
+ (WebCore::SWServer::rejectJob):
+ (WebCore::SWServer::resolveRegistrationJob):
+ (WebCore::SWServer::startScriptFetch):
+ (WebCore::SWServer::scriptFetchFinished):
+ * workers/service/server/SWServer.h:
+ (WebCore::SWServer::Connection::identifier const):
+ (WebCore::SWServer::getConnection):
+ * workers/service/server/SWServerRegistration.cpp:
+ (WebCore::SWServerRegistration::forEachConnection):
+ (WebCore::SWServerRegistration::addClientServiceWorkerRegistration):
+ (WebCore::SWServerRegistration::removeClientServiceWorkerRegistration):
+ (WebCore::SWServerRegistration::unregisterServerConnection):
+ * workers/service/server/SWServerRegistration.h:
+
2017-11-17 John Wilander <[email protected]>
Storage Access API: UI process should update network process about granted access
Modified: trunk/Source/WebCore/workers/service/ServiceWorker.cpp (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorker.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorker.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -28,6 +28,7 @@
#if ENABLE(SERVICE_WORKER)
+#include "Document.h"
#include "EventNames.h"
#include "MessagePort.h"
#include "SWClientConnection.h"
@@ -148,7 +149,7 @@
auto sourceClientData = ServiceWorkerClientData::from(context);
auto& swConnection = ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context.sessionID());
- swConnection.postMessageToServiceWorkerGlobalScope(identifier(), message.releaseReturnValue(), WTFMove(sourceClientData));
+ swConnection.postMessageToServiceWorkerGlobalScope(identifier(), message.releaseReturnValue(), downcast<Document>(context).identifier(), WTFMove(sourceClientData));
return { };
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -37,12 +37,11 @@
namespace WebCore {
-ServiceWorkerClient::ServiceWorkerClient(ScriptExecutionContext& context, ServiceWorkerClientData&& data)
+ServiceWorkerClient::ServiceWorkerClient(ScriptExecutionContext& context, ServiceWorkerClientIdentifier identifier, ServiceWorkerClientData&& data)
: ContextDestructionObserver(&context)
+ , m_identifier(identifier)
, m_data(WTFMove(data))
{
- ASSERT(m_data.identifier.serverConnectionIdentifier);
- ASSERT(m_data.identifier.scriptExecutionContextIdentifier);
}
ServiceWorkerClient::~ServiceWorkerClient()
@@ -66,7 +65,7 @@
String ServiceWorkerClient::id() const
{
- return m_data.identifier.toString();
+ return identifier().toString();
}
ExceptionOr<void> ServiceWorkerClient::postMessage(ScriptExecutionContext& context, JSC::JSValue messageValue, Vector<JSC::Strong<JSC::JSObject>>&& transfer)
@@ -90,7 +89,7 @@
return Exception { NotSupportedError, ASCIILiteral("Passing MessagePort objects to postMessage is not yet supported") };
auto sourceIdentifier = downcast<ServiceWorkerGlobalScope>(context).thread().identifier();
- callOnMainThread([message = message.releaseReturnValue(), destinationIdentifier = m_data.identifier, sourceIdentifier, sourceOrigin = context.origin().isolatedCopy()] () mutable {
+ callOnMainThread([message = message.releaseReturnValue(), destinationIdentifier = identifier(), sourceIdentifier, sourceOrigin = context.origin().isolatedCopy()] () mutable {
if (auto* connection = SWContextManager::singleton().connection())
connection->postMessageToServiceWorkerClient(destinationIdentifier, WTFMove(message), sourceIdentifier, sourceOrigin);
});
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClient.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerClient.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClient.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -46,9 +46,9 @@
using Type = ServiceWorkerClientType;
using FrameType = ServiceWorkerClientFrameType;
- static Ref<ServiceWorkerClient> create(ScriptExecutionContext& context, ServiceWorkerClientData&& data)
+ static Ref<ServiceWorkerClient> create(ScriptExecutionContext& context, ServiceWorkerClientIdentifier identifier, ServiceWorkerClientData&& data)
{
- return adoptRef(*new ServiceWorkerClient(context, WTFMove(data)));
+ return adoptRef(*new ServiceWorkerClient(context, identifier, WTFMove(data)));
}
~ServiceWorkerClient();
@@ -58,11 +58,14 @@
Type type() const;
String id() const;
+ Identifier identifier() const { return m_identifier; }
+
ExceptionOr<void> postMessage(ScriptExecutionContext&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&& transfer);
protected:
- ServiceWorkerClient(ScriptExecutionContext&, ServiceWorkerClientData&&);
+ ServiceWorkerClient(ScriptExecutionContext&, ServiceWorkerClientIdentifier, ServiceWorkerClientData&&);
+ ServiceWorkerClientIdentifier m_identifier;
ServiceWorkerClientData m_data;
};
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClientData.cpp (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerClientData.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClientData.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -56,7 +56,7 @@
ServiceWorkerClientData ServiceWorkerClientData::isolatedCopy() const
{
- return { identifier, type, frameType, url.isolatedCopy() };
+ return { type, frameType, url.isolatedCopy() };
}
ServiceWorkerClientData ServiceWorkerClientData::from(ScriptExecutionContext& context)
@@ -63,10 +63,7 @@
{
bool isDocument = is<Document>(context);
- ASSERT_WITH_MESSAGE(isDocument, "Only documents have identifiers at the moment");
-
return {
- { 0, downcast<Document>(context).identifier() },
isDocument ? ServiceWorkerClientType::Window : ServiceWorkerClientType::Worker,
toServiceWorkerClientFrameType(context),
context.url()
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClientData.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerClientData.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClientData.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -37,7 +37,6 @@
class ScriptExecutionContext;
struct ServiceWorkerClientData {
- ServiceWorkerClientIdentifier identifier;
ServiceWorkerClientType type;
ServiceWorkerClientFrameType frameType;
URL url;
@@ -53,17 +52,12 @@
template<class Encoder>
void ServiceWorkerClientData::encode(Encoder& encoder) const
{
- encoder << identifier << type << frameType << url;
+ encoder << type << frameType << url;
}
template<class Decoder>
std::optional<ServiceWorkerClientData> ServiceWorkerClientData::decode(Decoder& decoder)
{
- std::optional<ServiceWorkerClientIdentifier> identifier;
- decoder >> identifier;
- if (!identifier)
- return std::nullopt;
-
std::optional<ServiceWorkerClientType> type;
decoder >> type;
if (!type)
@@ -79,7 +73,7 @@
if (!url)
return std::nullopt;
- return { { WTFMove(*identifier), WTFMove(*type), WTFMove(*frameType), WTFMove(*url) } };
+ return { { WTFMove(*type), WTFMove(*frameType), WTFMove(*url) } };
}
} // namespace WebCore
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -25,15 +25,18 @@
#pragma once
+#if ENABLE(SERVICE_WORKER)
+
+#include "ServiceWorkerTypes.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
struct ServiceWorkerClientIdentifier {
- uint64_t serverConnectionIdentifier;
+ SWServerConnectionIdentifier serverConnectionIdentifier;
uint64_t scriptExecutionContextIdentifier;
- String toString() const { return String::number(serverConnectionIdentifier) + "-" + String::number(scriptExecutionContextIdentifier); }
+ String toString() const { return String::number(serverConnectionIdentifier.toUInt64()) + "-" + String::number(scriptExecutionContextIdentifier); }
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<ServiceWorkerClientIdentifier> decode(Decoder&);
@@ -48,7 +51,7 @@
template<class Decoder>
std::optional<ServiceWorkerClientIdentifier> ServiceWorkerClientIdentifier::decode(Decoder& decoder)
{
- std::optional<uint64_t> serverConnectionIdentifier;
+ std::optional<SWServerConnectionIdentifier> serverConnectionIdentifier;
decoder >> serverConnectionIdentifier;
if (!serverConnectionIdentifier)
return std::nullopt;
@@ -61,4 +64,6 @@
return { { WTFMove(*serverConnectionIdentifier), WTFMove(*scriptExecutionContextIdentifier) } };
}
-}
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -98,7 +98,7 @@
if (!m_swConnection)
m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(scriptExecutionContext()->sessionID());
- ServiceWorkerJobData jobData(m_swConnection->identifier());
+ ServiceWorkerJobData jobData(m_swConnection->serverConnectionIdentifier());
jobData.scriptURL = context->completeURL(relativeScriptURL);
if (!jobData.scriptURL.isValid()) {
@@ -156,7 +156,7 @@
return;
}
- ServiceWorkerJobData jobData(m_swConnection->identifier());
+ ServiceWorkerJobData jobData(m_swConnection->serverConnectionIdentifier());
jobData.clientCreationURL = context->url();
jobData.topOrigin = SecurityOriginData::fromSecurityOrigin(context->topOrigin());
jobData.type = ServiceWorkerJobType::Unregister;
@@ -180,7 +180,7 @@
return;
}
- ServiceWorkerJobData jobData(m_swConnection->identifier());
+ ServiceWorkerJobData jobData(m_swConnection->serverConnectionIdentifier());
jobData.clientCreationURL = context->url();
jobData.topOrigin = SecurityOriginData::fromSecurityOrigin(context->topOrigin());
jobData.type = ServiceWorkerJobType::Update;
@@ -383,10 +383,10 @@
unsetPendingActivity(this);
}
-uint64_t ServiceWorkerContainer::connectionIdentifier()
+SWServerConnectionIdentifier ServiceWorkerContainer::connectionIdentifier()
{
ASSERT(m_swConnection);
- return m_swConnection->identifier();
+ return m_swConnection->serverConnectionIdentifier();
}
const char* ServiceWorkerContainer::activeDOMObjectName() const
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -95,7 +95,7 @@
void jobDidFinish(ServiceWorkerJob&);
- uint64_t connectionIdentifier() final;
+ SWServerConnectionIdentifier connectionIdentifier() final;
const char* activeDOMObjectName() const final;
bool canSuspendForDocumentSuspension() const final;
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -29,12 +29,13 @@
#include "ResourceError.h"
#include "ServiceWorkerRegistrationKey.h"
+#include "ServiceWorkerTypes.h"
namespace WebCore {
struct ServiceWorkerFetchResult {
uint64_t jobIdentifier;
- uint64_t connectionIdentifier;
+ SWServerConnectionIdentifier connectionIdentifier;
ServiceWorkerRegistrationKey registrationKey;
String script;
ResourceError scriptError;
@@ -54,8 +55,12 @@
{
if (!decoder.decode(result.jobIdentifier))
return false;
- if (!decoder.decode(result.connectionIdentifier))
+
+ std::optional<SWServerConnectionIdentifier> connectionIdentifier;
+ decoder >> connectionIdentifier;
+ if (!connectionIdentifier)
return false;
+ result.connectionIdentifier = *connectionIdentifier;
auto registrationKey = ServiceWorkerRegistrationKey::decode(decoder);
if (!registrationKey)
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -27,6 +27,8 @@
#if ENABLE(SERVICE_WORKER)
+#include "ServiceWorkerTypes.h"
+
namespace WebCore {
class Exception;
@@ -46,7 +48,7 @@
virtual void jobFinishedLoadingScript(ServiceWorkerJob&, const String&) = 0;
virtual void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&, std::optional<Exception>&&) = 0;
- virtual uint64_t connectionIdentifier() = 0;
+ virtual SWServerConnectionIdentifier connectionIdentifier() = 0;
virtual void ref() = 0;
virtual void deref() = 0;
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJobData.cpp (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerJobData.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJobData.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -30,13 +30,13 @@
namespace WebCore {
-ServiceWorkerJobData::ServiceWorkerJobData(uint64_t jobIdentifier, uint64_t connectionIdentifier)
+ServiceWorkerJobData::ServiceWorkerJobData(uint64_t jobIdentifier, SWServerConnectionIdentifier connectionIdentifier)
: ThreadSafeIdentified(jobIdentifier)
, m_connectionIdentifier(connectionIdentifier)
{
}
-ServiceWorkerJobData::ServiceWorkerJobData(uint64_t connectionIdentifier)
+ServiceWorkerJobData::ServiceWorkerJobData(SWServerConnectionIdentifier connectionIdentifier)
: m_connectionIdentifier(connectionIdentifier)
{
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJobData.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerJobData.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJobData.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -31,6 +31,7 @@
#include "ServiceWorkerJobType.h"
#include "ServiceWorkerRegistrationKey.h"
#include "ServiceWorkerRegistrationOptions.h"
+#include "ServiceWorkerTypes.h"
#include "URL.h"
#include <wtf/Identified.h>
@@ -38,11 +39,11 @@
struct ServiceWorkerJobData : public ThreadSafeIdentified<ServiceWorkerJobData> {
public:
- explicit ServiceWorkerJobData(uint64_t connectionIdentifier);
+ explicit ServiceWorkerJobData(SWServerConnectionIdentifier);
ServiceWorkerJobData(const ServiceWorkerJobData&) = default;
ServiceWorkerJobData() = default;
- uint64_t connectionIdentifier() const { return m_connectionIdentifier; }
+ SWServerConnectionIdentifier connectionIdentifier() const { return m_connectionIdentifier; }
URL scriptURL;
URL clientCreationURL;
@@ -59,9 +60,9 @@
template<class Decoder> static std::optional<ServiceWorkerJobData> decode(Decoder&);
private:
- WEBCORE_EXPORT ServiceWorkerJobData(uint64_t jobIdentifier, uint64_t connectionIdentifier);
+ WEBCORE_EXPORT ServiceWorkerJobData(uint64_t jobIdentifier, SWServerConnectionIdentifier);
- uint64_t m_connectionIdentifier { 0 };
+ SWServerConnectionIdentifier m_connectionIdentifier;
};
template<class Encoder>
@@ -86,11 +87,12 @@
if (!decoder.decode(jobIdentifier))
return std::nullopt;
- uint64_t connectionIdentifier;
- if (!decoder.decode(connectionIdentifier))
+ std::optional<SWServerConnectionIdentifier> connectionIdentifier;
+ decoder >> connectionIdentifier;
+ if (!connectionIdentifier)
return std::nullopt;
- std::optional<ServiceWorkerJobData> jobData = { { jobIdentifier, connectionIdentifier } };
+ std::optional<ServiceWorkerJobData> jobData = { { jobIdentifier, *connectionIdentifier } };
if (!decoder.decode(jobData->scriptURL))
return std::nullopt;
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerTypes.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerTypes.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerTypes.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -61,6 +61,9 @@
enum SWServerToContextConnectionIdentifierType { };
using SWServerToContextConnectionIdentifier = ObjectIdentifier<SWServerToContextConnectionIdentifierType>;
+enum SWServerConnectionIdentifierType { };
+using SWServerConnectionIdentifier = ObjectIdentifier<SWServerConnectionIdentifierType>;
+
} // namespace WebCore
namespace WTF {
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -32,8 +32,8 @@
namespace WebCore {
-ServiceWorkerWindowClient::ServiceWorkerWindowClient(ScriptExecutionContext& context, ServiceWorkerClientData&& data)
- : ServiceWorkerClient(context, WTFMove(data))
+ServiceWorkerWindowClient::ServiceWorkerWindowClient(ScriptExecutionContext& context, ServiceWorkerClientIdentifier identifier, ServiceWorkerClientData&& data)
+ : ServiceWorkerClient(context, identifier, WTFMove(data))
{
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -36,9 +36,9 @@
class ServiceWorkerWindowClient final : public ServiceWorkerClient {
public:
- static Ref<ServiceWorkerWindowClient> create(ScriptExecutionContext& context, ServiceWorkerClientData&& data)
+ static Ref<ServiceWorkerWindowClient> create(ScriptExecutionContext& context, ServiceWorkerClientIdentifier identifier, ServiceWorkerClientData&& data)
{
- return adoptRef(*new ServiceWorkerWindowClient(context, WTFMove(data)));
+ return adoptRef(*new ServiceWorkerWindowClient(context, identifier, WTFMove(data)));
}
VisibilityState visibilityState() const;
@@ -48,7 +48,7 @@
void navigate(const String& url, Ref<DeferredPromise>&&);
private:
- ServiceWorkerWindowClient(ScriptExecutionContext&, ServiceWorkerClientData&&);
+ ServiceWorkerWindowClient(ScriptExecutionContext&, ServiceWorkerClientIdentifier, ServiceWorkerClientData&&);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.cpp (225007 => 225008)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -27,6 +27,7 @@
#if ENABLE(SERVICE_WORKER)
#include "SWContextManager.h"
+#include "ServiceWorkerClientIdentifier.h"
namespace WebCore {
@@ -64,7 +65,7 @@
return m_workerMap.get(identifier);
}
-void SWContextManager::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destination, Ref<SerializedScriptValue>&& message, ServiceWorkerClientData&& source)
+void SWContextManager::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destination, Ref<SerializedScriptValue>&& message, ServiceWorkerClientIdentifier sourceIdentifier, ServiceWorkerClientData&& sourceData)
{
auto* serviceWorker = m_workerMap.get(destination);
if (!serviceWorker)
@@ -71,7 +72,7 @@
return;
// FIXME: We should pass valid MessagePortChannels.
- serviceWorker->thread().postMessageToServiceWorkerGlobalScope(WTFMove(message), nullptr, WTFMove(source));
+ serviceWorker->thread().postMessageToServiceWorkerGlobalScope(WTFMove(message), nullptr, sourceIdentifier, WTFMove(sourceData));
}
void SWContextManager::fireInstallEvent(ServiceWorkerIdentifier identifier)
Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -58,7 +58,7 @@
WEBCORE_EXPORT void registerServiceWorkerThreadForInstall(Ref<ServiceWorkerThreadProxy>&&);
WEBCORE_EXPORT ServiceWorkerThreadProxy* serviceWorkerThreadProxy(ServiceWorkerIdentifier) const;
- WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destination, Ref<SerializedScriptValue>&& message, ServiceWorkerClientData&& source);
+ WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destination, Ref<SerializedScriptValue>&& message, ServiceWorkerClientIdentifier sourceIdentifier, ServiceWorkerClientData&& sourceData);
WEBCORE_EXPORT void fireInstallEvent(ServiceWorkerIdentifier);
WEBCORE_EXPORT void fireActivateEvent(ServiceWorkerIdentifier);
WEBCORE_EXPORT void terminateWorker(ServiceWorkerIdentifier);
Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (225007 => 225008)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -104,12 +104,12 @@
}, WorkerRunLoop::defaultMode());
}
-void ServiceWorkerThread::postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray>&& channels, ServiceWorkerClientData&& source)
+void ServiceWorkerThread::postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray>&& channels, ServiceWorkerClientIdentifier sourceIdentifier, ServiceWorkerClientData&& sourceData)
{
- ScriptExecutionContext::Task task([this, channels = WTFMove(channels), message = WTFMove(message), sourceData = source.isolatedCopy()] (ScriptExecutionContext& context) mutable {
+ ScriptExecutionContext::Task task([this, channels = WTFMove(channels), message = WTFMove(message), sourceIdentifier, sourceData = sourceData.isolatedCopy()] (ScriptExecutionContext& context) mutable {
auto& serviceWorkerGlobalScope = downcast<ServiceWorkerGlobalScope>(context);
auto ports = MessagePort::entanglePorts(serviceWorkerGlobalScope, WTFMove(channels));
- RefPtr<ServiceWorkerClient> source = ServiceWorkerWindowClient::create(context, WTFMove(sourceData));
+ RefPtr<ServiceWorkerClient> source = ServiceWorkerWindowClient::create(context, sourceIdentifier, WTFMove(sourceData));
auto sourceOrigin = SecurityOrigin::create(source->url());
auto messageEvent = ExtendableMessageEvent::create(WTFMove(ports), WTFMove(message), sourceOrigin->toString(), { }, ExtendableMessageEventSource { source });
serviceWorkerGlobalScope.dispatchEvent(messageEvent);
Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -57,7 +57,7 @@
WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
WEBCORE_EXPORT void postFetchTask(Ref<ServiceWorkerFetch::Client>&&, ResourceRequest&&, FetchOptions&&);
- WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&, ServiceWorkerClientData&& source);
+ WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&, ServiceWorkerClientIdentifier sourceIdentifier, ServiceWorkerClientData&& sourceData);
void fireInstallEvent();
void fireActivateEvent();
Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/server/SWClientConnection.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -68,8 +68,8 @@
virtual void didResolveRegistrationPromise(const ServiceWorkerRegistrationKey&) = 0;
- virtual void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&&, ServiceWorkerClientData&& source) = 0;
- virtual uint64_t identifier() const = 0;
+ virtual void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&&, uint64_t sourceContextIdentifier, ServiceWorkerClientData&& source) = 0;
+ virtual SWServerConnectionIdentifier serverConnectionIdentifier() const = 0;
virtual bool mayHaveServiceWorkerRegisteredForOrigin(const SecurityOrigin&) const = 0;
virtual void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) = 0;
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (225007 => 225008)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -50,9 +50,9 @@
return generateObjectIdentifier<ServiceWorkerIdentifierType>();
}
-SWServer::Connection::Connection(SWServer& server, uint64_t identifier)
- : Identified(identifier)
- , m_server(server)
+SWServer::Connection::Connection(SWServer& server)
+ : m_server(server)
+ , m_identifier(generateObjectIdentifier<SWServerConnectionIdentifierType>())
{
m_server.registerConnection(*this);
}
@@ -144,7 +144,7 @@
void SWServer::Connection::scheduleJobInServer(const ServiceWorkerJobData& jobData)
{
- LOG(ServiceWorker, "Scheduling ServiceWorker job %" PRIu64 "-%" PRIu64 " in server", jobData.connectionIdentifier(), jobData.identifier());
+ LOG(ServiceWorker, "Scheduling ServiceWorker job %s-%" PRIu64 " in server", jobData.connectionIdentifier().loggingString().utf8().data(), jobData.identifier());
ASSERT(identifier() == jobData.connectionIdentifier());
m_server.scheduleJob(jobData);
@@ -208,7 +208,7 @@
void SWServer::rejectJob(const ServiceWorkerJobData& jobData, const ExceptionData& exceptionData)
{
- LOG(ServiceWorker, "Rejected ServiceWorker job %" PRIu64 "-%" PRIu64 " in server", jobData.connectionIdentifier(), jobData.identifier());
+ LOG(ServiceWorker, "Rejected ServiceWorker job %s-%" PRIu64 " in server", jobData.connectionIdentifier().loggingString().utf8().data(), jobData.identifier());
auto* connection = m_connections.get(jobData.connectionIdentifier());
if (!connection)
return;
@@ -218,7 +218,7 @@
void SWServer::resolveRegistrationJob(const ServiceWorkerJobData& jobData, const ServiceWorkerRegistrationData& registrationData, ShouldNotifyWhenResolved shouldNotifyWhenResolved)
{
- LOG(ServiceWorker, "Resolved ServiceWorker job %" PRIu64 "-%" PRIu64 " in server with registration %s", jobData.connectionIdentifier(), jobData.identifier(), registrationData.identifier.loggingString().utf8().data());
+ LOG(ServiceWorker, "Resolved ServiceWorker job %s-%" PRIu64 " in server with registration %s", jobData.connectionIdentifier().loggingString().utf8().data(), jobData.identifier(), registrationData.identifier.loggingString().utf8().data());
auto* connection = m_connections.get(jobData.connectionIdentifier());
if (!connection)
return;
@@ -237,7 +237,7 @@
void SWServer::startScriptFetch(const ServiceWorkerJobData& jobData)
{
- LOG(ServiceWorker, "Server issuing startScriptFetch for current job %" PRIu64 "-%" PRIu64 " in client", jobData.connectionIdentifier(), jobData.identifier());
+ LOG(ServiceWorker, "Server issuing startScriptFetch for current job %s-%" PRIu64 " in client", jobData.connectionIdentifier().loggingString().utf8().data(), jobData.identifier());
auto* connection = m_connections.get(jobData.connectionIdentifier());
if (!connection)
return;
@@ -247,7 +247,7 @@
void SWServer::scriptFetchFinished(Connection& connection, const ServiceWorkerFetchResult& result)
{
- LOG(ServiceWorker, "Server handling scriptFetchFinished for current job %" PRIu64 "-%" PRIu64 " in client", result.connectionIdentifier, result.jobIdentifier);
+ LOG(ServiceWorker, "Server handling scriptFetchFinished for current job %s-%" PRIu64 " in client", result.connectionIdentifier.loggingString().utf8().data(), result.jobIdentifier);
ASSERT(m_connections.contains(result.connectionIdentifier));
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -37,7 +37,7 @@
#include <wtf/CrossThreadTask.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
-#include <wtf/Identified.h>
+#include <wtf/ObjectIdentifier.h>
#include <wtf/RunLoop.h>
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/Threading.h>
@@ -58,11 +58,14 @@
class SWServer {
public:
- class Connection : public Identified<Connection> {
+ class Connection {
friend class SWServer;
public:
WEBCORE_EXPORT virtual ~Connection();
+ using Identifier = SWServerConnectionIdentifier;
+ Identifier identifier() const { return m_identifier; }
+
WEBCORE_EXPORT void didResolveRegistrationPromise(const ServiceWorkerRegistrationKey&);
const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const { return m_server.doRegistrationMatching(topOrigin, clientURL); }
@@ -72,7 +75,7 @@
virtual void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier) = 0;
protected:
- WEBCORE_EXPORT Connection(SWServer&, uint64_t identifier);
+ WEBCORE_EXPORT explicit Connection(SWServer&);
SWServer& server() { return m_server; }
WEBCORE_EXPORT void scheduleJobInServer(const ServiceWorkerJobData&);
@@ -90,6 +93,7 @@
virtual void startScriptFetchInClient(uint64_t jobIdentifier) = 0;
SWServer& m_server;
+ Identifier m_identifier;
};
WEBCORE_EXPORT explicit SWServer(UniqueRef<SWOriginStore>&&);
@@ -119,7 +123,7 @@
void fireActivateEvent(SWServerWorker&);
SWServerWorker* workerByID(ServiceWorkerIdentifier identifier) const { return m_workersByID.get(identifier); }
- Connection* getConnection(uint64_t identifier) { return m_connections.get(identifier); }
+ Connection* getConnection(SWServerConnectionIdentifier identifier) { return m_connections.get(identifier); }
SWOriginStore& originStore() { return m_originStore; }
void scriptContextFailedToStart(SWServerWorker&, const String& message);
@@ -152,7 +156,7 @@
void installContextData(const ServiceWorkerContextData&);
- HashMap<uint64_t, Connection*> m_connections;
+ HashMap<SWServerConnectionIdentifier, Connection*> m_connections;
HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerRegistration>> m_registrations;
HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerJobQueue>> m_jobQueues;
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp (225007 => 225008)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -111,7 +111,7 @@
void SWServerRegistration::forEachConnection(const WTF::Function<void(SWServer::Connection&)>& apply)
{
- for (uint64_t connectionIdentifierWithClients : m_connectionsWithClientRegistrations.values()) {
+ for (auto connectionIdentifierWithClients : m_connectionsWithClientRegistrations.values()) {
if (auto* connection = m_server.getConnection(connectionIdentifierWithClients))
apply(*connection);
}
@@ -134,12 +134,12 @@
return { m_registrationKey, identifier(), m_scopeURL, m_updateViaCache, WTFMove(installingWorkerData), WTFMove(waitingWorkerData), WTFMove(activeWorkerData) };
}
-void SWServerRegistration::addClientServiceWorkerRegistration(uint64_t connectionIdentifier)
+void SWServerRegistration::addClientServiceWorkerRegistration(SWServerConnectionIdentifier connectionIdentifier)
{
m_connectionsWithClientRegistrations.add(connectionIdentifier);
}
-void SWServerRegistration::removeClientServiceWorkerRegistration(uint64_t connectionIdentifier)
+void SWServerRegistration::removeClientServiceWorkerRegistration(SWServerConnectionIdentifier connectionIdentifier)
{
m_connectionsWithClientRegistrations.remove(connectionIdentifier);
}
@@ -163,7 +163,7 @@
m_clientsUsingRegistration.remove(iterator);
}
-void SWServerRegistration::unregisterServerConnection(uint64_t serverConnectionIdentifier)
+void SWServerRegistration::unregisterServerConnection(SWServerConnectionIdentifier serverConnectionIdentifier)
{
m_connectionsWithClientRegistrations.removeAll(serverConnectionIdentifier);
m_clientsUsingRegistration.remove(serverConnectionIdentifier);
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.h (225007 => 225008)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -64,8 +64,8 @@
void updateWorkerState(SWServerWorker&, ServiceWorkerState);
void fireUpdateFoundEvent();
- void addClientServiceWorkerRegistration(uint64_t connectionIdentifier);
- void removeClientServiceWorkerRegistration(uint64_t connectionIdentifier);
+ void addClientServiceWorkerRegistration(SWServerConnectionIdentifier);
+ void removeClientServiceWorkerRegistration(SWServerConnectionIdentifier);
SWServerWorker* installingWorker() const { return m_installingWorker.get(); }
SWServerWorker* waitingWorker() const { return m_waitingWorker.get(); }
@@ -76,7 +76,7 @@
bool hasClientsUsingRegistration() const { return !m_clientsUsingRegistration.isEmpty(); }
void addClientUsingRegistration(const ServiceWorkerClientIdentifier&);
void removeClientUsingRegistration(const ServiceWorkerClientIdentifier&);
- void unregisterServerConnection(uint64_t serverConnectionIdentifier);
+ void unregisterServerConnection(SWServerConnectionIdentifier);
private:
void forEachConnection(const WTF::Function<void(SWServer::Connection&)>&);
@@ -94,11 +94,11 @@
double m_lastUpdateTime { 0 };
- HashCountedSet<uint64_t /* serverConnectionIdentifier */> m_connectionsWithClientRegistrations;
+ HashCountedSet<SWServerConnectionIdentifier> m_connectionsWithClientRegistrations;
SWServer& m_server;
MonotonicTime m_creationTime;
- HashMap<uint64_t /* serverConnectionIdentifier */, HashSet<uint64_t /* scriptExecutionContextIdentifier */>> m_clientsUsingRegistration;
+ HashMap<SWServerConnectionIdentifier, HashSet<uint64_t /* scriptExecutionContextIdentifier */>> m_clientsUsingRegistration;
};
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (225007 => 225008)
--- trunk/Source/WebKit/ChangeLog 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/ChangeLog 2017-11-18 02:27:13 UTC (rev 225008)
@@ -1,3 +1,54 @@
+2017-11-17 Chris Dumez <[email protected]>
+
+ Use a strongly typed identifier for SWServer::Connection
+ https://bugs.webkit.org/show_bug.cgi?id=179848
+
+ Reviewed by Brady Eidson.
+
+ Use a strongly typed identifier for SWServer::Connection, for clarity.
+
+ * Scripts/webkit/messages.py:
+ (forward_declarations_and_headers):
+ (forward_declarations_and_headers.templates):
+ (headers_for_type):
+ * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::WebSWServerConnection):
+ (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope):
+ * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+ * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+ * StorageProcess/StorageProcess.cpp:
+ (WebKit::StorageProcess::didFailFetch):
+ (WebKit::StorageProcess::didNotHandleFetch):
+ (WebKit::StorageProcess::didReceiveFetchResponse):
+ (WebKit::StorageProcess::didReceiveFetchData):
+ (WebKit::StorageProcess::didReceiveFetchFormData):
+ (WebKit::StorageProcess::didFinishFetch):
+ * StorageProcess/StorageProcess.h:
+ * StorageProcess/StorageProcess.messages.in:
+ * StorageProcess/StorageToWebProcessConnection.cpp:
+ (WebKit::StorageToWebProcessConnection::didReceiveMessage):
+ (WebKit::StorageToWebProcessConnection::establishSWServerConnection):
+ (WebKit::StorageToWebProcessConnection::removeSWServerConnection):
+ (WebKit::generateIDBConnectionToServerIdentifier):
+ (WebKit::StorageToWebProcessConnection::establishIDBConnectionToServer):
+ * StorageProcess/StorageToWebProcessConnection.h:
+ * StorageProcess/StorageToWebProcessConnection.messages.in:
+ * WebProcess/Storage/WebSWClientConnection.cpp:
+ (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope):
+ * WebProcess/Storage/WebSWClientConnection.h:
+ * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+ (WebKit::WebSWContextManagerConnection::startFetch):
+ (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope):
+ * WebProcess/Storage/WebSWContextManagerConnection.h:
+ * WebProcess/Storage/WebSWContextManagerConnection.messages.in:
+ * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:
+ (WebKit::WebServiceWorkerFetchTaskClient::WebServiceWorkerFetchTaskClient):
+ * WebProcess/Storage/WebServiceWorkerFetchTaskClient.h:
+ * WebProcess/Storage/WebToStorageProcessConnection.cpp:
+ (WebKit::WebToStorageProcessConnection::didReceiveMessage):
+ (WebKit::WebToStorageProcessConnection::serviceWorkerConnectionForSession):
+ * WebProcess/Storage/WebToStorageProcessConnection.h:
+
2017-11-17 John Wilander <[email protected]>
Storage Access API: UI process should update network process about granted access
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (225007 => 225008)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2017-11-18 02:27:13 UTC (rev 225008)
@@ -183,12 +183,18 @@
headers.add('<wtf/ThreadSafeRefCounted.h>')
types_by_namespace['IPC'].update([('class', 'Connection')])
+ no_forward_declaration_types = frozenset([
+ 'WebCore::ServiceWorkerIdentifier',
+ 'WebCore::ServiceWorkerRegistrationIdentifier',
+ 'WebCore::SWServerConnectionIdentifier',
+ ])
+
for parameter in receiver.iterparameters():
kind = parameter.kind
type = parameter.type
- if type.find('<') != -1 or type == "WebCore::ServiceWorkerIdentifier" or type == "WebCore::ServiceWorkerRegistrationIdentifier":
- # Don't forward declare class templates or ServiceWorkerIdentifier.
+ if type.find('<') != -1 or type in no_forward_declaration_types:
+ # Don't forward declare class templates.
headers.update(headers_for_type(type))
continue
@@ -372,6 +378,7 @@
'WebCore::PluginInfo': ['<WebCore/PluginData.h>'],
'WebCore::PolicyAction': ['<WebCore/FrameLoaderTypes.h>'],
'WebCore::RecentSearch': ['<WebCore/SearchPopupMenu.h>'],
+ 'WebCore::SWServerConnectionIdentifier': ['<WebCore/ServiceWorkerTypes.h>'],
'WebCore::ServiceWorkerRegistrationIdentifier': ['<WebCore/ServiceWorkerTypes.h>'],
'WebCore::ServiceWorkerRegistrationState': ['<WebCore/ServiceWorkerTypes.h>'],
'WebCore::ServiceWorkerState': ['<WebCore/ServiceWorkerTypes.h>'],
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (225007 => 225008)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -56,8 +56,8 @@
namespace WebKit {
-WebSWServerConnection::WebSWServerConnection(SWServer& server, IPC::Connection& connection, uint64_t connectionIdentifier, SessionID sessionID)
- : SWServer::Connection(server, connectionIdentifier)
+WebSWServerConnection::WebSWServerConnection(SWServer& server, IPC::Connection& connection, SessionID sessionID)
+ : SWServer::Connection(server)
, m_sessionID(sessionID)
, m_contentConnection(connection)
{
@@ -112,10 +112,10 @@
sendToContextProcess(Messages::WebSWContextManagerConnection::StartFetch { identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options, formData });
}
-void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationServiceWorkerIdentifier, const IPC::DataReference& message, ServiceWorkerClientData&& source)
+void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationServiceWorkerIdentifier, const IPC::DataReference& message, uint64_t sourceContextIdentifier, ServiceWorkerClientData&& sourceData)
{
- source.identifier.serverConnectionIdentifier = identifier();
- sendToContextProcess(Messages::WebSWContextManagerConnection::PostMessageToServiceWorkerGlobalScope { destinationServiceWorkerIdentifier, message, WTFMove(source) });
+ ServiceWorkerClientIdentifier sourceIdentifier { identifier(), sourceContextIdentifier };
+ sendToContextProcess(Messages::WebSWContextManagerConnection::PostMessageToServiceWorkerGlobalScope { destinationServiceWorkerIdentifier, message, sourceIdentifier, WTFMove(sourceData) });
}
void WebSWServerConnection::didReceiveFetchResponse(uint64_t fetchIdentifier, const ResourceResponse& response)
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (225007 => 225008)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -46,7 +46,7 @@
class WebSWServerConnection : public WebCore::SWServer::Connection, public IPC::MessageSender, public IPC::MessageReceiver {
public:
- WebSWServerConnection(WebCore::SWServer&, IPC::Connection&, uint64_t connectionIdentifier, PAL::SessionID);
+ WebSWServerConnection(WebCore::SWServer&, IPC::Connection&, PAL::SessionID);
WebSWServerConnection(const WebSWServerConnection&) = delete;
~WebSWServerConnection() final;
@@ -76,13 +76,13 @@
void startFetch(uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, const WebCore::ResourceRequest&, const WebCore::FetchOptions&, const IPC::FormDataReference&);
- void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerClientData&& source);
+ void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, uint64_t sourceContextIdentifier, WebCore::ServiceWorkerClientData&& source);
void matchRegistration(uint64_t registrationMatchRequestIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::URL& clientURL);
void getRegistrations(uint64_t registrationMatchRequestIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::URL& clientURL);
IPC::Connection* messageSenderConnection() final { return m_contentConnection.ptr(); }
- uint64_t messageSenderDestinationID() final { return identifier(); }
+ uint64_t messageSenderDestinationID() final { return identifier().toUInt64(); }
template<typename U> void sendToContextProcess(U&& message);
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in (225007 => 225008)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in 2017-11-18 02:27:13 UTC (rev 225008)
@@ -32,7 +32,7 @@
ServiceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
StartFetch(uint64_t identifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options, IPC::FormDataReference requestBody)
- PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationServiceWorkerIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientData source)
+ PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationServiceWorkerIdentifier, IPC::DataReference message, uint64_t sourceContextIdentifier, struct WebCore::ServiceWorkerClientData source)
DidResolveRegistrationPromise(WebCore::ServiceWorkerRegistrationKey key)
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.cpp (225007 => 225008)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -410,37 +410,37 @@
connection->workerContextProcessConnectionCreated();
}
-void StorageProcess::didFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
+void StorageProcess::didFailFetch(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier)
{
if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
connection->didFailFetch(fetchIdentifier);
}
-void StorageProcess::didNotHandleFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
+void StorageProcess::didNotHandleFetch(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier)
{
if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
connection->didNotHandleFetch(fetchIdentifier);
}
-void StorageProcess::didReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const WebCore::ResourceResponse& response)
+void StorageProcess::didReceiveFetchResponse(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, const WebCore::ResourceResponse& response)
{
if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
connection->didReceiveFetchResponse(fetchIdentifier, response);
}
-void StorageProcess::didReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::DataReference& data, int64_t encodedDataLength)
+void StorageProcess::didReceiveFetchData(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::DataReference& data, int64_t encodedDataLength)
{
if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
connection->didReceiveFetchData(fetchIdentifier, data, encodedDataLength);
}
-void StorageProcess::didReceiveFetchFormData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::FormDataReference& formData)
+void StorageProcess::didReceiveFetchFormData(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::FormDataReference& formData)
{
if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
connection->didReceiveFetchFormData(fetchIdentifier, formData);
}
-void StorageProcess::didFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
+void StorageProcess::didFinishFetch(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier)
{
if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
connection->didFinishFetch(fetchIdentifier);
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.h (225007 => 225008)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -30,6 +30,7 @@
#include <WebCore/IDBBackingStore.h>
#include <WebCore/IDBServer.h>
#include <WebCore/ServiceWorkerIdentifier.h>
+#include <WebCore/ServiceWorkerTypes.h>
#include <WebCore/UniqueIDBDatabase.h>
#include <pal/SessionID.h>
#include <wtf/CrossThreadTask.h>
@@ -124,12 +125,12 @@
#if ENABLE(SERVICE_WORKER)
void didGetWorkerContextProcessConnection(IPC::Attachment&& encodedConnectionIdentifier);
- void didReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const WebCore::ResourceResponse&);
- void didReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::DataReference&, int64_t encodedDataLength);
- void didReceiveFetchFormData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::FormDataReference&);
- void didFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier);
- void didFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier);
- void didNotHandleFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier);
+ void didReceiveFetchResponse(WebCore::SWServerConnectionIdentifier, uint64_t fetchIdentifier, const WebCore::ResourceResponse&);
+ void didReceiveFetchData(WebCore::SWServerConnectionIdentifier, uint64_t fetchIdentifier, const IPC::DataReference&, int64_t encodedDataLength);
+ void didReceiveFetchFormData(WebCore::SWServerConnectionIdentifier, uint64_t fetchIdentifier, const IPC::FormDataReference&);
+ void didFinishFetch(WebCore::SWServerConnectionIdentifier, uint64_t fetchIdentifier);
+ void didFailFetch(WebCore::SWServerConnectionIdentifier, uint64_t fetchIdentifier);
+ void didNotHandleFetch(WebCore::SWServerConnectionIdentifier, uint64_t fetchIdentifier);
void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin);
WebSWOriginStore& swOriginStoreForSession(PAL::SessionID);
@@ -162,7 +163,7 @@
RefPtr<WebSWServerToContextConnection> m_serverToContextConnection;
bool m_waitingForServerToContextProcessConnection { false };
HashMap<PAL::SessionID, std::unique_ptr<WebCore::SWServer>> m_swServers;
- HashMap<uint64_t, WebSWServerConnection*> m_swServerConnections;
+ HashMap<WebCore::SWServerConnectionIdentifier, WebSWServerConnection*> m_swServerConnections;
#endif
};
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in (225007 => 225008)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in 2017-11-18 02:27:13 UTC (rev 225008)
@@ -38,12 +38,12 @@
#if ENABLE(SERVICE_WORKER)
DidGetWorkerContextProcessConnection(IPC::Attachment connectionHandle)
- DidNotHandleFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
- DidFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
- DidReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, WebCore::ResourceResponse response)
- DidReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, IPC::DataReference data, int64_t encodedDataLength)
- DidReceiveFetchFormData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, IPC::FormDataReference data)
- DidFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
+ DidNotHandleFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier)
+ DidFailFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier)
+ DidReceiveFetchResponse(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, WebCore::ResourceResponse response)
+ DidReceiveFetchData(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, IPC::DataReference data, int64_t encodedDataLength)
+ DidReceiveFetchFormData(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, IPC::FormDataReference data)
+ DidFinishFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier)
PostMessageToServiceWorkerClient(struct WebCore::ServiceWorkerClientIdentifier destinationIdentifier, IPC::DataReference message, WebCore::ServiceWorkerIdentifier sourceIdentifier, String sourceOrigin)
#endif
}
Modified: trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp (225007 => 225008)
--- trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -85,7 +85,7 @@
#if ENABLE(SERVICE_WORKER)
if (decoder.messageReceiverName() == Messages::WebSWServerConnection::messageReceiverName()) {
- auto iterator = m_swConnections.find(decoder.destinationID());
+ auto iterator = m_swConnections.find(makeObjectIdentifier<SWServerConnectionIdentifierType>(decoder.destinationID()));
if (iterator != m_swConnections.end())
iterator->value->didReceiveMessage(connection, decoder);
return;
@@ -138,31 +138,26 @@
}
-static uint64_t generateConnectionToServerIdentifier()
+#if ENABLE(SERVICE_WORKER)
+void StorageToWebProcessConnection::establishSWServerConnection(SessionID sessionID, SWServerConnectionIdentifier& serverConnectionIdentifier)
{
- ASSERT(RunLoop::isMain());
- static uint64_t identifier = 0;
- return ++identifier;
-}
+ auto& server = StorageProcess::singleton().swServerForSession(sessionID);
+ auto connection = std::make_unique<WebSWServerConnection>(server, m_connection.get(), sessionID);
-#if ENABLE(SERVICE_WORKER)
-void StorageToWebProcessConnection::establishSWServerConnection(SessionID sessionID, uint64_t& serverConnectionIdentifier)
-{
- serverConnectionIdentifier = generateConnectionToServerIdentifier();
- LOG(ServiceWorker, "StorageToWebProcessConnection::establishSWServerConnection - %" PRIu64, serverConnectionIdentifier);
+ serverConnectionIdentifier = connection->identifier();
+ LOG(ServiceWorker, "StorageToWebProcessConnection::establishSWServerConnection - %s", serverConnectionIdentifier.loggingString().utf8().data());
ASSERT(!m_swConnections.contains(serverConnectionIdentifier));
- auto& server = StorageProcess::singleton().swServerForSession(sessionID);
- auto connectionResult = m_swConnections.add(serverConnectionIdentifier, std::make_unique<WebSWServerConnection>(server, m_connection.get(), serverConnectionIdentifier, sessionID));
- ASSERT(connectionResult.isNewEntry);
+ auto addResult = m_swConnections.add(serverConnectionIdentifier, WTFMove(connection));
+ ASSERT(addResult.isNewEntry);
- StorageProcess::singleton().registerSWServerConnection(*(connectionResult.iterator->value));
+ StorageProcess::singleton().registerSWServerConnection(*(addResult.iterator->value));
if (!StorageProcess::singleton().globalServerToContextConnection())
StorageProcess::singleton().createServerToContextConnection();
}
-void StorageToWebProcessConnection::removeSWServerConnection(uint64_t serverConnectionIdentifier)
+void StorageToWebProcessConnection::removeSWServerConnection(WebCore::SWServer::Connection::Identifier serverConnectionIdentifier)
{
ASSERT(m_swConnections.contains(serverConnectionIdentifier));
@@ -179,9 +174,16 @@
#endif
#if ENABLE(INDEXED_DATABASE)
+static uint64_t generateIDBConnectionToServerIdentifier()
+{
+ ASSERT(RunLoop::isMain());
+ static uint64_t identifier = 0;
+ return ++identifier;
+}
+
void StorageToWebProcessConnection::establishIDBConnectionToServer(SessionID sessionID, uint64_t& serverConnectionIdentifier)
{
- serverConnectionIdentifier = generateConnectionToServerIdentifier();
+ serverConnectionIdentifier = generateIDBConnectionToServerIdentifier();
LOG(IndexedDB, "StorageToWebProcessConnection::establishIDBConnectionToServer - %" PRIu64, serverConnectionIdentifier);
ASSERT(!m_webIDBConnections.contains(serverConnectionIdentifier));
Modified: trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.h (225007 => 225008)
--- trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -72,9 +72,9 @@
#endif // ENABLE(INDEXED_DATABASE)
#if ENABLE(SERVICE_WORKER)
- void establishSWServerConnection(PAL::SessionID, uint64_t& serverConnectionIdentifier);
- void removeSWServerConnection(uint64_t serverConnectionIdentifier);
- HashMap<uint64_t, std::unique_ptr<WebSWServerConnection>> m_swConnections;
+ void establishSWServerConnection(PAL::SessionID, WebCore::SWServerConnectionIdentifier&);
+ void removeSWServerConnection(WebCore::SWServerConnectionIdentifier);
+ HashMap<WebCore::SWServerConnectionIdentifier, std::unique_ptr<WebSWServerConnection>> m_swConnections;
#endif
Ref<IPC::Connection> m_connection;
Modified: trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.messages.in (225007 => 225008)
--- trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.messages.in 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.messages.in 2017-11-18 02:27:13 UTC (rev 225008)
@@ -26,7 +26,7 @@
RemoveIDBConnectionToServer(uint64_t serverConnectionIdentifier)
#endif
#if ENABLE(SERVICE_WORKER)
- EstablishSWServerConnection(PAL::SessionID sessionID) -> (uint64_t serverConnectionIdentifier)
- RemoveSWServerConnection(uint64_t serverConnectionIdentifier)
+ EstablishSWServerConnection(PAL::SessionID sessionID) -> (WebCore::SWServerConnectionIdentifier serverConnectionIdentifier)
+ RemoveSWServerConnection(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier)
#endif
}
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (225007 => 225008)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -82,9 +82,9 @@
send(Messages::WebSWServerConnection::RemoveServiceWorkerRegistrationInServer(key, identifier));
}
-void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&& scriptValue, ServiceWorkerClientData&& source)
+void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&& scriptValue, uint64_t sourceContextIdentifier, ServiceWorkerClientData&& source)
{
- send(Messages::WebSWServerConnection::PostMessageToServiceWorkerGlobalScope(destinationIdentifier, IPC::DataReference { scriptValue->data() }, WTFMove(source)));
+ send(Messages::WebSWServerConnection::PostMessageToServiceWorkerGlobalScope(destinationIdentifier, IPC::DataReference { scriptValue->data() }, sourceContextIdentifier, WTFMove(source)));
}
void WebSWClientConnection::serviceWorkerStartedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (225007 => 225008)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -52,7 +52,7 @@
WebSWClientConnection(const WebSWClientConnection&) = delete;
~WebSWClientConnection() final;
- uint64_t identifier() const final { return m_identifier; }
+ WebCore::SWServerConnectionIdentifier serverConnectionIdentifier() const final { return m_identifier; }
void addServiceWorkerRegistrationInServer(const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerRegistrationIdentifier) final;
void removeServiceWorkerRegistrationInServer(const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerRegistrationIdentifier) final;
@@ -68,7 +68,7 @@
private:
void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final;
void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final;
- void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, Ref<WebCore::SerializedScriptValue>&&, WebCore::ServiceWorkerClientData&& source) final;
+ void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, Ref<WebCore::SerializedScriptValue>&&, uint64_t sourceContextIdentifier, WebCore::ServiceWorkerClientData&& source) final;
void serviceWorkerStartedControllingClient(WebCore::ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) final;
void serviceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) final;
@@ -83,13 +83,13 @@
void scheduleStorageJob(const WebCore::ServiceWorkerJobData&);
IPC::Connection* messageSenderConnection() final { return m_connection.ptr(); }
- uint64_t messageSenderDestinationID() final { return m_identifier; }
+ uint64_t messageSenderDestinationID() final { return m_identifier.toUInt64(); }
void setSWOriginTableSharedMemory(const SharedMemory::Handle&);
void initializeSWOriginTableAsEmpty();
PAL::SessionID m_sessionID;
- uint64_t m_identifier;
+ WebCore::SWServerConnectionIdentifier m_identifier;
Ref<IPC::Connection> m_connection;
UniqueRef<WebSWOriginTable> m_swOriginTable;
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (225007 => 225008)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -132,7 +132,7 @@
m_connectionToStorageProcess->send(Messages::WebSWServerToContextConnection::ScriptContextFailedToStart(serviceWorkerIdentifier, exceptionMessage), 0);
}
-void WebSWContextManagerConnection::startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options, IPC::FormDataReference&& formData)
+void WebSWContextManagerConnection::startFetch(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options, IPC::FormDataReference&& formData)
{
auto* serviceWorkerThreadProxy = serviceWorkerIdentifier ? SWContextManager::singleton().serviceWorkerThreadProxy(*serviceWorkerIdentifier) : nullptr;
if (!serviceWorkerThreadProxy) {
@@ -146,9 +146,9 @@
serviceWorkerThreadProxy->thread().postFetchTask(WTFMove(client), WTFMove(request), WTFMove(options));
}
-void WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, ServiceWorkerClientData&& source)
+void WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, ServiceWorkerClientIdentifier sourceIdentifier, ServiceWorkerClientData&& sourceData)
{
- SWContextManager::singleton().postMessageToServiceWorkerGlobalScope(destinationIdentifier, SerializedScriptValue::adopt(message.vector()), WTFMove(source));
+ SWContextManager::singleton().postMessageToServiceWorkerGlobalScope(destinationIdentifier, SerializedScriptValue::adopt(message.vector()), sourceIdentifier, WTFMove(sourceData));
}
void WebSWContextManagerConnection::fireInstallEvent(ServiceWorkerIdentifier identifier)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h (225007 => 225008)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -30,6 +30,7 @@
#include "Connection.h"
#include "MessageReceiver.h"
#include <WebCore/SWContextManager.h>
+#include <WebCore/ServiceWorkerTypes.h>
namespace IPC {
class FormDataReference;
@@ -64,8 +65,8 @@
// IPC messages.
void serviceWorkerStartedWithMessage(WebCore::ServiceWorkerIdentifier, const String& exceptionMessage) final;
void installServiceWorker(const WebCore::ServiceWorkerContextData&);
- void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, WebCore::ResourceRequest&&, WebCore::FetchOptions&&, IPC::FormDataReference&&);
- void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerClientData&& source);
+ void startFetch(WebCore::SWServerConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, WebCore::ResourceRequest&&, WebCore::FetchOptions&&, IPC::FormDataReference&&);
+ void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerClientIdentifier sourceIdentifier, WebCore::ServiceWorkerClientData&& sourceData);
void fireInstallEvent(WebCore::ServiceWorkerIdentifier);
void fireActivateEvent(WebCore::ServiceWorkerIdentifier);
void terminateWorker(WebCore::ServiceWorkerIdentifier);
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in (225007 => 225008)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in 2017-11-18 02:27:13 UTC (rev 225008)
@@ -24,8 +24,8 @@
messages -> WebSWContextManagerConnection {
InstallServiceWorker(struct WebCore::ServiceWorkerContextData contextData)
- StartFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options, IPC::FormDataReference requestBody)
- PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientData source)
+ StartFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options, IPC::FormDataReference requestBody)
+ PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientIdentifier sourceIdentifier, struct WebCore::ServiceWorkerClientData sourceData)
FireInstallEvent(WebCore::ServiceWorkerIdentifier identifier)
FireActivateEvent(WebCore::ServiceWorkerIdentifier identifier)
TerminateWorker(WebCore::ServiceWorkerIdentifier identifier)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp (225007 => 225008)
--- trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -45,7 +45,7 @@
RunLoop::main().dispatch([connection = WTFMove(m_connection)] { });
}
-WebServiceWorkerFetchTaskClient::WebServiceWorkerFetchTaskClient(Ref<IPC::Connection>&& connection, uint64_t serverConnectionIdentifier, uint64_t fetchTaskIdentifier)
+WebServiceWorkerFetchTaskClient::WebServiceWorkerFetchTaskClient(Ref<IPC::Connection>&& connection, WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchTaskIdentifier)
: m_connection(WTFMove(connection))
, m_serverConnectionIdentifier(serverConnectionIdentifier)
, m_fetchTaskIdentifier(fetchTaskIdentifier)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h (225007 => 225008)
--- trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -29,12 +29,13 @@
#include "Connection.h"
#include <WebCore/ServiceWorkerFetch.h>
+#include <WebCore/ServiceWorkerTypes.h>
namespace WebKit {
class WebServiceWorkerFetchTaskClient final : public WebCore::ServiceWorkerFetch::Client {
public:
- static Ref<WebServiceWorkerFetchTaskClient> create(Ref<IPC::Connection>&& connection, uint64_t serverConnectionIdentifier, uint64_t fetchTaskIdentifier)
+ static Ref<WebServiceWorkerFetchTaskClient> create(Ref<IPC::Connection>&& connection, WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchTaskIdentifier)
{
return adoptRef(*new WebServiceWorkerFetchTaskClient(WTFMove(connection), serverConnectionIdentifier, fetchTaskIdentifier));
}
@@ -42,7 +43,7 @@
~WebServiceWorkerFetchTaskClient();
private:
- WebServiceWorkerFetchTaskClient(Ref<IPC::Connection>&&, uint64_t serverConnectionIdentifier, uint64_t fetchTaskIdentifier);
+ WebServiceWorkerFetchTaskClient(Ref<IPC::Connection>&&, WebCore::SWServerConnectionIdentifier, uint64_t fetchTaskIdentifier);
void didReceiveResponse(const WebCore::ResourceResponse&) final;
void didReceiveData(Ref<WebCore::SharedBuffer>&&) final;
@@ -52,7 +53,7 @@
void didNotHandle() final;
RefPtr<IPC::Connection> m_connection;
- uint64_t m_serverConnectionIdentifier { 0 };
+ WebCore::SWServerConnectionIdentifier m_serverConnectionIdentifier;
uint64_t m_fetchTaskIdentifier { 0 };
};
Modified: trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp (225007 => 225008)
--- trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp 2017-11-18 02:27:13 UTC (rev 225008)
@@ -64,7 +64,7 @@
#if ENABLE(SERVICE_WORKER)
if (decoder.messageReceiverName() == Messages::WebSWClientConnection::messageReceiverName()) {
- auto serviceWorkerConnection = m_swConnectionsByIdentifier.get(decoder.destinationID());
+ auto serviceWorkerConnection = m_swConnectionsByIdentifier.get(makeObjectIdentifier<SWServerConnectionIdentifierType>(decoder.destinationID()));
if (serviceWorkerConnection)
serviceWorkerConnection->didReceiveMessage(connection, decoder);
return;
@@ -114,8 +114,8 @@
auto result = m_swConnectionsBySession.add(sessionID, nullptr);
if (result.isNewEntry) {
result.iterator->value = std::make_unique<WebSWClientConnection>(m_connection.get(), sessionID);
- ASSERT(!m_swConnectionsByIdentifier.contains(result.iterator->value->identifier()));
- m_swConnectionsByIdentifier.set(result.iterator->value->identifier(), result.iterator->value.get());
+ ASSERT(!m_swConnectionsByIdentifier.contains(result.iterator->value->serverConnectionIdentifier()));
+ m_swConnectionsByIdentifier.set(result.iterator->value->serverConnectionIdentifier(), result.iterator->value.get());
}
return *result.iterator->value;
Modified: trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.h (225007 => 225008)
--- trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.h 2017-11-18 01:57:57 UTC (rev 225007)
+++ trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.h 2017-11-18 02:27:13 UTC (rev 225008)
@@ -78,7 +78,7 @@
#if ENABLE(SERVICE_WORKER)
HashMap<PAL::SessionID, std::unique_ptr<WebSWClientConnection>> m_swConnectionsBySession;
- HashMap<uint64_t, WebSWClientConnection*> m_swConnectionsByIdentifier;
+ HashMap<WebCore::SWServerConnectionIdentifier, WebSWClientConnection*> m_swConnectionsByIdentifier;
#endif
};