Changeset 113026 in webkit
- Timestamp:
- Apr 3, 2012 6:24:11 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r113025 r113026 1 2012-03-29 Joseph Pecoraro <joepeck@webkit.org> and Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 3 Add a Generic WebSocket Server. 4 https://bugs.webkit.org/show_bug.cgi?id=73093 5 6 Reviewed by Simon Hausmann. 7 8 Allow SocketStreamHandle for the Qt port to take an existing QTcpSocket in its constructor. 9 10 * platform/network/qt/SocketStreamHandle.h: 11 (WebCore::SocketStreamHandle::create): 12 (SocketStreamHandle): 13 * platform/network/qt/SocketStreamHandlePrivate.h: 14 (SocketStreamHandlePrivate): 15 * platform/network/qt/SocketStreamHandleQt.cpp: 16 (WebCore::SocketStreamHandlePrivate::SocketStreamHandlePrivate): 17 (WebCore): 18 (WebCore::SocketStreamHandlePrivate::initConnections): 19 (WebCore::SocketStreamHandlePrivate::close): 20 (WebCore::SocketStreamHandle::SocketStreamHandle): 21 1 22 2012-04-01 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 23 -
trunk/Source/WebCore/platform/network/qt/SocketStreamHandle.h
r95901 r113026 43 43 #endif 44 44 45 QT_BEGIN_NAMESPACE 46 class QTcpSocket; 47 QT_END_NAMESPACE 48 45 49 namespace WebCore { 46 50 … … 53 57 public: 54 58 static PassRefPtr<SocketStreamHandle> create(const KURL& url, SocketStreamHandleClient* client) { return adoptRef(new SocketStreamHandle(url, client)); } 59 static PassRefPtr<SocketStreamHandle> create(QTcpSocket* socket, SocketStreamHandleClient* client) { return adoptRef(new SocketStreamHandle(socket, client)); } 55 60 56 61 virtual ~SocketStreamHandle(); … … 62 67 private: 63 68 SocketStreamHandle(const KURL&, SocketStreamHandleClient*); 69 SocketStreamHandle(QTcpSocket*, SocketStreamHandleClient*); 64 70 65 71 // No authentication for streams per se, but proxy may ask for credentials. -
trunk/Source/WebCore/platform/network/qt/SocketStreamHandlePrivate.h
r95901 r113026 48 48 public: 49 49 SocketStreamHandlePrivate(SocketStreamHandle*, const KURL&); 50 SocketStreamHandlePrivate(SocketStreamHandle*, QTcpSocket*); 50 51 ~SocketStreamHandlePrivate(); 51 52 … … 64 65 #endif 65 66 public: 67 void initConnections(); 66 68 QTcpSocket* m_socket; 67 69 SocketStreamHandle* m_streamHandle; -
trunk/Source/WebCore/platform/network/qt/SocketStreamHandleQt.cpp
r100891 r113026 41 41 namespace WebCore { 42 42 43 SocketStreamHandlePrivate::SocketStreamHandlePrivate(SocketStreamHandle* streamHandle, const KURL& url) : QObject()43 SocketStreamHandlePrivate::SocketStreamHandlePrivate(SocketStreamHandle* streamHandle, const KURL& url) 44 44 { 45 45 m_streamHandle = streamHandle; … … 57 57 return; 58 58 59 initConnections(); 60 61 unsigned int port = url.hasPort() ? url.port() : (isSecure ? 443 : 80); 62 63 QString host = url.host(); 64 if (isSecure) { 65 #ifndef QT_NO_OPENSSL 66 static_cast<QSslSocket*>(m_socket)->connectToHostEncrypted(host, port); 67 #endif 68 } else 69 m_socket->connectToHost(host, port); 70 } 71 72 SocketStreamHandlePrivate::SocketStreamHandlePrivate(SocketStreamHandle* streamHandle, QTcpSocket* socket) 73 { 74 m_streamHandle = streamHandle; 75 m_socket = socket; 76 initConnections(); 77 } 78 79 SocketStreamHandlePrivate::~SocketStreamHandlePrivate() 80 { 81 Q_ASSERT(!(m_socket && m_socket->state() == QAbstractSocket::ConnectedState)); 82 } 83 84 void SocketStreamHandlePrivate::initConnections() 85 { 59 86 connect(m_socket, SIGNAL(connected()), this, SLOT(socketConnected())); 60 87 connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); 61 88 connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketClosed())); 62 89 connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); 63 if (isSecure) 90 #ifndef QT_NO_OPENSSL 91 if (qobject_cast<QSslSocket*>(m_socket)) 64 92 connect(m_socket, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(socketSslErrors(const QList<QSslError>&))); 65 66 unsigned int port = url.hasPort() ? url.port() : (isSecure ? 443 : 80); 67 68 QString host = url.host(); 69 if (isSecure) { 70 #ifndef QT_NO_OPENSSL 71 static_cast<QSslSocket*>(m_socket)->connectToHostEncrypted(host, port); 72 #endif 73 } else 74 m_socket->connectToHost(host, port); 75 } 76 77 SocketStreamHandlePrivate::~SocketStreamHandlePrivate() 78 { 79 Q_ASSERT(!(m_socket && m_socket->state() == QAbstractSocket::ConnectedState)); 93 #endif 94 95 // Check for missed signals and call the slots asynchronously to allow a client to be set first. 96 if (m_socket->state() >= QAbstractSocket::ConnectedState) 97 QMetaObject::invokeMethod(this, "socketConnected", Qt::QueuedConnection); 98 if (m_socket->bytesAvailable()) 99 QMetaObject::invokeMethod(this, "socketReadyRead", Qt::QueuedConnection); 80 100 } 81 101 … … 107 127 void SocketStreamHandlePrivate::close() 108 128 { 109 if (m_streamHandle ->m_state == SocketStreamHandleBase::Connecting) {129 if (m_streamHandle && m_streamHandle->m_state == SocketStreamHandleBase::Connecting) { 110 130 m_socket->abort(); 111 131 m_streamHandle->client()->didCloseSocketStream(m_streamHandle); … … 167 187 } 168 188 189 SocketStreamHandle::SocketStreamHandle(QTcpSocket* socket, SocketStreamHandleClient* client) 190 : SocketStreamHandleBase(KURL(), client) 191 { 192 LOG(Network, "SocketStreamHandle %p new client %p", this, m_client); 193 m_p = new SocketStreamHandlePrivate(this, socket); 194 } 195 169 196 SocketStreamHandle::~SocketStreamHandle() 170 197 { -
trunk/Source/WebKit2/ChangeLog
r113022 r113026 1 2012-03-29 Joseph Pecoraro <joepeck@webkit.org> and Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 3 Add a Generic WebSocket Server. 4 https://bugs.webkit.org/show_bug.cgi?id=73093 5 6 Reviewed by Simon Hausmann. 7 8 The Inspector Server will be a WebSocket Server that also responds to 9 non-WebSocket-Upgrade HTTP Requests. This is a generic WebSocket server 10 that passes on what it doesn't know on to its client for extended 11 functionality. This code is wrapped in a new ENABLE(INSPECTOR_SERVER) flag. 12 13 There are no tests yet for a built-in WebSocket server. 14 This will be covered by API level tests in a later patch. 15 16 * Target.pri: 17 18 WebSocketServer is a simple server. Calling listen, or close, 19 multiple times is safe. Subclassing is expected. 20 21 * UIProcess/InspectorServer/WebSocketServer.cpp: Added. 22 (WebKit): 23 (WebKit::WebSocketServer::WebSocketServer): 24 (WebKit::WebSocketServer::~WebSocketServer): 25 (WebKit::WebSocketServer::listen): 26 (WebKit::WebSocketServer::close): 27 (WebKit::WebSocketServer::didAcceptConnection): 28 (WebKit::WebSocketServer::didCloseWebSocketServerConnection): 29 * UIProcess/InspectorServer/WebSocketServer.h: Added. 30 (WebKit): 31 (WebCore): 32 (WebSocketServer): 33 * UIProcess/InspectorServer/WebSocketServerClient.h: Added. 34 (WebCore): 35 (WebKit): 36 (WebSocketServerClient): 37 (WebKit::WebSocketServerClient::~WebSocketServerClient): 38 (WebKit::WebSocketServerClient::didReceiveUnrecognizedHTTPRequest): 39 (WebKit::WebSocketServerClient::didReceiveWebSocketUpgradeHTTPRequest): 40 (WebKit::WebSocketServerClient::didEstablishWebSocketConnection): 41 (WebKit::WebSocketServerClient::didReceiveWebSocketMessage): 42 (WebKit::WebSocketServerClient::didCloseWebSocketConnection): 43 44 Each WebSocketConnection: 45 46 - Passes unknown HTTP Requests to the server's client. 47 - Handles WebSocket Upgrade Requests. 48 - First ask the client if it is okay. 49 - Later notify the client about a success. 50 - Once upgraded the connection parses and passes WebSocket 51 frames to the client. 52 53 * UIProcess/InspectorServer/WebSocketServerConnection.cpp: Added. 54 (WebKit): 55 (WebKit::WebSocketServerConnection::WebSocketServerConnection): 56 (WebKit::WebSocketServerConnection::~WebSocketServerConnection): 57 (WebKit::WebSocketServerConnection::shutdownNow): 58 (WebKit::WebSocketServerConnection::shutdownAfterSendOrNow): meant to shutdown after an HTTP response. Ensure all platforms work as expected. 59 (WebKit::WebSocketServerConnection::sendWebSocketMessage): send a text message (WebSocket message) over the connection. 60 (WebKit::WebSocketServerConnection::sendHTTPResponseHeader): 61 (WebKit::WebSocketServerConnection::sendRawData): send raw data (HTTP message) over the connection. 62 (WebKit::WebSocketServerConnection::didCloseSocketStream): handle socket closing scenarios. 63 (WebKit::WebSocketServerConnection::didReceiveSocketStreamData): parse the incoming data in HTTP / WebSocket modes. 64 (WebKit::WebSocketServerConnection::didFailSocketStream): log errors. 65 (WebKit::WebSocketServerConnection::readHTTPMessage): when starting, a web socket connection reads an HTTP message. 66 (WebKit::WebSocketServerConnection::upgradeToWebSocketServerConnection): 67 (WebKit::WebSocketServerConnection::readWebSocketFrames): parse our buffer for as many frames as possible. 68 (WebKit::WebSocketServerConnection::readWebSocketFrame): parse an individual frame. 69 * UIProcess/InspectorServer/WebSocketServerConnection.h: Added. 70 (WebCore): 71 (WebKit): 72 (WebSocketServerConnection): 73 (WebKit::WebSocketServerConnection::identifier): 74 (WebKit::WebSocketServerConnection::setIdentifier): 75 76 Qt specific implementation. 77 78 * UIProcess/InspectorServer/qt/WebSocketServerQt.cpp: Added. 79 (WebKit): 80 (WebKit::WebSocketServer::platformInitialize): 81 (WebKit::WebSocketServer::platformListen): 82 (WebKit::WebSocketServer::platformClose): 83 (WebKit::QtTcpServerHandler::QtTcpServerHandler): 84 (WebKit::QtTcpServerHandler::handleNewConnection): 85 (WebKit::QtTcpServerHandler::listen): 86 (WebKit::QtTcpServerHandler::close): 87 * UIProcess/InspectorServer/qt/WebSocketServerQt.h: Added. 88 (WebKit): 89 (QtTcpServerHandler): 90 91 * WebKit2.pri: 92 * config.h: Add ENABLE(INSPECTOR_SERVER) for WebKit2. 93 1 94 2012-04-03 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 95 -
trunk/Source/WebKit2/Target.pri
r112889 r113026 205 205 UIProcess/GeolocationPermissionRequestManagerProxy.h \ 206 206 UIProcess/GeolocationPermissionRequestProxy.h \ 207 UIProcess/InspectorServer/WebSocketServer.h \ 208 UIProcess/InspectorServer/WebSocketServerClient.h \ 209 UIProcess/InspectorServer/WebSocketServerConnection.h \ 210 UIProcess/InspectorServer/qt/WebSocketServerQt.h \ 207 211 UIProcess/Launcher/ProcessLauncher.h \ 208 212 UIProcess/Launcher/ThreadLauncher.h \ … … 542 546 UIProcess/GeolocationPermissionRequestManagerProxy.cpp \ 543 547 UIProcess/GeolocationPermissionRequestProxy.cpp \ 548 UIProcess/InspectorServer/WebSocketServer.cpp \ 549 UIProcess/InspectorServer/WebSocketServerConnection.cpp \ 550 UIProcess/InspectorServer/qt/WebSocketServerQt.cpp \ 544 551 UIProcess/Launcher/ProcessLauncher.cpp \ 545 552 UIProcess/Launcher/ThreadLauncher.cpp \ -
trunk/Source/WebKit2/WebKit2.pri
r111783 r113026 28 28 $$SOURCE_DIR/UIProcess/Authentication \ 29 29 $$SOURCE_DIR/UIProcess/Downloads \ 30 $$SOURCE_DIR/UIProcess/InspectorServer \ 31 $$SOURCE_DIR/UIProcess/InspectorServer/qt \ 30 32 $$SOURCE_DIR/UIProcess/Launcher \ 31 33 $$SOURCE_DIR/UIProcess/Notifications \ -
trunk/Source/WebKit2/config.h
r105203 r113026 136 136 137 137 #define PLUGIN_ARCHITECTURE(ARCH) (defined PLUGIN_ARCHITECTURE_##ARCH && PLUGIN_ARCHITECTURE_##ARCH) 138 139 #ifndef ENABLE_INSPECTOR_SERVER 140 #if PLATFORM(QT) 141 #define ENABLE_INSPECTOR_SERVER 1 142 #endif 143 #endif
Note: See TracChangeset
for help on using the changeset viewer.