Changeset 256303 in webkit


Ignore:
Timestamp:
Feb 11, 2020 6:08:30 AM (4 years ago)
Author:
youenn@apple.com
Message:

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:
Location:
trunk/Source/WebKit
Files:
17 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r256294 r256303  
     12020-02-11  Youenn Fablet  <youenn@apple.com>
     2
     3        Use ObjectIdentifier for WebSocketStream/WebSocketChannel
     4        https://bugs.webkit.org/show_bug.cgi?id=207507
     5
     6        Reviewed by Alex Christensen.
     7
     8        Replace uint64_t by ObjectIdentifier.
     9        This adds type safety and ensures we get valid identifiers from IPC.
     10        We still need to check for destinationID being not null in a few places.
     11        No observable change of behavior.
     12
     13        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     14        (WebKit::NetworkConnectionToWebProcess::didReceiveMessage):
     15        (WebKit::NetworkConnectionToWebProcess::createSocketStream):
     16        (WebKit::NetworkConnectionToWebProcess::createSocketChannel):
     17        (WebKit::NetworkConnectionToWebProcess::removeSocketChannel):
     18        * NetworkProcess/NetworkConnectionToWebProcess.h:
     19        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
     20        * NetworkProcess/NetworkSocketChannel.cpp:
     21        (WebKit::NetworkSocketChannel::create):
     22        (WebKit::NetworkSocketChannel::NetworkSocketChannel):
     23        * NetworkProcess/NetworkSocketChannel.h:
     24        * NetworkProcess/NetworkSocketStream.cpp:
     25        (WebKit::NetworkSocketStream::create):
     26        (WebKit::NetworkSocketStream::NetworkSocketStream):
     27        (WebKit::NetworkSocketStream::messageSenderDestinationID const):
     28        * NetworkProcess/NetworkSocketStream.h:
     29        * Scripts/webkit/messages.py:
     30        * WebKit.xcodeproj/project.pbxproj:
     31        * WebProcess/Network/NetworkProcessConnection.cpp:
     32        (WebKit::NetworkProcessConnection::didReceiveMessage):
     33        * WebProcess/Network/WebSocketChannel.cpp:
     34        (WebKit::WebSocketChannel::WebSocketChannel):
     35        (WebKit::WebSocketChannel::messageSenderDestinationID const):
     36        (WebKit::WebSocketChannel::connect):
     37        * WebProcess/Network/WebSocketChannel.h:
     38        (WebKit::WebSocketChannel::identifier const):
     39        * WebProcess/Network/WebSocketChannelManager.cpp:
     40        (WebKit::WebSocketChannelManager::didReceiveMessage):
     41        * WebProcess/Network/WebSocketChannelManager.h:
     42        * WebProcess/Network/WebSocketIdentifier.h: Added.
     43        * WebProcess/Network/WebSocketStream.cpp:
     44        (WebKit::WebSocketStream::streamWithIdentifier):
     45        (WebKit::WebSocketStream::WebSocketStream):
     46        (WebKit::WebSocketStream::~WebSocketStream):
     47        (WebKit::WebSocketStream::messageSenderDestinationID const):
     48        * WebProcess/Network/WebSocketStream.h:
     49
    1502020-02-11  chris fleizach  <cfleizach@apple.com>
    251
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r255681 r256303  
    6262#include "WebSWServerToContextConnection.h"
    6363#include "WebSWServerToContextConnectionMessages.h"
     64#include "WebSocketIdentifier.h"
    6465#include "WebsiteDataStoreParameters.h"
    6566#include <WebCore/DocumentStorageAccess.h>
     
    176177
    177178    if (decoder.messageReceiverName() == Messages::NetworkSocketStream::messageReceiverName()) {
    178         if (auto* socketStream = m_networkSocketStreams.get(decoder.destinationID())) {
     179        if (auto* socketStream = m_networkSocketStreams.get(makeObjectIdentifier<WebSocketIdentifierType>(decoder.destinationID()))) {
    179180            socketStream->didReceiveMessage(connection, decoder);
    180181            if (decoder.messageName() == Messages::NetworkSocketStream::Close::name())
    181                 m_networkSocketStreams.remove(decoder.destinationID());
     182                m_networkSocketStreams.remove(makeObjectIdentifier<WebSocketIdentifierType>(decoder.destinationID()));
    182183        }
    183184        return;
     
    185186
    186187    if (decoder.messageReceiverName() == Messages::NetworkSocketChannel::messageReceiverName()) {
    187         if (auto* channel = m_networkSocketChannels.get(decoder.destinationID()))
     188        if (auto* channel = m_networkSocketChannels.get(makeObjectIdentifier<WebSocketIdentifierType>(decoder.destinationID())))
    188189            channel->didReceiveMessage(connection, decoder);
    189190        return;
     
    336337}
    337338
    338 void NetworkConnectionToWebProcess::createSocketStream(URL&& url, String cachePartition, uint64_t identifier)
     339void NetworkConnectionToWebProcess::createSocketStream(URL&& url, String cachePartition, WebSocketIdentifier identifier)
    339340{
    340341    ASSERT(!m_networkSocketStreams.contains(identifier));
     
    343344    token = { m_networkProcess->sourceApplicationAuditData() };
    344345#endif
    345     m_networkSocketStreams.set(identifier, NetworkSocketStream::create(m_networkProcess.get(), WTFMove(url), m_sessionID, cachePartition, identifier, m_connection, WTFMove(token)));
    346 }
    347 
    348 void NetworkConnectionToWebProcess::createSocketChannel(const ResourceRequest& request, const String& protocol, uint64_t identifier)
     346    m_networkSocketStreams.add(identifier, NetworkSocketStream::create(m_networkProcess.get(), WTFMove(url), m_sessionID, cachePartition, identifier, m_connection, WTFMove(token)));
     347}
     348
     349void NetworkConnectionToWebProcess::createSocketChannel(const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier)
    349350{
    350351    ASSERT(!m_networkSocketChannels.contains(identifier));
     
    353354}
    354355
    355 void NetworkConnectionToWebProcess::removeSocketChannel(uint64_t identifier)
     356void NetworkConnectionToWebProcess::removeSocketChannel(WebSocketIdentifier identifier)
    356357{
    357358    ASSERT(m_networkSocketChannels.contains(identifier));
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h

    r255681 r256303  
    3838#include "WebPaymentCoordinatorProxy.h"
    3939#include "WebResourceLoadObserver.h"
     40#include "WebSocketIdentifier.h"
    4041#include <WebCore/FrameIdentifier.h>
    4142#include <WebCore/MessagePortChannelProvider.h>
     
    156157    Vector<RefPtr<WebCore::BlobDataFileReference>> resolveBlobReferences(const NetworkResourceLoadParameters&);
    157158
    158     void removeSocketChannel(uint64_t identifier);
     159    void removeSocketChannel(WebSocketIdentifier);
    159160
    160161    WebCore::ProcessIdentifier webProcessIdentifier() const { return m_webProcessIdentifier; }
     
    219220    void setCaptureExtraNetworkLoadMetricsEnabled(bool);
    220221
    221     void createSocketStream(URL&&, String cachePartition, uint64_t);
    222 
    223     void createSocketChannel(const WebCore::ResourceRequest&, const String& protocol, uint64_t identifier);
     222    void createSocketStream(URL&&, String cachePartition, WebSocketIdentifier);
     223
     224    void createSocketChannel(const WebCore::ResourceRequest&, const String& protocol, WebSocketIdentifier);
    224225    void updateQuotaBasedOnSpaceUsageForTesting(const WebCore::ClientOrigin&);
    225226
     
    314315    PAL::SessionID m_sessionID;
    315316
    316     HashMap<uint64_t, RefPtr<NetworkSocketStream>> m_networkSocketStreams;
    317     HashMap<uint64_t, std::unique_ptr<NetworkSocketChannel>> m_networkSocketChannels;
     317    HashMap<WebSocketIdentifier, RefPtr<NetworkSocketStream>> m_networkSocketStreams;
     318    HashMap<WebSocketIdentifier, std::unique_ptr<NetworkSocketChannel>> m_networkSocketChannels;
    318319    NetworkResourceLoadMap m_networkResourceLoaders;
    319320    HashMap<String, RefPtr<WebCore::BlobDataFileReference>> m_blobDataFileReferences;
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in

    r255681 r256303  
    5252    SetCaptureExtraNetworkLoadMetricsEnabled(bool enabled)
    5353
    54     CreateSocketStream(URL url, String cachePartition, uint64_t identifier)
    55     CreateSocketChannel(WebCore::ResourceRequest request, String protocol, uint64_t identifier)
     54    CreateSocketStream(URL url, String cachePartition, WebKit::WebSocketIdentifier identifier)
     55    CreateSocketChannel(WebCore::ResourceRequest request, String protocol, WebKit::WebSocketIdentifier identifier)
    5656
    5757#if ENABLE(RESOURCE_LOAD_STATISTICS)
  • trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp

    r248846 r256303  
    3737using namespace WebCore;
    3838
    39 std::unique_ptr<NetworkSocketChannel> NetworkSocketChannel::create(NetworkConnectionToWebProcess& connection, PAL::SessionID sessionID, const ResourceRequest& request, const String& protocol, uint64_t identifier)
     39std::unique_ptr<NetworkSocketChannel> NetworkSocketChannel::create(NetworkConnectionToWebProcess& connection, PAL::SessionID sessionID, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier)
    4040{
    4141    auto result = makeUnique<NetworkSocketChannel>(connection, connection.networkProcess().networkSession(sessionID), request, protocol, identifier);
     
    4747}
    4848
    49 NetworkSocketChannel::NetworkSocketChannel(NetworkConnectionToWebProcess& connection, NetworkSession* session, const ResourceRequest& request, const String& protocol, uint64_t identifier)
     49NetworkSocketChannel::NetworkSocketChannel(NetworkConnectionToWebProcess& connection, NetworkSession* session, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier)
    5050    : m_connectionToWebProcess(connection)
    5151    , m_identifier(identifier)
  • trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h

    r251361 r256303  
    2828#include "MessageReceiver.h"
    2929#include "MessageSender.h"
     30#include "WebSocketIdentifier.h"
    3031#include <pal/SessionID.h>
    3132#include <wtf/CompletionHandler.h>
     
    5253    WTF_MAKE_FAST_ALLOCATED;
    5354public:
    54     static std::unique_ptr<NetworkSocketChannel> create(NetworkConnectionToWebProcess&, PAL::SessionID, const WebCore::ResourceRequest&, const String& protocol, uint64_t identifier);
     55    static std::unique_ptr<NetworkSocketChannel> create(NetworkConnectionToWebProcess&, PAL::SessionID, const WebCore::ResourceRequest&, const String& protocol, WebSocketIdentifier);
    5556
    56     NetworkSocketChannel(NetworkConnectionToWebProcess&, NetworkSession*, const WebCore::ResourceRequest&, const String& protocol, uint64_t identifier);
     57    NetworkSocketChannel(NetworkConnectionToWebProcess&, NetworkSession*, const WebCore::ResourceRequest&, const String& protocol, WebSocketIdentifier);
    5758    ~NetworkSocketChannel();
    5859
     
    7374
    7475    IPC::Connection* messageSenderConnection() const final;
    75     uint64_t messageSenderDestinationID() const final { return m_identifier; }
     76    uint64_t messageSenderDestinationID() const final { return m_identifier.toUInt64(); }
    7677
    7778    void finishClosingIfPossible();
    7879
    7980    NetworkConnectionToWebProcess& m_connectionToWebProcess;
    80     uint64_t m_identifier;
     81    WebSocketIdentifier m_identifier;
    8182    WeakPtr<NetworkSession> m_session;
    8283    std::unique_ptr<WebSocketTask> m_socket;
  • trunk/Source/WebKit/NetworkProcess/NetworkSocketStream.cpp

    r240955 r256303  
    3636using namespace WebCore;
    3737
    38 Ref<NetworkSocketStream> NetworkSocketStream::create(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, uint64_t identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
     38Ref<NetworkSocketStream> NetworkSocketStream::create(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, WebSocketIdentifier identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
    3939{
    4040    return adoptRef(*new NetworkSocketStream(networkProcess, WTFMove(url), sessionID, credentialPartition, identifier, connection, WTFMove(auditData)));
    4141}
    4242
    43 NetworkSocketStream::NetworkSocketStream(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, uint64_t identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
     43NetworkSocketStream::NetworkSocketStream(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, WebSocketIdentifier identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
    4444    : m_identifier(identifier)
    4545    , m_connection(connection)
     
    115115uint64_t NetworkSocketStream::messageSenderDestinationID() const
    116116{
    117     return m_identifier;
     117    return m_identifier.toUInt64();
    118118}
    119119
  • trunk/Source/WebKit/NetworkProcess/NetworkSocketStream.h

    r240955 r256303  
    2828#include "MessageReceiver.h"
    2929#include "MessageSender.h"
     30#include "WebSocketIdentifier.h"
    3031#include <WebCore/SocketStreamHandleClient.h>
    3132#include <WebCore/SocketStreamHandleImpl.h>
     
    4445class NetworkSocketStream : public RefCounted<NetworkSocketStream>, public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandleClient {
    4546public:
    46     static Ref<NetworkSocketStream> create(NetworkProcess&, URL&&, PAL::SessionID, const String& credentialPartition, uint64_t, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
     47    static Ref<NetworkSocketStream> create(NetworkProcess&, URL&&, PAL::SessionID, const String& credentialPartition, WebSocketIdentifier, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
    4748    ~NetworkSocketStream();
    4849
     
    6566    uint64_t messageSenderDestinationID() const final;
    6667
    67     NetworkSocketStream(NetworkProcess&, URL&&, PAL::SessionID, const String& credentialPartition, uint64_t, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
     68    NetworkSocketStream(NetworkProcess&, URL&&, PAL::SessionID, const String& credentialPartition, WebSocketIdentifier, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
    6869
    69     uint64_t m_identifier;
     70    WebSocketIdentifier m_identifier;
    7071    IPC::Connection& m_connection;
    7172    Ref<WebCore::SocketStreamHandleImpl> m_impl;
  • trunk/Source/WebKit/Scripts/webkit/messages.py

    r256185 r256303  
    237237        'WebKit::UserContentControllerIdentifier',
    238238        'WebKit::WebPageProxyIdentifier',
     239        'WebKit::WebSocketIdentifier',
    239240    ])
    240241
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r256236 r256303  
    33833383                417915B72257046E00D6F97E /* NetworkSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSocketChannel.cpp; sourceTree = "<group>"; };
    33843384                417915B82257046E00D6F97E /* NetworkSocketChannel.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NetworkSocketChannel.messages.in; sourceTree = "<group>"; };
     3385                41794D1C23EDD757008C453F /* WebSocketIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketIdentifier.h; path = Network/WebSocketIdentifier.h; sourceTree = "<group>"; };
    33853386                41897ECC1F415D5C0016FA42 /* WebCacheStorageProvider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCacheStorageProvider.cpp; sourceTree = "<group>"; };
    33863387                41897ECD1F415D5C0016FA42 /* WebCacheStorageConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCacheStorageConnection.h; sourceTree = "<group>"; };
     
    73497350                                417915B22256C2E200D6F97E /* WebSocketChannelManager.cpp */,
    73507351                                417915B02256C0D600D6F97E /* WebSocketChannelManager.h */,
     7352                                41794D1C23EDD757008C453F /* WebSocketIdentifier.h */,
    73517353                                5C7706731D111D8B0012700F /* WebSocketProvider.cpp */,
    73527354                                5C7C88DC1D0F41A0009D2F6D /* WebSocketProvider.h */,
  • trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp

    r256185 r256303  
    9090    }
    9191    if (decoder.messageReceiverName() == Messages::WebSocketStream::messageReceiverName()) {
    92         if (auto* stream = WebSocketStream::streamWithIdentifier(decoder.destinationID()))
     92        if (auto* stream = WebSocketStream::streamWithIdentifier(makeObjectIdentifier<WebSocketIdentifierType>(decoder.destinationID())))
    9393            stream->didReceiveMessage(connection, decoder);
    9494        return;
  • trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp

    r249891 r256303  
    6363WebSocketChannel::WebSocketChannel(Document& document, WebSocketChannelClient& client)
    6464    : m_document(makeWeakPtr(document))
     65    ,  m_identifier(WebSocketIdentifier::generate())
    6566    , m_client(makeWeakPtr(client))
    6667    , m_messageQueue(createMessageQueue(document, *this))
     
    7980uint64_t WebSocketChannel::messageSenderDestinationID() const
    8081{
    81     return identifier();
     82    return m_identifier.toUInt64();
    8283}
    8384
     
    104105        m_client->didUpgradeURL();
    105106
    106     MessageSender::send(Messages::NetworkConnectionToWebProcess::CreateSocketChannel { *request, protocol, identifier() });
     107    MessageSender::send(Messages::NetworkConnectionToWebProcess::CreateSocketChannel { *request, protocol, m_identifier });
    107108    return ConnectStatus::OK;
    108109}
  • trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h

    r250287 r256303  
    2828#include "MessageReceiver.h"
    2929#include "MessageSender.h"
     30#include "WebSocketIdentifier.h"
    3031#include <WebCore/NetworkSendQueue.h>
    3132#include <WebCore/ThreadableWebSocketChannel.h>
    32 #include <wtf/Identified.h>
    3333#include <wtf/WeakPtr.h>
    3434
     
    4141namespace WebKit {
    4242
    43 class WebSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::ThreadableWebSocketChannel, public RefCounted<WebSocketChannel>, public Identified<WebSocketChannel> {
     43class WebSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::ThreadableWebSocketChannel, public RefCounted<WebSocketChannel> {
    4444public:
    4545    static Ref<WebSocketChannel> create(WebCore::Document&, WebCore::WebSocketChannelClient&);
    4646    ~WebSocketChannel();
     47
     48    WebSocketIdentifier identifier() const { return m_identifier; }
    4749
    4850    void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
     
    9193
    9294    WeakPtr<WebCore::Document> m_document;
     95    WebSocketIdentifier m_identifier;
    9396    WeakPtr<WebCore::WebSocketChannelClient> m_client;
    9497    String m_subprotocol;
  • trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.cpp

    r246388 r256303  
    4545void WebSocketChannelManager::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
    4646{
    47     auto iterator = m_channels.find(decoder.destinationID());
     47    auto iterator = m_channels.find(makeObjectIdentifier<WebSocketIdentifierType>(decoder.destinationID()));
    4848    if (iterator != m_channels.end())
    4949        iterator->value->didReceiveMessage(connection, decoder);
  • trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h

    r246388 r256303  
    4949
    5050private:
    51     HashMap<uint64_t, Ref<WebSocketChannel>> m_channels;
     51    HashMap<WebSocketIdentifier, Ref<WebSocketChannel>> m_channels;
    5252};
    5353
  • trunk/Source/WebKit/WebProcess/Network/WebSocketIdentifier.h

    r256302 r256303  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    66 * are met:
    77 * 1. Redistributions of source code must retain the above copyright
    8  *    notice, this list of conditions and the following disclaimer.
     8 *    notice , this list of conditions and the following disclaimer.
    99 * 2. Redistributions in binary form must reproduce the above copyright
    1010 *    notice, this list of conditions and the following disclaimer in the
     
    2626#pragma once
    2727
    28 #include "WebSocketChannel.h"
    29 
    30 namespace IPC {
    31 class Connection;
    32 class Decoder;
    33 }
    34 
    35 namespace WebCore {
    36 class Document;
    37 class ThreadableWebSocketChannel;
    38 }
     28#include <wtf/ObjectIdentifier.h>
    3929
    4030namespace WebKit {
    4131
    42 class WebSocketChannelManager {
    43 public:
    44     WebSocketChannelManager() = default;
    45     RefPtr<WebCore::ThreadableWebSocketChannel> createWebSocketChannel(WebCore::Document&, WebCore::WebSocketChannelClient&);
    46 
    47     void networkProcessCrashed();
    48     void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
    49 
    50 private:
    51     HashMap<uint64_t, Ref<WebSocketChannel>> m_channels;
    52 };
     32enum WebSocketIdentifierType { };
     33using WebSocketIdentifier = ObjectIdentifier<WebSocketIdentifierType>;
    5334
    5435} // namespace WebKit
  • trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp

    r250079 r256303  
    3333#include "WebCoreArgumentCoders.h"
    3434#include "WebProcess.h"
     35#include "WebSocketIdentifier.h"
    3536#include <WebCore/CookieRequestHeaderFieldProxy.h>
    3637#include <WebCore/SocketStreamError.h>
     
    4243
    4344static Lock globalWebSocketStreamMapLock;
    44 static HashMap<uint64_t, WebSocketStream*>& globalWebSocketStreamMap()
     45static HashMap<WebSocketIdentifier, WebSocketStream*>& globalWebSocketStreamMap()
    4546{
    46     static NeverDestroyed<HashMap<uint64_t, WebSocketStream*>> globalMap;
     47    static NeverDestroyed<HashMap<WebSocketIdentifier, WebSocketStream*>> globalMap;
    4748    return globalMap;
    4849}
    4950
    50 WebSocketStream* WebSocketStream::streamWithIdentifier(uint64_t identifier)
     51WebSocketStream* WebSocketStream::streamWithIdentifier(WebSocketIdentifier identifier)
    5152{
    5253    LockHolder locker(globalWebSocketStreamMapLock);
     
    8485WebSocketStream::WebSocketStream(const URL& url, WebCore::SocketStreamHandleClient& client, const String& cachePartition)
    8586    : SocketStreamHandle(url, client)
     87    ,  m_identifier(WebSocketIdentifier::generate())
    8688    , m_client(client)
    8789{
    88     WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::CreateSocketStream(url, cachePartition, identifier()), 0);
     90    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::CreateSocketStream(url, cachePartition, m_identifier), 0);
    8991
    9092    LockHolder locker(globalWebSocketStreamMapLock);
    91     ASSERT(!globalWebSocketStreamMap().contains(identifier()));
    92     globalWebSocketStreamMap().set(identifier(), this);
     93    ASSERT(!globalWebSocketStreamMap().contains(m_identifier));
     94    globalWebSocketStreamMap().set(m_identifier, this);
    9395}
    9496
     
    9698{
    9799    LockHolder locker(globalWebSocketStreamMapLock);
    98     ASSERT(globalWebSocketStreamMap().contains(identifier()));
    99     globalWebSocketStreamMap().remove(identifier());
     100    ASSERT(globalWebSocketStreamMap().contains(m_identifier));
     101    globalWebSocketStreamMap().remove(m_identifier);
    100102}
    101103
     
    107109uint64_t WebSocketStream::messageSenderDestinationID() const
    108110{
    109     return identifier();
     111    return m_identifier.toUInt64();
    110112}
    111113
  • trunk/Source/WebKit/WebProcess/Network/WebSocketStream.h

    r250079 r256303  
    2828#include "MessageReceiver.h"
    2929#include "MessageSender.h"
     30#include "WebSocketIdentifier.h"
    3031#include <WebCore/SocketStreamHandle.h>
    31 #include <wtf/Identified.h>
    3232
    3333namespace IPC {
     
    4343namespace WebKit {
    4444
    45 class WebSocketStream : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandle, public Identified<WebSocketStream> {
     45class WebSocketStream : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandle {
    4646public:
    4747    static Ref<WebSocketStream> create(const URL&, WebCore::SocketStreamHandleClient&, const String& credentialPartition);
    4848    static void networkProcessCrashed();
    49     static WebSocketStream* streamWithIdentifier(uint64_t);
     49    static WebSocketStream* streamWithIdentifier(WebSocketIdentifier);
    5050   
    5151    void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
     
    7676    ~WebSocketStream();
    7777
     78    WebSocketIdentifier m_identifier;
    7879    size_t m_bufferedAmount { 0 };
    7980    WebCore::SocketStreamHandleClient& m_client;
Note: See TracChangeset for help on using the changeset viewer.