Changeset 246896 in webkit


Ignore:
Timestamp:
Jun 27, 2019 11:43:10 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Carlos Garcia Campos <cgarcia@igalia.com> 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:
Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r246895 r246896  
     12019-06-27  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebSockets: avoid data copies when queuing tasks in WebSocketChannel
     4        https://bugs.webkit.org/show_bug.cgi?id=199262
     5
     6        Reviewed by Alex Christensen.
     7
     8        For IPC message handler arguments we can receive rvalue references instead of const references.
     9
     10        * WebProcess/Network/WebSocketChannel.cpp:
     11        (WebKit::WebSocketChannel::didConnect):
     12        (WebKit::WebSocketChannel::didReceiveText):
     13        (WebKit::WebSocketChannel::didReceiveBinaryData):
     14        (WebKit::WebSocketChannel::didClose):
     15        (WebKit::WebSocketChannel::didReceiveMessageError):
     16        * WebProcess/Network/WebSocketChannel.h:
     17
    1182019-06-27  Youenn Fablet  <youenn@apple.com>
    219
  • trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp

    r246877 r246896  
    162162}
    163163
    164 void WebSocketChannel::didConnect(const String& subprotocol)
     164void WebSocketChannel::didConnect(String&& subprotocol)
    165165{
    166166    if (m_isClosing)
     
    171171
    172172    if (m_isSuspended) {
    173         enqueueTask([this, subprotocol] {
    174             didConnect(subprotocol);
    175         });
    176         return;
    177     }
    178 
    179     m_subprotocol = subprotocol;
     173        enqueueTask([this, subprotocol = WTFMove(subprotocol)] () mutable {
     174            didConnect(WTFMove(subprotocol));
     175        });
     176        return;
     177    }
     178
     179    m_subprotocol = WTFMove(subprotocol);
    180180    m_client->didConnect();
    181181}
    182182
    183 void WebSocketChannel::didReceiveText(const String& message)
     183void WebSocketChannel::didReceiveText(String&& message)
    184184{
    185185    if (m_isClosing)
     
    190190
    191191    if (m_isSuspended) {
    192         enqueueTask([this, message] {
    193             didReceiveText(message);
     192        enqueueTask([this, message = WTFMove(message)] () mutable {
     193            didReceiveText(WTFMove(message));
    194194        });
    195195        return;
     
    199199}
    200200
    201 void WebSocketChannel::didReceiveBinaryData(const IPC::DataReference& data)
     201void WebSocketChannel::didReceiveBinaryData(IPC::DataReference&& data)
    202202{
    203203    if (m_isClosing)
     
    208208
    209209    if (m_isSuspended) {
    210         enqueueTask([this, data = data.vector()]() mutable {
     210        enqueueTask([this, data = data.vector()] () mutable {
    211211            if (!m_isClosing && m_client)
    212212                m_client->didReceiveBinaryData(WTFMove(data));
     
    217217}
    218218
    219 void WebSocketChannel::didClose(unsigned short code, const String& reason)
    220 {
    221     if (!m_client)
    222         return;
    223 
    224     if (m_isSuspended) {
    225         enqueueTask([this, code, reason] {
    226             didClose(code, reason);
     219void WebSocketChannel::didClose(unsigned short code, String&& reason)
     220{
     221    if (!m_client)
     222        return;
     223
     224    if (m_isSuspended) {
     225        enqueueTask([this, code, reason = WTFMove(reason)] () mutable {
     226            didClose(code, WTFMove(reason));
    227227        });
    228228        return;
     
    235235}
    236236
    237 void WebSocketChannel::didReceiveMessageError(const String& errorMessage)
    238 {
    239     if (!m_client)
    240         return;
    241 
    242     if (m_isSuspended) {
    243         enqueueTask([this, errorMessage] {
    244             didReceiveMessageError(errorMessage);
     237void WebSocketChannel::didReceiveMessageError(String&& errorMessage)
     238{
     239    if (!m_client)
     240        return;
     241
     242    if (m_isSuspended) {
     243        enqueueTask([this, errorMessage = WTFMove(errorMessage)] () mutable {
     244            didReceiveMessageError(WTFMove(errorMessage));
    245245        });
    246246        return;
  • trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h

    r246877 r246896  
    7474
    7575    // Message receivers
    76     void didConnect(const String&);
    77     void didReceiveText(const String&);
    78     void didReceiveBinaryData(const IPC::DataReference&);
    79     void didClose(unsigned short code, const String&);
    80     void didReceiveMessageError(const String&);
     76    void didConnect(String&&);
     77    void didReceiveText(String&&);
     78    void didReceiveBinaryData(IPC::DataReference&&);
     79    void didClose(unsigned short code, String&&);
     80    void didReceiveMessageError(String&&);
    8181
    8282    // MessageSender
Note: See TracChangeset for help on using the changeset viewer.