Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2163)

Unified Diff: Source/web/WebSocketImpl.cpp

Issue 311993006: [WebSocket] bufferedAmount should not decrease inside a task. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/web/WebSocketImpl.cpp
diff --git a/Source/web/WebSocketImpl.cpp b/Source/web/WebSocketImpl.cpp
index a83ba25326394e7a51e9478dbee80c0b17c33252..da2b1c33fb0723fdd24c6ea885e299e195bbd7a0 100644
--- a/Source/web/WebSocketImpl.cpp
+++ b/Source/web/WebSocketImpl.cpp
@@ -42,6 +42,7 @@
#include "public/platform/WebURL.h"
#include "public/web/WebDocument.h"
#include "wtf/ArrayBuffer.h"
+#include "wtf/text/CString.h"
#include "wtf/text/WTFString.h"
using namespace WebCore;
@@ -51,6 +52,7 @@ namespace blink {
WebSocketImpl::WebSocketImpl(const WebDocument& document, WebSocketClient* client)
: m_client(client)
, m_binaryType(BinaryTypeBlob)
+ , m_bufferedAmount(0)
{
RefPtrWillBeRawPtr<Document> coreDocument = PassRefPtrWillBeRawPtr<Document>(document);
if (RuntimeEnabledFeatures::experimentalWebSocketEnabled()) {
@@ -95,17 +97,19 @@ WebString WebSocketImpl::extensions()
bool WebSocketImpl::sendText(const WebString& message)
{
+ m_bufferedAmount += ((String)message).utf8().length();
tyoshino (SeeGerritForStatus) 2014/06/16 07:31:42 WebString also has utf8()?
yhirano 2014/06/16 10:19:45 Done.
return m_private->send(message) == WebSocketChannel::SendSuccess;
}
bool WebSocketImpl::sendArrayBuffer(const WebArrayBuffer& webArrayBuffer)
{
+ m_bufferedAmount += webArrayBuffer.byteLength();
return m_private->send(*PassRefPtr<ArrayBuffer>(webArrayBuffer), 0, webArrayBuffer.byteLength()) == WebSocketChannel::SendSuccess;
}
unsigned long WebSocketImpl::bufferedAmount() const
{
- return m_private->bufferedAmount();
+ return m_bufferedAmount;
}
void WebSocketImpl::close(int code, const WebString& reason)
@@ -151,9 +155,9 @@ void WebSocketImpl::didReceiveMessageError()
m_client->didReceiveMessageError();
}
-void WebSocketImpl::didUpdateBufferedAmount(unsigned long bufferedAmount)
+void WebSocketImpl::didConsumeBufferedAmount(unsigned long consumed)
{
- m_client->didUpdateBufferedAmount(bufferedAmount);
+ m_bufferedAmount -= consumed;
}
void WebSocketImpl::didStartClosingHandshake()
@@ -161,9 +165,9 @@ void WebSocketImpl::didStartClosingHandshake()
m_client->didStartClosingHandshake();
}
-void WebSocketImpl::didClose(unsigned long bufferedAmount, ClosingHandshakeCompletionStatus status, unsigned short code, const String& reason)
+void WebSocketImpl::didClose(ClosingHandshakeCompletionStatus status, unsigned short code, const String& reason)
{
- m_client->didClose(bufferedAmount, static_cast<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(reason));
+ m_client->didClose(m_bufferedAmount, static_cast<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(reason));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698