Title: [246896] trunk/Source/WebKit
Revision
246896
Author
[email protected]
Date
2019-06-27 11:43:10 -0700 (Thu, 27 Jun 2019)

Log Message

WebSockets: avoid data copies when queuing tasks in WebSocketChannel
https://bugs.webkit.org/show_bug.cgi?id=199262

Patch by Carlos Garcia Campos <[email protected]> on 2019-06-27
Reviewed by Alex Christensen.

For IPC message handler arguments we can receive rvalue references instead of const references.

* WebProcess/Network/WebSocketChannel.cpp:
(WebKit::WebSocketChannel::didConnect):
(WebKit::WebSocketChannel::didReceiveText):
(WebKit::WebSocketChannel::didReceiveBinaryData):
(WebKit::WebSocketChannel::didClose):
(WebKit::WebSocketChannel::didReceiveMessageError):
* WebProcess/Network/WebSocketChannel.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (246895 => 246896)


--- trunk/Source/WebKit/ChangeLog	2019-06-27 18:36:13 UTC (rev 246895)
+++ trunk/Source/WebKit/ChangeLog	2019-06-27 18:43:10 UTC (rev 246896)
@@ -1,3 +1,20 @@
+2019-06-27  Carlos Garcia Campos  <[email protected]>
+
+        WebSockets: avoid data copies when queuing tasks in WebSocketChannel
+        https://bugs.webkit.org/show_bug.cgi?id=199262
+
+        Reviewed by Alex Christensen.
+
+        For IPC message handler arguments we can receive rvalue references instead of const references.
+
+        * WebProcess/Network/WebSocketChannel.cpp:
+        (WebKit::WebSocketChannel::didConnect):
+        (WebKit::WebSocketChannel::didReceiveText):
+        (WebKit::WebSocketChannel::didReceiveBinaryData):
+        (WebKit::WebSocketChannel::didClose):
+        (WebKit::WebSocketChannel::didReceiveMessageError):
+        * WebProcess/Network/WebSocketChannel.h:
+
 2019-06-27  Youenn Fablet  <[email protected]>
 
         Fix build after revision 246877

Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp (246895 => 246896)


--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp	2019-06-27 18:36:13 UTC (rev 246895)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp	2019-06-27 18:43:10 UTC (rev 246896)
@@ -161,7 +161,7 @@
     MessageSender::send(Messages::NetworkSocketChannel::Close { 0, { } });
 }
 
-void WebSocketChannel::didConnect(const String& subprotocol)
+void WebSocketChannel::didConnect(String&& subprotocol)
 {
     if (m_isClosing)
         return;
@@ -170,17 +170,17 @@
         return;
 
     if (m_isSuspended) {
-        enqueueTask([this, subprotocol] {
-            didConnect(subprotocol);
+        enqueueTask([this, subprotocol = WTFMove(subprotocol)] () mutable {
+            didConnect(WTFMove(subprotocol));
         });
         return;
     }
 
-    m_subprotocol = subprotocol;
+    m_subprotocol = WTFMove(subprotocol);
     m_client->didConnect();
 }
 
-void WebSocketChannel::didReceiveText(const String& message)
+void WebSocketChannel::didReceiveText(String&& message)
 {
     if (m_isClosing)
         return;
@@ -189,8 +189,8 @@
         return;
 
     if (m_isSuspended) {
-        enqueueTask([this, message] {
-            didReceiveText(message);
+        enqueueTask([this, message = WTFMove(message)] () mutable {
+            didReceiveText(WTFMove(message));
         });
         return;
     }
@@ -198,7 +198,7 @@
     m_client->didReceiveMessage(message);
 }
 
-void WebSocketChannel::didReceiveBinaryData(const IPC::DataReference& data)
+void WebSocketChannel::didReceiveBinaryData(IPC::DataReference&& data)
 {
     if (m_isClosing)
         return;
@@ -207,7 +207,7 @@
         return;
 
     if (m_isSuspended) {
-        enqueueTask([this, data = "" mutable {
+        enqueueTask([this, data = "" () mutable {
             if (!m_isClosing && m_client)
                 m_client->didReceiveBinaryData(WTFMove(data));
         });
@@ -216,14 +216,14 @@
     m_client->didReceiveBinaryData(data.vector());
 }
 
-void WebSocketChannel::didClose(unsigned short code, const String& reason)
+void WebSocketChannel::didClose(unsigned short code, String&& reason)
 {
     if (!m_client)
         return;
 
     if (m_isSuspended) {
-        enqueueTask([this, code, reason] {
-            didClose(code, reason);
+        enqueueTask([this, code, reason = WTFMove(reason)] () mutable {
+            didClose(code, WTFMove(reason));
         });
         return;
     }
@@ -234,14 +234,14 @@
     m_client->didClose(m_bufferedAmount, (m_isClosing || code == WebCore::WebSocketChannel::CloseEventCodeNormalClosure) ? WebCore::WebSocketChannelClient::ClosingHandshakeComplete : WebCore::WebSocketChannelClient::ClosingHandshakeIncomplete, code, reason);
 }
 
-void WebSocketChannel::didReceiveMessageError(const String& errorMessage)
+void WebSocketChannel::didReceiveMessageError(String&& errorMessage)
 {
     if (!m_client)
         return;
 
     if (m_isSuspended) {
-        enqueueTask([this, errorMessage] {
-            didReceiveMessageError(errorMessage);
+        enqueueTask([this, errorMessage = WTFMove(errorMessage)] () mutable {
+            didReceiveMessageError(WTFMove(errorMessage));
         });
         return;
     }

Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h (246895 => 246896)


--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h	2019-06-27 18:36:13 UTC (rev 246895)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h	2019-06-27 18:43:10 UTC (rev 246896)
@@ -73,11 +73,11 @@
     void derefThreadableWebSocketChannel() final { deref(); }
 
     // Message receivers
-    void didConnect(const String&);
-    void didReceiveText(const String&);
-    void didReceiveBinaryData(const IPC::DataReference&);
-    void didClose(unsigned short code, const String&);
-    void didReceiveMessageError(const String&);
+    void didConnect(String&&);
+    void didReceiveText(String&&);
+    void didReceiveBinaryData(IPC::DataReference&&);
+    void didClose(unsigned short code, String&&);
+    void didReceiveMessageError(String&&);
 
     // MessageSender
     IPC::Connection* messageSenderConnection() const final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to