summaryrefslogtreecommitdiffstats
path: root/WebCore/websockets/WebSocketChannel.cpp
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2010-06-28 16:42:48 +0100
committerKristian Monsen <kristianm@google.com>2010-07-02 10:29:56 +0100
commit06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch)
tree20c1428cd05c76f32394ab354ea35ed99acd86d8 /WebCore/websockets/WebSocketChannel.cpp
parent72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff)
downloadexternal_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip
external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz
external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'WebCore/websockets/WebSocketChannel.cpp')
-rw-r--r--WebCore/websockets/WebSocketChannel.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/WebCore/websockets/WebSocketChannel.cpp b/WebCore/websockets/WebSocketChannel.cpp
index 9ca2b20..5859fd7 100644
--- a/WebCore/websockets/WebSocketChannel.cpp
+++ b/WebCore/websockets/WebSocketChannel.cpp
@@ -58,6 +58,7 @@ WebSocketChannel::WebSocketChannel(ScriptExecutionContext* context, WebSocketCha
, m_handshake(url, protocol, context)
, m_buffer(0)
, m_bufferSize(0)
+ , m_resumeTimer(this, &WebSocketChannel::resumeTimerFired)
, m_suspended(false)
, m_closed(false)
, m_unhandledBufferedAmount(0)
@@ -125,12 +126,8 @@ void WebSocketChannel::suspend()
void WebSocketChannel::resume()
{
m_suspended = false;
- RefPtr<WebSocketChannel> protect(this); // The client can close the channel, potentially removing the last reference.
- while (!m_suspended && m_client && m_buffer)
- if (!processBuffer())
- break;
- if (!m_suspended && m_client && m_closed && m_handle)
- didClose(m_handle.get());
+ if ((m_buffer || m_closed) && m_client && !m_resumeTimer.isActive())
+ m_resumeTimer.startOneShot(0);
}
void WebSocketChannel::didOpen(SocketStreamHandle* handle)
@@ -234,6 +231,7 @@ bool WebSocketChannel::processBuffer()
ASSERT(!m_suspended);
ASSERT(m_client);
ASSERT(m_buffer);
+
if (m_handshake.mode() == WebSocketHandshake::Incomplete) {
int headerLength = m_handshake.readServerHandshake(m_buffer, m_bufferSize);
if (headerLength <= 0)
@@ -318,6 +316,18 @@ bool WebSocketChannel::processBuffer()
return false;
}
+void WebSocketChannel::resumeTimerFired(Timer<WebSocketChannel>* timer)
+{
+ ASSERT_UNUSED(timer, timer == &m_resumeTimer);
+
+ RefPtr<WebSocketChannel> protect(this); // The client can close the channel, potentially removing the last reference.
+ while (!m_suspended && m_client && m_buffer)
+ if (!processBuffer())
+ break;
+ if (!m_suspended && m_client && m_closed && m_handle)
+ didClose(m_handle.get());
+}
+
} // namespace WebCore
#endif // ENABLE(WEB_SOCKETS)