- Revision
- 260063
- Author
- [email protected]
- Date
- 2020-04-14 02:30:15 -0700 (Tue, 14 Apr 2020)
Log Message
WebSocketChannel should remove itself from its manager map
https://bugs.webkit.org/show_bug.cgi?id=210424
Reviewed by Alex Christensen.
WebSocketChannelManager was never removing any entry from its map.
To fix this, the manager is now keeping a WeakPtr to each channel.
When the channel is destroyed, it will remove itself from its channel manager.
* WebProcess/Network/WebSocketChannel.cpp:
(WebKit::WebSocketChannel::WebSocketChannel):
(WebKit::WebSocketChannel::~WebSocketChannel):
* WebProcess/Network/WebSocketChannel.h:
* WebProcess/Network/WebSocketChannelManager.cpp:
(WebKit::WebSocketChannelManager::addChannel):
(WebKit::WebSocketChannelManager::createWebSocketChannel): Deleted.
* WebProcess/Network/WebSocketChannelManager.h:
(WebKit::WebSocketChannelManager::removeChannel):
* WebProcess/Network/WebSocketProvider.cpp:
(WebKit::WebSocketProvider::createWebSocketChannel):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (260062 => 260063)
--- trunk/Source/WebKit/ChangeLog 2020-04-14 07:56:03 UTC (rev 260062)
+++ trunk/Source/WebKit/ChangeLog 2020-04-14 09:30:15 UTC (rev 260063)
@@ -1,5 +1,28 @@
2020-04-14 Youenn Fablet <[email protected]>
+ WebSocketChannel should remove itself from its manager map
+ https://bugs.webkit.org/show_bug.cgi?id=210424
+
+ Reviewed by Alex Christensen.
+
+ WebSocketChannelManager was never removing any entry from its map.
+ To fix this, the manager is now keeping a WeakPtr to each channel.
+ When the channel is destroyed, it will remove itself from its channel manager.
+
+ * WebProcess/Network/WebSocketChannel.cpp:
+ (WebKit::WebSocketChannel::WebSocketChannel):
+ (WebKit::WebSocketChannel::~WebSocketChannel):
+ * WebProcess/Network/WebSocketChannel.h:
+ * WebProcess/Network/WebSocketChannelManager.cpp:
+ (WebKit::WebSocketChannelManager::addChannel):
+ (WebKit::WebSocketChannelManager::createWebSocketChannel): Deleted.
+ * WebProcess/Network/WebSocketChannelManager.h:
+ (WebKit::WebSocketChannelManager::removeChannel):
+ * WebProcess/Network/WebSocketProvider.cpp:
+ (WebKit::WebSocketProvider::createWebSocketChannel):
+
+2020-04-14 Youenn Fablet <[email protected]>
+
Add logging in case of WebRTC socket error
https://bugs.webkit.org/show_bug.cgi?id=210428
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp (260062 => 260063)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp 2020-04-14 07:56:03 UTC (rev 260062)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp 2020-04-14 09:30:15 UTC (rev 260063)
@@ -75,10 +75,12 @@
, m_messageQueue(createMessageQueue(document, *this))
, m_inspector(document)
{
+ WebProcess::singleton().webSocketChannelManager().addChannel(*this);
}
WebSocketChannel::~WebSocketChannel()
{
+ WebProcess::singleton().webSocketChannelManager().removeChannel(*this);
}
IPC::Connection* WebSocketChannel::messageSenderConnection() const
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h (260062 => 260063)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h 2020-04-14 07:56:03 UTC (rev 260062)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h 2020-04-14 09:30:15 UTC (rev 260063)
@@ -42,7 +42,7 @@
namespace WebKit {
-class WebSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::ThreadableWebSocketChannel, public RefCounted<WebSocketChannel> {
+class WebSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::ThreadableWebSocketChannel, public RefCounted<WebSocketChannel>, public CanMakeWeakPtr<WebSocketChannel> {
public:
static Ref<WebSocketChannel> create(WebCore::Document&, WebCore::WebSocketChannelClient&);
~WebSocketChannel();
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.cpp (260062 => 260063)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.cpp 2020-04-14 07:56:03 UTC (rev 260062)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.cpp 2020-04-14 09:30:15 UTC (rev 260063)
@@ -28,11 +28,10 @@
namespace WebKit {
-RefPtr<WebCore::ThreadableWebSocketChannel> WebSocketChannelManager::createWebSocketChannel(WebCore::Document& document, WebCore::WebSocketChannelClient& client)
+void WebSocketChannelManager::addChannel(WebSocketChannel& channel)
{
- auto channel = WebSocketChannel::create(document, client);
- m_channels.add(channel->identifier(), channel.copyRef());
- return channel;
+ ASSERT(!m_channels.contains(channel.identifier()));
+ m_channels.add(channel.identifier(), makeWeakPtr(channel));
}
void WebSocketChannelManager::networkProcessCrashed()
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h (260062 => 260063)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h 2020-04-14 07:56:03 UTC (rev 260062)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h 2020-04-14 09:30:15 UTC (rev 260063)
@@ -42,13 +42,15 @@
class WebSocketChannelManager {
public:
WebSocketChannelManager() = default;
- RefPtr<WebCore::ThreadableWebSocketChannel> createWebSocketChannel(WebCore::Document&, WebCore::WebSocketChannelClient&);
void networkProcessCrashed();
void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
+ void addChannel(WebSocketChannel&);
+ void removeChannel(WebSocketChannel& channel) { m_channels.remove(channel.identifier() ); }
+
private:
- HashMap<WebSocketIdentifier, Ref<WebSocketChannel>> m_channels;
+ HashMap<WebSocketIdentifier, WeakPtr<WebSocketChannel>> m_channels;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketProvider.cpp (260062 => 260063)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketProvider.cpp 2020-04-14 07:56:03 UTC (rev 260062)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketProvider.cpp 2020-04-14 09:30:15 UTC (rev 260063)
@@ -31,7 +31,6 @@
#include "config.h"
#include "WebSocketProvider.h"
-#include "WebProcess.h"
#include "WebSocketChannelManager.h"
#include "WebSocketStream.h"
@@ -46,7 +45,7 @@
RefPtr<ThreadableWebSocketChannel> WebSocketProvider::createWebSocketChannel(Document& document, WebSocketChannelClient& client)
{
- return WebProcess::singleton().webSocketChannelManager().createWebSocketChannel(document, client);
+ return WebSocketChannel::create(document, client);
}
} // namespace WebKit