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

Unified Diff: Source/modules/websockets/NewWebSocketChannelImpl.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/modules/websockets/NewWebSocketChannelImpl.cpp
diff --git a/Source/modules/websockets/NewWebSocketChannelImpl.cpp b/Source/modules/websockets/NewWebSocketChannelImpl.cpp
index 7b056012a46a1b31e2b628f282b8c0e9336ebfc1..22331beed8a198d1ffb979bf5b71adce8fb812f1 100644
--- a/Source/modules/websockets/NewWebSocketChannelImpl.cpp
+++ b/Source/modules/websockets/NewWebSocketChannelImpl.cpp
@@ -191,6 +191,8 @@ WebSocketChannel::SendResult NewWebSocketChannelImpl::send(const String& message
CString data = message.utf8();
InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, WebSocketFrame::OpCodeText, true, data.data(), data.length());
}
+ if (m_client)
+ m_client->didIncreaseBufferedAmount(message.utf8().length());
m_messages.append(adoptPtr(new Message(message)));
sendInternal();
return SendSuccess;
@@ -207,6 +209,8 @@ WebSocketChannel::SendResult NewWebSocketChannelImpl::send(PassRefPtr<BlobDataHa
// affect actual behavior.
InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, WebSocketFrame::OpCodeBinary, true, "", 0);
}
+ if (m_client)
+ m_client->didIncreaseBufferedAmount(blobDataHandle->size());
m_messages.append(adoptPtr(new Message(blobDataHandle)));
sendInternal();
return SendSuccess;
@@ -220,6 +224,8 @@ WebSocketChannel::SendResult NewWebSocketChannelImpl::send(const ArrayBuffer& bu
// of individual frames.
InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, WebSocketFrame::OpCodeBinary, true, static_cast<const char*>(buffer.data()) + byteOffset, byteLength);
}
+ if (m_client)
+ m_client->didIncreaseBufferedAmount(byteLength);
// buffer.slice copies its contents.
// FIXME: Reduce copy by sending the data immediately when we don't need to
// queue the data.
@@ -317,7 +323,7 @@ NewWebSocketChannelImpl::Message::Message(PassOwnPtr<Vector<char> > vectorData)
void NewWebSocketChannelImpl::sendInternal()
{
ASSERT(m_handle);
- unsigned long bufferedAmount = m_bufferedAmount;
+ int64_t quota = m_sendingQuota;
while (!m_messages.isEmpty() && m_sendingQuota > 0 && !m_blobLoader) {
bool final = false;
Message* message = m_messages.first().get();
@@ -362,8 +368,9 @@ void NewWebSocketChannelImpl::sendInternal()
m_sentSizeOfTopMessage = 0;
}
}
- if (m_client && m_bufferedAmount != bufferedAmount) {
- m_client->didUpdateBufferedAmount(m_bufferedAmount);
+ if (m_client && quota != m_sendingQuota) {
+ unsigned long diff = quota - m_sendingQuota;
+ m_client->didDecreaseBufferedAmount(diff);
}
}

Powered by Google App Engine
This is Rietveld 408576698