From e14391e94c850b8bd03680c23b38978db68687a8 Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 4 Nov 2010 12:00:17 -0700 Subject: Merge Webkit at r70949: Initial merge by git. Change-Id: I77b8645c083b5d0da8dba73ed01d4014aab9848e --- WebCore/websockets/WebSocketChannel.cpp | 55 +++++++++------------------------ WebCore/websockets/WebSocketChannel.h | 8 +---- 2 files changed, 16 insertions(+), 47 deletions(-) (limited to 'WebCore/websockets') diff --git a/WebCore/websockets/WebSocketChannel.cpp b/WebCore/websockets/WebSocketChannel.cpp index 45bb206..01c2bef 100644 --- a/WebCore/websockets/WebSocketChannel.cpp +++ b/WebCore/websockets/WebSocketChannel.cpp @@ -36,7 +36,7 @@ #include "CookieJar.h" #include "Document.h" -#include "InspectorController.h" +#include "InspectorInstrumentation.h" #include "Logging.h" #include "Page.h" #include "PlatformString.h" @@ -67,14 +67,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 + if (m_context->isDocument()) + if (Page* page = static_cast(m_context)->page()) + m_identifier = page->progress()->createUniqueIdentifier(); + + if (m_identifier) + InspectorInstrumentation::didCreateWebSocket(m_context, m_identifier, url, m_context->url()); } WebSocketChannel::~WebSocketChannel() @@ -124,11 +124,8 @@ 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 + if (m_identifier && m_context) + InspectorInstrumentation::didCloseWebSocket(m_context, m_identifier); m_handshake.clearScriptExecutionContext(); m_client = 0; m_context = 0; @@ -154,10 +151,8 @@ 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 + if (m_identifier) + InspectorInstrumentation::willSendWebSocketHandshakeRequest(m_context, m_identifier, m_handshake.clientHandshakeRequest()); 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()); @@ -168,11 +163,8 @@ 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 + if (m_identifier && m_context) + InspectorInstrumentation::didCloseWebSocket(m_context, m_identifier); ASSERT_UNUSED(handle, handle == m_handle || !m_handle); m_closed = true; if (m_handle) { @@ -276,10 +268,8 @@ 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_identifier) + InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(m_context, m_identifier, m_handshake.serverHandshakeResponse()); if (!m_handshake.serverSetCookie().isEmpty()) { if (m_context->isDocument()) { Document* document = static_cast(m_context); @@ -397,21 +387,6 @@ void WebSocketChannel::resumeTimerFired(Timer* 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) diff --git a/WebCore/websockets/WebSocketChannel.h b/WebCore/websockets/WebSocketChannel.h index a08e6bb..9c52377 100644 --- a/WebCore/websockets/WebSocketChannel.h +++ b/WebCore/websockets/WebSocketChannel.h @@ -84,10 +84,6 @@ namespace WebCore { bool processBuffer(); void resumeTimerFired(Timer* timer); -#if ENABLE(INSPECTOR) - unsigned long identifier(); -#endif - ScriptExecutionContext* m_context; WebSocketChannelClient* m_client; WebSocketHandshake m_handshake; @@ -101,9 +97,7 @@ namespace WebCore { bool m_shouldDiscardReceivedData; unsigned long m_unhandledBufferedAmount; -#if ENABLE(INSPECTOR) - unsigned long m_identifier; -#endif + unsigned long m_identifier; // m_identifier == 0 means that we could not obtain a valid identifier. }; } // namespace WebCore -- cgit v1.1