diff options
Diffstat (limited to 'WebCore/websockets/WebSocketChannel.cpp')
-rw-r--r-- | WebCore/websockets/WebSocketChannel.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/WebCore/websockets/WebSocketChannel.cpp b/WebCore/websockets/WebSocketChannel.cpp index a09224d..5ce1cc3 100644 --- a/WebCore/websockets/WebSocketChannel.cpp +++ b/WebCore/websockets/WebSocketChannel.cpp @@ -36,8 +36,11 @@ #include "CookieJar.h" #include "Document.h" +#include "InspectorController.h" #include "Logging.h" +#include "Page.h" #include "PlatformString.h" +#include "ProgressTracker.h" #include "ScriptExecutionContext.h" #include "SocketStreamError.h" #include "SocketStreamHandle.h" @@ -63,7 +66,14 @@ WebSocketChannel::WebSocketChannel(ScriptExecutionContext* context, WebSocketCha , m_closed(false) , m_shouldDiscardReceivedData(false) , m_unhandledBufferedAmount(0) +#if ENABLE(INSPECTOR) + , m_identifier(0) +#endif { +#if ENABLE(INSPECTOR) + if (InspectorController* controller = m_context->inspectorController()) + controller->didCreateWebSocket(identifier(), url, m_context->url()); +#endif } WebSocketChannel::~WebSocketChannel() @@ -113,6 +123,11 @@ void WebSocketChannel::close() void WebSocketChannel::disconnect() { LOG(Network, "WebSocketChannel %p disconnect", this); +#if ENABLE(INSPECTOR) + if (m_context) + if (InspectorController* controller = m_context->inspectorController()) + controller->didCloseWebSocket(identifier()); +#endif m_handshake.clearScriptExecutionContext(); m_client = 0; m_context = 0; @@ -138,6 +153,10 @@ void WebSocketChannel::didOpen(SocketStreamHandle* handle) ASSERT(handle == m_handle); if (!m_context) return; +#if ENABLE(INSPECTOR) + if (InspectorController* controller = m_context->inspectorController()) + controller->willSendWebSocketHandshakeRequest(identifier(), m_handshake.clientHandshakeRequest()); +#endif const CString& handshakeMessage = m_handshake.clientHandshakeMessage(); if (!handle->send(handshakeMessage.data(), handshakeMessage.length())) { m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error sending handshake message.", 0, m_handshake.clientOrigin()); @@ -148,6 +167,11 @@ void WebSocketChannel::didOpen(SocketStreamHandle* handle) void WebSocketChannel::didClose(SocketStreamHandle* handle) { LOG(Network, "WebSocketChannel %p didClose", this); +#if ENABLE(INSPECTOR) + if (m_context) + if (InspectorController* controller = m_context->inspectorController()) + controller->didCloseWebSocket(identifier()); +#endif ASSERT_UNUSED(handle, handle == m_handle || !m_handle); m_closed = true; if (m_handle) { @@ -251,6 +275,10 @@ bool WebSocketChannel::processBuffer() if (headerLength <= 0) return false; if (m_handshake.mode() == WebSocketHandshake::Connected) { +#if ENABLE(INSPECTOR) + if (InspectorController* controller = m_context->inspectorController()) + controller->didReceiveWebSocketHandshakeResponse(identifier(), m_handshake.serverHandshakeResponse()); +#endif if (!m_handshake.serverSetCookie().isEmpty()) { if (m_context->isDocument()) { Document* document = static_cast<Document*>(m_context); @@ -368,6 +396,21 @@ void WebSocketChannel::resumeTimerFired(Timer<WebSocketChannel>* timer) didClose(m_handle.get()); } +#if ENABLE(INSPECTOR) +unsigned long WebSocketChannel::identifier() +{ + if (m_identifier) + return m_identifier; + + if (InspectorController* controller = m_context->inspectorController()) + if (Page* page = controller->inspectedPage()) + m_identifier = page->progress()->createUniqueIdentifier(); + + ASSERT(m_identifier); + return m_identifier; +} +#endif // ENABLE(INSPECTOR) + } // namespace WebCore #endif // ENABLE(WEB_SOCKETS) |