Changeset 54279 in webkit


Ignore:
Timestamp:
Feb 3, 2010 5:42:51 AM (14 years ago)
Author:
yael.aharon@nokia.com
Message:

[Qt] WebSockets : Buffer the data in WebKit instead of QtNetwork
https://bugs.webkit.org/show_bug.cgi?id=34425

Reviewed by Kenneth Rohde Christiansen.

Buffer the sent data in SocketStreamHandlePrivate instead of relying on
the network layer to do it. This is more robust and more consistent with how
Qt's HTTP stack works.
Close the socket in SocketStreamHandlePrivate::close() regardless of its state.

No new tests, since no new functionality is introduced.

  • platform/network/qt/SocketStreamHandlePrivate.h:
  • platform/network/qt/SocketStreamHandleQt.cpp:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54278 r54279  
     12010-02-02  Yael Aharon  <yael.aharon@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] WebSockets : Buffer the data in WebKit instead of QtNetwork
     6        https://bugs.webkit.org/show_bug.cgi?id=34425
     7
     8        Buffer the sent data in SocketStreamHandlePrivate instead of relying on
     9        the network layer to do it. This is more robust and more consistent with how
     10        Qt's HTTP stack works.
     11        Close the socket in SocketStreamHandlePrivate::close() regardless of its state.
     12
     13        No new tests, since no new functionality is introduced.
     14
     15        * platform/network/qt/SocketStreamHandlePrivate.h:
     16        * platform/network/qt/SocketStreamHandleQt.cpp:
     17        (WebCore::SocketStreamHandlePrivate::SocketStreamHandlePrivate):
     18        (WebCore::SocketStreamHandlePrivate::send):
     19        (WebCore::SocketStreamHandlePrivate::close):
     20        (WebCore::SocketStreamHandlePrivate::socketBytesWritten):
     21
    1222010-02-03  Shinichiro Hamaji  <hamaji@chromium.org>
    223
  • trunk/WebCore/platform/network/qt/SocketStreamHandlePrivate.h

    r54134 r54279  
    5656    void close();
    5757    void socketSentdata();
     58    void socketBytesWritten(qint64);
    5859    void socketClosed();
    5960    void socketError(QAbstractSocket::SocketError);
     
    6667    QTcpSocket* m_socket;
    6768    SocketStreamHandle* m_streamHandle;
     69    QByteArray m_data;
    6870};
    6971
  • trunk/WebCore/platform/network/qt/SocketStreamHandleQt.cpp

    r54134 r54279  
    5757        return;
    5858
    59     connect(m_socket, SIGNAL(connected()), this, SLOT(socketConnected()));
     59    if (isSecure) {
     60#ifndef QT_NO_OPENSSL
     61        connect(m_socket, SIGNAL(encrypted()), this, SLOT(socketConnected()));
     62        connect(m_socket, SIGNAL(encryptedBytesWritten(qint64)), this, SLOT(socketBytesWritten(qint64)));
     63#endif
     64    } else {
     65        connect(m_socket, SIGNAL(connected()), this, SLOT(socketConnected()));
     66        connect(m_socket, SIGNAL(bytesWritten(qint64)), this, SLOT(socketBytesWritten(qint64)));
     67    }
    6068    connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()));
    6169    connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketClosed()));
     
    100108    if (!m_socket || m_socket->state() != QAbstractSocket::ConnectedState)
    101109        return 0;
    102     quint64 sentSize = m_socket->write(data, len);
    103     QMetaObject::invokeMethod(this, "socketSentData", Qt::QueuedConnection);
    104     return sentSize;
     110    // If we are already sending something, then m_data is not empty.
     111    bool sending = m_data.length() > 0;
     112    m_data.append(data, len);
     113    if (!sending)
     114        m_socket->write(m_data);
     115    return len;
    105116}
    106117
    107118void SocketStreamHandlePrivate::close()
    108119{
    109     if (m_socket && m_socket->state() == QAbstractSocket::ConnectedState)
     120    if (m_socket)
    110121        m_socket->close();
    111122}
     
    115126    if (m_streamHandle)
    116127        m_streamHandle->sendPendingData();
     128}
     129
     130void SocketStreamHandlePrivate::socketBytesWritten(qint64 written)
     131{
     132    if (!m_socket || m_socket->state() != QAbstractSocket::ConnectedState || written < 0)
     133        return;
     134    m_data.remove(0, written);
     135    // If we are done sending all the data, then m_data is now empty
     136    if (m_data.isEmpty())
     137        QMetaObject::invokeMethod(this, "socketSentdata", Qt::QueuedConnection);
     138    else
     139        m_socket->write(m_data);
    117140}
    118141
Note: See TracChangeset for help on using the changeset viewer.