Diff
Modified: trunk/Source/WebKit/ChangeLog (256302 => 256303)
--- trunk/Source/WebKit/ChangeLog 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/ChangeLog 2020-02-11 14:08:30 UTC (rev 256303)
@@ -1,3 +1,52 @@
+2020-02-11 Youenn Fablet <[email protected]>
+
+ Use ObjectIdentifier for WebSocketStream/WebSocketChannel
+ https://bugs.webkit.org/show_bug.cgi?id=207507
+
+ Reviewed by Alex Christensen.
+
+ Replace uint64_t by ObjectIdentifier.
+ This adds type safety and ensures we get valid identifiers from IPC.
+ We still need to check for destinationID being not null in a few places.
+ No observable change of behavior.
+
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::didReceiveMessage):
+ (WebKit::NetworkConnectionToWebProcess::createSocketStream):
+ (WebKit::NetworkConnectionToWebProcess::createSocketChannel):
+ (WebKit::NetworkConnectionToWebProcess::removeSocketChannel):
+ * NetworkProcess/NetworkConnectionToWebProcess.h:
+ * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+ * NetworkProcess/NetworkSocketChannel.cpp:
+ (WebKit::NetworkSocketChannel::create):
+ (WebKit::NetworkSocketChannel::NetworkSocketChannel):
+ * NetworkProcess/NetworkSocketChannel.h:
+ * NetworkProcess/NetworkSocketStream.cpp:
+ (WebKit::NetworkSocketStream::create):
+ (WebKit::NetworkSocketStream::NetworkSocketStream):
+ (WebKit::NetworkSocketStream::messageSenderDestinationID const):
+ * NetworkProcess/NetworkSocketStream.h:
+ * Scripts/webkit/messages.py:
+ * WebKit.xcodeproj/project.pbxproj:
+ * WebProcess/Network/NetworkProcessConnection.cpp:
+ (WebKit::NetworkProcessConnection::didReceiveMessage):
+ * WebProcess/Network/WebSocketChannel.cpp:
+ (WebKit::WebSocketChannel::WebSocketChannel):
+ (WebKit::WebSocketChannel::messageSenderDestinationID const):
+ (WebKit::WebSocketChannel::connect):
+ * WebProcess/Network/WebSocketChannel.h:
+ (WebKit::WebSocketChannel::identifier const):
+ * WebProcess/Network/WebSocketChannelManager.cpp:
+ (WebKit::WebSocketChannelManager::didReceiveMessage):
+ * WebProcess/Network/WebSocketChannelManager.h:
+ * WebProcess/Network/WebSocketIdentifier.h: Added.
+ * WebProcess/Network/WebSocketStream.cpp:
+ (WebKit::WebSocketStream::streamWithIdentifier):
+ (WebKit::WebSocketStream::WebSocketStream):
+ (WebKit::WebSocketStream::~WebSocketStream):
+ (WebKit::WebSocketStream::messageSenderDestinationID const):
+ * WebProcess/Network/WebSocketStream.h:
+
2020-02-11 chris fleizach <[email protected]>
AX: Unable to build webkit open source - build errors related to AXClientType
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (256302 => 256303)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2020-02-11 14:08:30 UTC (rev 256303)
@@ -61,6 +61,7 @@
#include "WebSWServerConnectionMessages.h"
#include "WebSWServerToContextConnection.h"
#include "WebSWServerToContextConnectionMessages.h"
+#include "WebSocketIdentifier.h"
#include "WebsiteDataStoreParameters.h"
#include <WebCore/DocumentStorageAccess.h>
#include <WebCore/HTTPCookieAcceptPolicy.h>
@@ -175,16 +176,16 @@
}
if (decoder.messageReceiverName() == Messages::NetworkSocketStream::messageReceiverName()) {
- if (auto* socketStream = m_networkSocketStreams.get(decoder.destinationID())) {
+ if (auto* socketStream = m_networkSocketStreams.get(makeObjectIdentifier<WebSocketIdentifierType>(decoder.destinationID()))) {
socketStream->didReceiveMessage(connection, decoder);
if (decoder.messageName() == Messages::NetworkSocketStream::Close::name())
- m_networkSocketStreams.remove(decoder.destinationID());
+ m_networkSocketStreams.remove(makeObjectIdentifier<WebSocketIdentifierType>(decoder.destinationID()));
}
return;
}
if (decoder.messageReceiverName() == Messages::NetworkSocketChannel::messageReceiverName()) {
- if (auto* channel = m_networkSocketChannels.get(decoder.destinationID()))
+ if (auto* channel = m_networkSocketChannels.get(makeObjectIdentifier<WebSocketIdentifierType>(decoder.destinationID())))
channel->didReceiveMessage(connection, decoder);
return;
}
@@ -335,7 +336,7 @@
{
}
-void NetworkConnectionToWebProcess::createSocketStream(URL&& url, String cachePartition, uint64_t identifier)
+void NetworkConnectionToWebProcess::createSocketStream(URL&& url, String cachePartition, WebSocketIdentifier identifier)
{
ASSERT(!m_networkSocketStreams.contains(identifier));
WebCore::SourceApplicationAuditToken token = { };
@@ -342,10 +343,10 @@
#if PLATFORM(COCOA)
token = { m_networkProcess->sourceApplicationAuditData() };
#endif
- m_networkSocketStreams.set(identifier, NetworkSocketStream::create(m_networkProcess.get(), WTFMove(url), m_sessionID, cachePartition, identifier, m_connection, WTFMove(token)));
+ m_networkSocketStreams.add(identifier, NetworkSocketStream::create(m_networkProcess.get(), WTFMove(url), m_sessionID, cachePartition, identifier, m_connection, WTFMove(token)));
}
-void NetworkConnectionToWebProcess::createSocketChannel(const ResourceRequest& request, const String& protocol, uint64_t identifier)
+void NetworkConnectionToWebProcess::createSocketChannel(const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier)
{
ASSERT(!m_networkSocketChannels.contains(identifier));
if (auto channel = NetworkSocketChannel::create(*this, m_sessionID, request, protocol, identifier))
@@ -352,7 +353,7 @@
m_networkSocketChannels.add(identifier, WTFMove(channel));
}
-void NetworkConnectionToWebProcess::removeSocketChannel(uint64_t identifier)
+void NetworkConnectionToWebProcess::removeSocketChannel(WebSocketIdentifier identifier)
{
ASSERT(m_networkSocketChannels.contains(identifier));
m_networkSocketChannels.remove(identifier);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (256302 => 256303)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h 2020-02-11 14:08:30 UTC (rev 256303)
@@ -37,6 +37,7 @@
#include "WebPageProxyIdentifier.h"
#include "WebPaymentCoordinatorProxy.h"
#include "WebResourceLoadObserver.h"
+#include "WebSocketIdentifier.h"
#include <WebCore/FrameIdentifier.h>
#include <WebCore/MessagePortChannelProvider.h>
#include <WebCore/MessagePortIdentifier.h>
@@ -155,7 +156,7 @@
Vector<RefPtr<WebCore::BlobDataFileReference>> resolveBlobReferences(const NetworkResourceLoadParameters&);
- void removeSocketChannel(uint64_t identifier);
+ void removeSocketChannel(WebSocketIdentifier);
WebCore::ProcessIdentifier webProcessIdentifier() const { return m_webProcessIdentifier; }
@@ -218,9 +219,9 @@
void setCaptureExtraNetworkLoadMetricsEnabled(bool);
- void createSocketStream(URL&&, String cachePartition, uint64_t);
+ void createSocketStream(URL&&, String cachePartition, WebSocketIdentifier);
- void createSocketChannel(const WebCore::ResourceRequest&, const String& protocol, uint64_t identifier);
+ void createSocketChannel(const WebCore::ResourceRequest&, const String& protocol, WebSocketIdentifier);
void updateQuotaBasedOnSpaceUsageForTesting(const WebCore::ClientOrigin&);
#if ENABLE(SERVICE_WORKER)
@@ -313,8 +314,8 @@
Ref<NetworkProcess> m_networkProcess;
PAL::SessionID m_sessionID;
- HashMap<uint64_t, RefPtr<NetworkSocketStream>> m_networkSocketStreams;
- HashMap<uint64_t, std::unique_ptr<NetworkSocketChannel>> m_networkSocketChannels;
+ HashMap<WebSocketIdentifier, RefPtr<NetworkSocketStream>> m_networkSocketStreams;
+ HashMap<WebSocketIdentifier, std::unique_ptr<NetworkSocketChannel>> m_networkSocketChannels;
NetworkResourceLoadMap m_networkResourceLoaders;
HashMap<String, RefPtr<WebCore::BlobDataFileReference>> m_blobDataFileReferences;
Vector<ResourceNetworkActivityTracker> m_networkActivityTrackers;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (256302 => 256303)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2020-02-11 14:08:30 UTC (rev 256303)
@@ -51,8 +51,8 @@
SetCaptureExtraNetworkLoadMetricsEnabled(bool enabled)
- CreateSocketStream(URL url, String cachePartition, uint64_t identifier)
- CreateSocketChannel(WebCore::ResourceRequest request, String protocol, uint64_t identifier)
+ CreateSocketStream(URL url, String cachePartition, WebKit::WebSocketIdentifier identifier)
+ CreateSocketChannel(WebCore::ResourceRequest request, String protocol, WebKit::WebSocketIdentifier identifier)
#if ENABLE(RESOURCE_LOAD_STATISTICS)
RemoveStorageAccessForFrame(WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp (256302 => 256303)
--- trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp 2020-02-11 14:08:30 UTC (rev 256303)
@@ -36,7 +36,7 @@
namespace WebKit {
using namespace WebCore;
-std::unique_ptr<NetworkSocketChannel> NetworkSocketChannel::create(NetworkConnectionToWebProcess& connection, PAL::SessionID sessionID, const ResourceRequest& request, const String& protocol, uint64_t identifier)
+std::unique_ptr<NetworkSocketChannel> NetworkSocketChannel::create(NetworkConnectionToWebProcess& connection, PAL::SessionID sessionID, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier)
{
auto result = makeUnique<NetworkSocketChannel>(connection, connection.networkProcess().networkSession(sessionID), request, protocol, identifier);
if (!result->m_socket) {
@@ -46,7 +46,7 @@
return result;
}
-NetworkSocketChannel::NetworkSocketChannel(NetworkConnectionToWebProcess& connection, NetworkSession* session, const ResourceRequest& request, const String& protocol, uint64_t identifier)
+NetworkSocketChannel::NetworkSocketChannel(NetworkConnectionToWebProcess& connection, NetworkSession* session, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier)
: m_connectionToWebProcess(connection)
, m_identifier(identifier)
, m_session(makeWeakPtr(session))
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h (256302 => 256303)
--- trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h 2020-02-11 14:08:30 UTC (rev 256303)
@@ -27,6 +27,7 @@
#include "MessageReceiver.h"
#include "MessageSender.h"
+#include "WebSocketIdentifier.h"
#include <pal/SessionID.h>
#include <wtf/CompletionHandler.h>
#include <wtf/WeakPtr.h>
@@ -51,9 +52,9 @@
class NetworkSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver {
WTF_MAKE_FAST_ALLOCATED;
public:
- static std::unique_ptr<NetworkSocketChannel> create(NetworkConnectionToWebProcess&, PAL::SessionID, const WebCore::ResourceRequest&, const String& protocol, uint64_t identifier);
+ static std::unique_ptr<NetworkSocketChannel> create(NetworkConnectionToWebProcess&, PAL::SessionID, const WebCore::ResourceRequest&, const String& protocol, WebSocketIdentifier);
- NetworkSocketChannel(NetworkConnectionToWebProcess&, NetworkSession*, const WebCore::ResourceRequest&, const String& protocol, uint64_t identifier);
+ NetworkSocketChannel(NetworkConnectionToWebProcess&, NetworkSession*, const WebCore::ResourceRequest&, const String& protocol, WebSocketIdentifier);
~NetworkSocketChannel();
void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
@@ -72,12 +73,12 @@
void close(int32_t code, const String& reason);
IPC::Connection* messageSenderConnection() const final;
- uint64_t messageSenderDestinationID() const final { return m_identifier; }
+ uint64_t messageSenderDestinationID() const final { return m_identifier.toUInt64(); }
void finishClosingIfPossible();
NetworkConnectionToWebProcess& m_connectionToWebProcess;
- uint64_t m_identifier;
+ WebSocketIdentifier m_identifier;
WeakPtr<NetworkSession> m_session;
std::unique_ptr<WebSocketTask> m_socket;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketStream.cpp (256302 => 256303)
--- trunk/Source/WebKit/NetworkProcess/NetworkSocketStream.cpp 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketStream.cpp 2020-02-11 14:08:30 UTC (rev 256303)
@@ -35,12 +35,12 @@
namespace WebKit {
using namespace WebCore;
-Ref<NetworkSocketStream> NetworkSocketStream::create(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, uint64_t identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
+Ref<NetworkSocketStream> NetworkSocketStream::create(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, WebSocketIdentifier identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
{
return adoptRef(*new NetworkSocketStream(networkProcess, WTFMove(url), sessionID, credentialPartition, identifier, connection, WTFMove(auditData)));
}
-NetworkSocketStream::NetworkSocketStream(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, uint64_t identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
+NetworkSocketStream::NetworkSocketStream(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, WebSocketIdentifier identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
: m_identifier(identifier)
, m_connection(connection)
, m_impl(SocketStreamHandleImpl::create(url, *this, sessionID, credentialPartition, WTFMove(auditData), NetworkStorageSessionProvider::create(networkProcess, sessionID).ptr()))
@@ -114,7 +114,7 @@
uint64_t NetworkSocketStream::messageSenderDestinationID() const
{
- return m_identifier;
+ return m_identifier.toUInt64();
}
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketStream.h (256302 => 256303)
--- trunk/Source/WebKit/NetworkProcess/NetworkSocketStream.h 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketStream.h 2020-02-11 14:08:30 UTC (rev 256303)
@@ -27,6 +27,7 @@
#include "MessageReceiver.h"
#include "MessageSender.h"
+#include "WebSocketIdentifier.h"
#include <WebCore/SocketStreamHandleClient.h>
#include <WebCore/SocketStreamHandleImpl.h>
#include <pal/SessionID.h>
@@ -43,7 +44,7 @@
class NetworkSocketStream : public RefCounted<NetworkSocketStream>, public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandleClient {
public:
- static Ref<NetworkSocketStream> create(NetworkProcess&, URL&&, PAL::SessionID, const String& credentialPartition, uint64_t, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
+ static Ref<NetworkSocketStream> create(NetworkProcess&, URL&&, PAL::SessionID, const String& credentialPartition, WebSocketIdentifier, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
~NetworkSocketStream();
void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
@@ -64,9 +65,9 @@
IPC::Connection* messageSenderConnection() const final;
uint64_t messageSenderDestinationID() const final;
- NetworkSocketStream(NetworkProcess&, URL&&, PAL::SessionID, const String& credentialPartition, uint64_t, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
+ NetworkSocketStream(NetworkProcess&, URL&&, PAL::SessionID, const String& credentialPartition, WebSocketIdentifier, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
- uint64_t m_identifier;
+ WebSocketIdentifier m_identifier;
IPC::Connection& m_connection;
Ref<WebCore::SocketStreamHandleImpl> m_impl;
};
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (256302 => 256303)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2020-02-11 14:08:30 UTC (rev 256303)
@@ -236,6 +236,7 @@
'WebKit::TransactionID',
'WebKit::UserContentControllerIdentifier',
'WebKit::WebPageProxyIdentifier',
+ 'WebKit::WebSocketIdentifier',
])
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (256302 => 256303)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-02-11 14:08:30 UTC (rev 256303)
@@ -3382,6 +3382,7 @@
417915B62257046E00D6F97E /* NetworkSocketChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkSocketChannel.h; sourceTree = "<group>"; };
417915B72257046E00D6F97E /* NetworkSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSocketChannel.cpp; sourceTree = "<group>"; };
417915B82257046E00D6F97E /* NetworkSocketChannel.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NetworkSocketChannel.messages.in; sourceTree = "<group>"; };
+ 41794D1C23EDD757008C453F /* WebSocketIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketIdentifier.h; path = Network/WebSocketIdentifier.h; sourceTree = "<group>"; };
41897ECC1F415D5C0016FA42 /* WebCacheStorageProvider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCacheStorageProvider.cpp; sourceTree = "<group>"; };
41897ECD1F415D5C0016FA42 /* WebCacheStorageConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCacheStorageConnection.h; sourceTree = "<group>"; };
41897ECE1F415D5C0016FA42 /* WebCacheStorageConnection.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCacheStorageConnection.cpp; sourceTree = "<group>"; };
@@ -7348,6 +7349,7 @@
417915B42256D1A700D6F97E /* WebSocketChannel.messages.in */,
417915B22256C2E200D6F97E /* WebSocketChannelManager.cpp */,
417915B02256C0D600D6F97E /* WebSocketChannelManager.h */,
+ 41794D1C23EDD757008C453F /* WebSocketIdentifier.h */,
5C7706731D111D8B0012700F /* WebSocketProvider.cpp */,
5C7C88DC1D0F41A0009D2F6D /* WebSocketProvider.h */,
5C0B177A1E7C884F00E9123C /* WebSocketStream.cpp */,
Modified: trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp (256302 => 256303)
--- trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp 2020-02-11 14:08:30 UTC (rev 256303)
@@ -89,7 +89,7 @@
return;
}
if (decoder.messageReceiverName() == Messages::WebSocketStream::messageReceiverName()) {
- if (auto* stream = WebSocketStream::streamWithIdentifier(decoder.destinationID()))
+ if (auto* stream = WebSocketStream::streamWithIdentifier(makeObjectIdentifier<WebSocketIdentifierType>(decoder.destinationID())))
stream->didReceiveMessage(connection, decoder);
return;
}
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp (256302 => 256303)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp 2020-02-11 14:08:30 UTC (rev 256303)
@@ -62,6 +62,7 @@
WebSocketChannel::WebSocketChannel(Document& document, WebSocketChannelClient& client)
: m_document(makeWeakPtr(document))
+ , m_identifier(WebSocketIdentifier::generate())
, m_client(makeWeakPtr(client))
, m_messageQueue(createMessageQueue(document, *this))
{
@@ -78,7 +79,7 @@
uint64_t WebSocketChannel::messageSenderDestinationID() const
{
- return identifier();
+ return m_identifier.toUInt64();
}
String WebSocketChannel::subprotocol()
@@ -103,7 +104,7 @@
if (request->url() != url && m_client)
m_client->didUpgradeURL();
- MessageSender::send(Messages::NetworkConnectionToWebProcess::CreateSocketChannel { *request, protocol, identifier() });
+ MessageSender::send(Messages::NetworkConnectionToWebProcess::CreateSocketChannel { *request, protocol, m_identifier });
return ConnectStatus::OK;
}
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h (256302 => 256303)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h 2020-02-11 14:08:30 UTC (rev 256303)
@@ -27,9 +27,9 @@
#include "MessageReceiver.h"
#include "MessageSender.h"
+#include "WebSocketIdentifier.h"
#include <WebCore/NetworkSendQueue.h>
#include <WebCore/ThreadableWebSocketChannel.h>
-#include <wtf/Identified.h>
#include <wtf/WeakPtr.h>
namespace IPC {
@@ -40,11 +40,13 @@
namespace WebKit {
-class WebSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::ThreadableWebSocketChannel, public RefCounted<WebSocketChannel>, public Identified<WebSocketChannel> {
+class WebSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::ThreadableWebSocketChannel, public RefCounted<WebSocketChannel> {
public:
static Ref<WebSocketChannel> create(WebCore::Document&, WebCore::WebSocketChannelClient&);
~WebSocketChannel();
+ WebSocketIdentifier identifier() const { return m_identifier; }
+
void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
void networkProcessCrashed();
@@ -90,6 +92,7 @@
void enqueueTask(Function<void()>&&);
WeakPtr<WebCore::Document> m_document;
+ WebSocketIdentifier m_identifier;
WeakPtr<WebCore::WebSocketChannelClient> m_client;
String m_subprotocol;
String m_extensions;
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.cpp (256302 => 256303)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.cpp 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.cpp 2020-02-11 14:08:30 UTC (rev 256303)
@@ -44,7 +44,7 @@
void WebSocketChannelManager::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
{
- auto iterator = m_channels.find(decoder.destinationID());
+ auto iterator = m_channels.find(makeObjectIdentifier<WebSocketIdentifierType>(decoder.destinationID()));
if (iterator != m_channels.end())
iterator->value->didReceiveMessage(connection, decoder);
}
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h (256302 => 256303)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h 2020-02-11 14:08:30 UTC (rev 256303)
@@ -48,7 +48,7 @@
void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
private:
- HashMap<uint64_t, Ref<WebSocketChannel>> m_channels;
+ HashMap<WebSocketIdentifier, Ref<WebSocketChannel>> m_channels;
};
} // namespace WebKit
Copied: trunk/Source/WebKit/WebProcess/Network/WebSocketIdentifier.h (from rev 256302, trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h) (0 => 256303)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketIdentifier.h (rev 0)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketIdentifier.h 2020-02-11 14:08:30 UTC (rev 256303)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2020 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
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebKit {
+
+enum WebSocketIdentifierType { };
+using WebSocketIdentifier = ObjectIdentifier<WebSocketIdentifierType>;
+
+} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp (256302 => 256303)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp 2020-02-11 14:08:30 UTC (rev 256303)
@@ -32,6 +32,7 @@
#include "NetworkSocketStreamMessages.h"
#include "WebCoreArgumentCoders.h"
#include "WebProcess.h"
+#include "WebSocketIdentifier.h"
#include <WebCore/CookieRequestHeaderFieldProxy.h>
#include <WebCore/SocketStreamError.h>
#include <WebCore/SocketStreamHandleClient.h>
@@ -41,13 +42,13 @@
using namespace WebCore;
static Lock globalWebSocketStreamMapLock;
-static HashMap<uint64_t, WebSocketStream*>& globalWebSocketStreamMap()
+static HashMap<WebSocketIdentifier, WebSocketStream*>& globalWebSocketStreamMap()
{
- static NeverDestroyed<HashMap<uint64_t, WebSocketStream*>> globalMap;
+ static NeverDestroyed<HashMap<WebSocketIdentifier, WebSocketStream*>> globalMap;
return globalMap;
}
-WebSocketStream* WebSocketStream::streamWithIdentifier(uint64_t identifier)
+WebSocketStream* WebSocketStream::streamWithIdentifier(WebSocketIdentifier identifier)
{
LockHolder locker(globalWebSocketStreamMapLock);
return globalWebSocketStreamMap().get(identifier);
@@ -83,20 +84,21 @@
WebSocketStream::WebSocketStream(const URL& url, WebCore::SocketStreamHandleClient& client, const String& cachePartition)
: SocketStreamHandle(url, client)
+ , m_identifier(WebSocketIdentifier::generate())
, m_client(client)
{
- WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::CreateSocketStream(url, cachePartition, identifier()), 0);
+ WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::CreateSocketStream(url, cachePartition, m_identifier), 0);
LockHolder locker(globalWebSocketStreamMapLock);
- ASSERT(!globalWebSocketStreamMap().contains(identifier()));
- globalWebSocketStreamMap().set(identifier(), this);
+ ASSERT(!globalWebSocketStreamMap().contains(m_identifier));
+ globalWebSocketStreamMap().set(m_identifier, this);
}
WebSocketStream::~WebSocketStream()
{
LockHolder locker(globalWebSocketStreamMapLock);
- ASSERT(globalWebSocketStreamMap().contains(identifier()));
- globalWebSocketStreamMap().remove(identifier());
+ ASSERT(globalWebSocketStreamMap().contains(m_identifier));
+ globalWebSocketStreamMap().remove(m_identifier);
}
IPC::Connection* WebSocketStream::messageSenderConnection() const
@@ -106,7 +108,7 @@
uint64_t WebSocketStream::messageSenderDestinationID() const
{
- return identifier();
+ return m_identifier.toUInt64();
}
void WebSocketStream::platformSend(const uint8_t* data, size_t length, Function<void(bool)>&& completionHandler)
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketStream.h (256302 => 256303)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketStream.h 2020-02-11 13:09:59 UTC (rev 256302)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketStream.h 2020-02-11 14:08:30 UTC (rev 256303)
@@ -27,8 +27,8 @@
#include "MessageReceiver.h"
#include "MessageSender.h"
+#include "WebSocketIdentifier.h"
#include <WebCore/SocketStreamHandle.h>
-#include <wtf/Identified.h>
namespace IPC {
class Connection;
@@ -42,11 +42,11 @@
namespace WebKit {
-class WebSocketStream : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandle, public Identified<WebSocketStream> {
+class WebSocketStream : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandle {
public:
static Ref<WebSocketStream> create(const URL&, WebCore::SocketStreamHandleClient&, const String& credentialPartition);
static void networkProcessCrashed();
- static WebSocketStream* streamWithIdentifier(uint64_t);
+ static WebSocketStream* streamWithIdentifier(WebSocketIdentifier);
void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
@@ -75,6 +75,7 @@
WebSocketStream(const URL&, WebCore::SocketStreamHandleClient&, const String& credentialPartition);
~WebSocketStream();
+ WebSocketIdentifier m_identifier;
size_t m_bufferedAmount { 0 };
WebCore::SocketStreamHandleClient& m_client;
HashMap<uint64_t, Function<void(bool)>> m_sendDataCallbacks;