summaryrefslogtreecommitdiffstats
path: root/WebCore/websockets
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2010-11-04 12:00:17 -0700
committerJohn Reck <jreck@google.com>2010-11-09 11:35:04 -0800
commite14391e94c850b8bd03680c23b38978db68687a8 (patch)
tree3fed87e6620fecaf3edc7259ae58a11662bedcb2 /WebCore/websockets
parent1bd705833a68f07850cf7e204b26f8d328d16951 (diff)
downloadexternal_webkit-e14391e94c850b8bd03680c23b38978db68687a8.zip
external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.gz
external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.bz2
Merge Webkit at r70949: Initial merge by git.
Change-Id: I77b8645c083b5d0da8dba73ed01d4014aab9848e
Diffstat (limited to 'WebCore/websockets')
-rw-r--r--WebCore/websockets/WebSocketChannel.cpp55
-rw-r--r--WebCore/websockets/WebSocketChannel.h8
2 files changed, 16 insertions, 47 deletions
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<Document*>(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<Document*>(m_context);
@@ -397,21 +387,6 @@ 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)
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<WebSocketChannel>* 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