summaryrefslogtreecommitdiffstats
path: root/WebCore/websockets
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/websockets')
-rw-r--r--WebCore/websockets/WebSocket.cpp2
-rw-r--r--WebCore/websockets/WebSocket.h2
-rw-r--r--WebCore/websockets/WebSocketChannel.cpp43
-rw-r--r--WebCore/websockets/WebSocketChannel.h8
4 files changed, 53 insertions, 2 deletions
diff --git a/WebCore/websockets/WebSocket.cpp b/WebCore/websockets/WebSocket.cpp
index 38629d7..073a924 100644
--- a/WebCore/websockets/WebSocket.cpp
+++ b/WebCore/websockets/WebSocket.cpp
@@ -216,7 +216,7 @@ bool WebSocket::canSuspend() const
return !m_channel;
}
-void WebSocket::suspend()
+void WebSocket::suspend(ReasonForSuspension)
{
if (m_channel)
m_channel->suspend();
diff --git a/WebCore/websockets/WebSocket.h b/WebCore/websockets/WebSocket.h
index fd3ee56..7f63cbf 100644
--- a/WebCore/websockets/WebSocket.h
+++ b/WebCore/websockets/WebSocket.h
@@ -83,7 +83,7 @@ namespace WebCore {
virtual ScriptExecutionContext* scriptExecutionContext() const;
virtual void contextDestroyed();
virtual bool canSuspend() const;
- virtual void suspend();
+ virtual void suspend(ReasonForSuspension);
virtual void resume();
virtual void stop();
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)
diff --git a/WebCore/websockets/WebSocketChannel.h b/WebCore/websockets/WebSocketChannel.h
index 43d431a..a08e6bb 100644
--- a/WebCore/websockets/WebSocketChannel.h
+++ b/WebCore/websockets/WebSocketChannel.h
@@ -84,6 +84,10 @@ 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;
@@ -96,6 +100,10 @@ namespace WebCore {
bool m_closed;
bool m_shouldDiscardReceivedData;
unsigned long m_unhandledBufferedAmount;
+
+#if ENABLE(INSPECTOR)
+ unsigned long m_identifier;
+#endif
};
} // namespace WebCore