[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756
ukai at chromium.org
ukai at chromium.org
Fri Feb 26 22:23:40 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 13a010e81a08fee9058f1610fec1d4db3ef8e1c6
Author: ukai at chromium.org <ukai at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Feb 18 05:32:05 2010 +0000
2010-02-17 Fumitoshi Ukai <ukai at chromium.org>
Reviewed by Alexey Proskuryakov.
WebSocket bufferedAmount should not be 0 when send after close.
https://bugs.webkit.org/show_bug.cgi?id=34633
* websocket/tests/bufferedAmount-after-close-expected.txt: Added.
* websocket/tests/bufferedAmount-after-close.html: Added.
* websocket/tests/script-tests/bufferedAmount-after-close.js: Added.
2010-02-17 Fumitoshi Ukai <ukai at chromium.org>
Reviewed by Alexey Proskuryakov.
WebSocket bufferedAmount should not be 0 when send after close.
https://bugs.webkit.org/show_bug.cgi?id=34633
Fixed bug in webkit r54694. check m_client after it calls user
callback, because user callback may call close(), which would
call onclose event handler.
Test: websocket/tests/bufferedAmount-after-close.html
* websockets/ThreadableWebSocketChannelClientWrapper.h:
(WebCore::ThreadableWebSocketChannelClientWrapper::didClose):
* websockets/WebSocket.cpp:
(WebCore::WebSocket::WebSocket):
(WebCore::WebSocket::send):
(WebCore::WebSocket::close):
(WebCore::WebSocket::bufferedAmount):
(WebCore::WebSocket::didConnect):
(WebCore::WebSocket::didClose):
* websockets/WebSocket.h:
* websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::WebSocketChannel):
(WebCore::WebSocketChannel::send):
(WebCore::WebSocketChannel::bufferedAmount):
(WebCore::WebSocketChannel::didClose):
(WebCore::WebSocketChannel::didReceiveData):
* websockets/WebSocketChannel.h:
* websockets/WebSocketChannelClient.h:
(WebCore::WebSocketChannelClient::didClose):
* websockets/WorkerThreadableWebSocketChannel.cpp:
(WebCore::workerContextDidClose):
(WebCore::WorkerThreadableWebSocketChannel::Peer::didClose):
* websockets/WorkerThreadableWebSocketChannel.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54927 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index c31f093..6b5adf1 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-02-17 Fumitoshi Ukai <ukai at chromium.org>
+
+ Reviewed by Alexey Proskuryakov.
+
+ WebSocket bufferedAmount should not be 0 when send after close.
+ https://bugs.webkit.org/show_bug.cgi?id=34633
+
+ * websocket/tests/bufferedAmount-after-close-expected.txt: Added.
+ * websocket/tests/bufferedAmount-after-close.html: Added.
+ * websocket/tests/script-tests/bufferedAmount-after-close.js: Added.
+
2010-02-17 Yuzo Fujishima <yuzo at google.com>
Reviewed by Eric Seidel.
diff --git a/LayoutTests/websocket/tests/bufferedAmount-after-close-expected.txt b/LayoutTests/websocket/tests/bufferedAmount-after-close-expected.txt
new file mode 100644
index 0000000..19e600d
--- /dev/null
+++ b/LayoutTests/websocket/tests/bufferedAmount-after-close-expected.txt
@@ -0,0 +1,14 @@
+Web Socket bufferedAmount after closed
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Connected.
+Closed.
+PASS ws.readyState is 2
+PASS ws.bufferedAmount is 0
+PASS ws.send('send to closed socket') is false
+PASS ws.bufferedAmount is 23
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/websocket/tests/bufferedAmount-after-close.html b/LayoutTests/websocket/tests/bufferedAmount-after-close.html
new file mode 100644
index 0000000..f9a60ab
--- /dev/null
+++ b/LayoutTests/websocket/tests/bufferedAmount-after-close.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script src="script-tests/bufferedAmount-after-close.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/websocket/tests/script-tests/bufferedAmount-after-close.js b/LayoutTests/websocket/tests/script-tests/bufferedAmount-after-close.js
new file mode 100644
index 0000000..a79d3d7
--- /dev/null
+++ b/LayoutTests/websocket/tests/script-tests/bufferedAmount-after-close.js
@@ -0,0 +1,34 @@
+description("Web Socket bufferedAmount after closed");
+
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function endTest()
+{
+ isSuccessfullyParsed();
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+var ws = new WebSocket("ws://localhost:8880/websocket/tests/simple");
+
+ws.onopen = function()
+{
+ debug("Connected.");
+ ws.close();
+};
+
+ws.onclose = function()
+{
+ debug("Closed.");
+ shouldBe("ws.readyState", "2");
+ shouldBe("ws.bufferedAmount", "0");
+ shouldBeFalse("ws.send('send to closed socket')");
+ // If the connection is closed, bufferedAmount attribute's value will only
+ // increase with each call to the send() method.
+ // (the number does not reset to zero once the connection closes).
+ shouldBe("ws.bufferedAmount", "23");
+ endTest();
+};
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8a7a950..064d0c6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,40 @@
+2010-02-17 Fumitoshi Ukai <ukai at chromium.org>
+
+ Reviewed by Alexey Proskuryakov.
+
+ WebSocket bufferedAmount should not be 0 when send after close.
+ https://bugs.webkit.org/show_bug.cgi?id=34633
+
+ Fixed bug in webkit r54694. check m_client after it calls user
+ callback, because user callback may call close(), which would
+ call onclose event handler.
+
+ Test: websocket/tests/bufferedAmount-after-close.html
+
+ * websockets/ThreadableWebSocketChannelClientWrapper.h:
+ (WebCore::ThreadableWebSocketChannelClientWrapper::didClose):
+ * websockets/WebSocket.cpp:
+ (WebCore::WebSocket::WebSocket):
+ (WebCore::WebSocket::send):
+ (WebCore::WebSocket::close):
+ (WebCore::WebSocket::bufferedAmount):
+ (WebCore::WebSocket::didConnect):
+ (WebCore::WebSocket::didClose):
+ * websockets/WebSocket.h:
+ * websockets/WebSocketChannel.cpp:
+ (WebCore::WebSocketChannel::WebSocketChannel):
+ (WebCore::WebSocketChannel::send):
+ (WebCore::WebSocketChannel::bufferedAmount):
+ (WebCore::WebSocketChannel::didClose):
+ (WebCore::WebSocketChannel::didReceiveData):
+ * websockets/WebSocketChannel.h:
+ * websockets/WebSocketChannelClient.h:
+ (WebCore::WebSocketChannelClient::didClose):
+ * websockets/WorkerThreadableWebSocketChannel.cpp:
+ (WebCore::workerContextDidClose):
+ (WebCore::WorkerThreadableWebSocketChannel::Peer::didClose):
+ * websockets/WorkerThreadableWebSocketChannel.h:
+
2010-02-17 Yuzo Fujishima <yuzo at google.com>
Reviewed by Eric Seidel.
diff --git a/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h b/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h
index 8bf51fa..28d6129 100644
--- a/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h
+++ b/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h
@@ -99,10 +99,10 @@ public:
m_client->didReceiveMessage(msg);
}
- void didClose()
+ void didClose(unsigned long unhandledBufferedAmount)
{
if (m_client)
- m_client->didClose();
+ m_client->didClose(unhandledBufferedAmount);
}
protected:
diff --git a/WebCore/websockets/WebSocket.cpp b/WebCore/websockets/WebSocket.cpp
index f50dc5c..cd5528b 100644
--- a/WebCore/websockets/WebSocket.cpp
+++ b/WebCore/websockets/WebSocket.cpp
@@ -97,6 +97,7 @@ bool WebSocket::isAvailable()
WebSocket::WebSocket(ScriptExecutionContext* context)
: ActiveDOMObject(context, this)
, m_state(CONNECTING)
+ , m_bufferedAmountAfterClose(0)
{
}
@@ -162,9 +163,12 @@ bool WebSocket::send(const String& message, ExceptionCode& ec)
return false;
}
// No exception is raised if the connection was once established but has subsequently been closed.
- if (m_state == CLOSED)
+ if (m_state == CLOSED) {
+ m_bufferedAmountAfterClose += message.utf8().length() + 2; // 2 for frameing
return false;
+ }
// FIXME: check message is valid utf8.
+ ASSERT(m_channel);
return m_channel->send(message);
}
@@ -174,6 +178,7 @@ void WebSocket::close()
if (m_state == CLOSED)
return;
m_state = CLOSED;
+ m_bufferedAmountAfterClose = m_channel->bufferedAmount();
m_channel->close();
}
@@ -191,7 +196,7 @@ unsigned long WebSocket::bufferedAmount() const
{
if (m_state == OPEN)
return m_channel->bufferedAmount();
- return 0;
+ return m_bufferedAmountAfterClose;
}
ScriptExecutionContext* WebSocket::scriptExecutionContext() const
@@ -223,7 +228,7 @@ void WebSocket::didConnect()
{
LOG(Network, "WebSocket %p didConnect", this);
if (m_state != CONNECTING || !scriptExecutionContext()) {
- didClose();
+ didClose(0);
return;
}
m_state = OPEN;
@@ -240,10 +245,11 @@ void WebSocket::didReceiveMessage(const String& msg)
dispatchEvent(evt);
}
-void WebSocket::didClose()
+void WebSocket::didClose(unsigned long unhandledBufferedAmount)
{
LOG(Network, "WebSocket %p didClose", this);
m_state = CLOSED;
+ m_bufferedAmountAfterClose += unhandledBufferedAmount;
dispatchEvent(Event::create(eventNames().closeEvent, false, false));
m_channel = 0;
if (hasPendingActivity())
diff --git a/WebCore/websockets/WebSocket.h b/WebCore/websockets/WebSocket.h
index c72dbbd..8bda882 100644
--- a/WebCore/websockets/WebSocket.h
+++ b/WebCore/websockets/WebSocket.h
@@ -91,7 +91,7 @@ namespace WebCore {
// WebSocketChannelClient
virtual void didConnect();
virtual void didReceiveMessage(const String& message);
- virtual void didClose();
+ virtual void didClose(unsigned long unhandledBufferedAmount);
private:
WebSocket(ScriptExecutionContext*);
@@ -111,6 +111,7 @@ namespace WebCore {
KURL m_url;
String m_protocol;
EventTargetData m_eventTargetData;
+ unsigned long m_bufferedAmountAfterClose;
};
} // namespace WebCore
diff --git a/WebCore/websockets/WebSocketChannel.cpp b/WebCore/websockets/WebSocketChannel.cpp
index df66c14..7b87bf3 100644
--- a/WebCore/websockets/WebSocketChannel.cpp
+++ b/WebCore/websockets/WebSocketChannel.cpp
@@ -57,7 +57,6 @@ WebSocketChannel::WebSocketChannel(ScriptExecutionContext* context, WebSocketCha
, m_handshake(url, protocol, context)
, m_buffer(0)
, m_bufferSize(0)
- , m_unhandledBufferSize(0)
{
}
@@ -78,22 +77,18 @@ void WebSocketChannel::connect()
bool WebSocketChannel::send(const String& msg)
{
LOG(Network, "WebSocketChannel %p send %s", this, msg.utf8().data());
+ ASSERT(m_handle);
Vector<char> buf;
buf.append('\0'); // frame type
buf.append(msg.utf8().data(), msg.utf8().length());
buf.append('\xff'); // frame end
- if (!m_handle) {
- m_unhandledBufferSize += buf.size();
- return false;
- }
return m_handle->send(buf.data(), buf.size());
}
unsigned long WebSocketChannel::bufferedAmount() const
{
LOG(Network, "WebSocketChannel %p bufferedAmount", this);
- if (!m_handle)
- return m_unhandledBufferSize;
+ ASSERT(m_handle);
return m_handle->bufferedAmount();
}
@@ -126,14 +121,14 @@ void WebSocketChannel::didOpen(SocketStreamHandle* handle)
void WebSocketChannel::didClose(SocketStreamHandle* handle)
{
LOG(Network, "WebSocketChannel %p didClose", this);
- ASSERT(handle == m_handle || !m_handle);
+ ASSERT_UNUSED(handle, handle == m_handle || !m_handle);
if (m_handle) {
- m_unhandledBufferSize = handle->bufferedAmount();
+ unsigned long unhandledBufferedAmount = m_handle->bufferedAmount();
WebSocketChannelClient* client = m_client;
m_client = 0;
m_handle = 0;
if (client)
- client->didClose();
+ client->didClose(unhandledBufferedAmount);
}
deref();
}
@@ -169,6 +164,8 @@ void WebSocketChannel::didReceiveData(SocketStreamHandle* handle, const char* da
// FIXME: handle set-cookie2.
LOG(Network, "WebSocketChannel %p connected", this);
m_client->didConnect();
+ if (!m_client)
+ return;
break;
default:
LOG(Network, "WebSocketChannel %p connection failed", this);
@@ -214,6 +211,8 @@ void WebSocketChannel::didReceiveData(SocketStreamHandle* handle, const char* da
if (p < end && *p == '\xff') {
if (frameByte == 0x00)
m_client->didReceiveMessage(String::fromUTF8(msgStart, p - msgStart));
+ if (!m_client)
+ return;
++p;
nextFrame = p;
}
diff --git a/WebCore/websockets/WebSocketChannel.h b/WebCore/websockets/WebSocketChannel.h
index 7ec826c..41a03ab 100644
--- a/WebCore/websockets/WebSocketChannel.h
+++ b/WebCore/websockets/WebSocketChannel.h
@@ -83,7 +83,6 @@ namespace WebCore {
RefPtr<SocketStreamHandle> m_handle;
char* m_buffer;
int m_bufferSize;
- unsigned long m_unhandledBufferSize;
};
} // namespace WebCore
diff --git a/WebCore/websockets/WebSocketChannelClient.h b/WebCore/websockets/WebSocketChannelClient.h
index 163070f..5328eb7 100644
--- a/WebCore/websockets/WebSocketChannelClient.h
+++ b/WebCore/websockets/WebSocketChannelClient.h
@@ -40,7 +40,7 @@ namespace WebCore {
virtual ~WebSocketChannelClient() { }
virtual void didConnect() { }
virtual void didReceiveMessage(const String&) { }
- virtual void didClose() { }
+ virtual void didClose(unsigned long /* unhandledBufferedAmount */) { }
protected:
WebSocketChannelClient() { }
diff --git a/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp b/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp
index dac1f19..3dda104 100644
--- a/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp
+++ b/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp
@@ -190,17 +190,17 @@ void WorkerThreadableWebSocketChannel::Peer::didReceiveMessage(const String& mes
m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidReceiveMessage, m_workerClientWrapper, message), m_taskMode);
}
-static void workerContextDidClose(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper)
+static void workerContextDidClose(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, unsigned long unhandledBufferedAmount)
{
ASSERT_UNUSED(context, context->isWorkerContext());
- workerClientWrapper->didClose();
+ workerClientWrapper->didClose(unhandledBufferedAmount);
}
-void WorkerThreadableWebSocketChannel::Peer::didClose()
+void WorkerThreadableWebSocketChannel::Peer::didClose(unsigned long unhandledBufferedAmount)
{
ASSERT(isMainThread());
m_mainWebSocketChannel = 0;
- m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidClose, m_workerClientWrapper), m_taskMode);
+ m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidClose, m_workerClientWrapper, unhandledBufferedAmount), m_taskMode);
}
void WorkerThreadableWebSocketChannel::Bridge::setWebSocketChannel(ScriptExecutionContext* context, Bridge* thisPtr, Peer* peer, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper)
diff --git a/WebCore/websockets/WorkerThreadableWebSocketChannel.h b/WebCore/websockets/WorkerThreadableWebSocketChannel.h
index 1106f43..a6a1680 100644
--- a/WebCore/websockets/WorkerThreadableWebSocketChannel.h
+++ b/WebCore/websockets/WorkerThreadableWebSocketChannel.h
@@ -91,7 +91,7 @@ private:
virtual void didConnect();
virtual void didReceiveMessage(const String& message);
- virtual void didClose();
+ virtual void didClose(unsigned long unhandledBufferedAmount);
private:
Peer(RefPtr<ThreadableWebSocketChannelClientWrapper>, WorkerLoaderProxy&, ScriptExecutionContext*, const String& taskMode, const KURL&, const String& protocol);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list