Changeset 54279 in webkit
- Timestamp:
- Feb 3, 2010 5:42:51 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r54278 r54279 1 2010-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 1 22 2010-02-03 Shinichiro Hamaji <hamaji@chromium.org> 2 23 -
trunk/WebCore/platform/network/qt/SocketStreamHandlePrivate.h
r54134 r54279 56 56 void close(); 57 57 void socketSentdata(); 58 void socketBytesWritten(qint64); 58 59 void socketClosed(); 59 60 void socketError(QAbstractSocket::SocketError); … … 66 67 QTcpSocket* m_socket; 67 68 SocketStreamHandle* m_streamHandle; 69 QByteArray m_data; 68 70 }; 69 71 -
trunk/WebCore/platform/network/qt/SocketStreamHandleQt.cpp
r54134 r54279 57 57 return; 58 58 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 } 60 68 connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); 61 69 connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketClosed())); … … 100 108 if (!m_socket || m_socket->state() != QAbstractSocket::ConnectedState) 101 109 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; 105 116 } 106 117 107 118 void SocketStreamHandlePrivate::close() 108 119 { 109 if (m_socket && m_socket->state() == QAbstractSocket::ConnectedState)120 if (m_socket) 110 121 m_socket->close(); 111 122 } … … 115 126 if (m_streamHandle) 116 127 m_streamHandle->sendPendingData(); 128 } 129 130 void 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); 117 140 } 118 141
Note: See TracChangeset
for help on using the changeset viewer.