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

Unified Diff: webrtc/libjingle/xmpp/xmppsocket.cc

Issue 1821083002: Split ByteBuffer into writer/reader objects. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « webrtc/libjingle/xmpp/xmppsocket.h ('k') | webrtc/media/base/rtpdump.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/libjingle/xmpp/xmppsocket.cc
diff --git a/webrtc/libjingle/xmpp/xmppsocket.cc b/webrtc/libjingle/xmpp/xmppsocket.cc
index 25e03efbe9271acb0e1dc3f94939fd2a3982f6f9..981815872b35a3e3744ed28e8836c12e154e625d 100644
--- a/webrtc/libjingle/xmpp/xmppsocket.cc
+++ b/webrtc/libjingle/xmpp/xmppsocket.cc
@@ -81,10 +81,13 @@ void XmppSocket::OnReadEvent(rtc::AsyncSocket * socket) {
void XmppSocket::OnWriteEvent(rtc::AsyncSocket * socket) {
// Write bytes if there are any
- while (buffer_.Length() != 0) {
- int written = cricket_socket_->Send(buffer_.Data(), buffer_.Length());
+ while (buffer_.size() > 0) {
+ int written = cricket_socket_->Send(buffer_.data(), buffer_.size());
if (written > 0) {
- buffer_.Consume(written);
+ ASSERT(static_cast<size_t>(written) <= buffer_.size());
+ memmove(buffer_.data(), buffer_.data() + written,
+ buffer_.size() - written);
+ buffer_.SetSize(buffer_.size() - written);
continue;
}
if (!cricket_socket_->IsBlocking())
@@ -131,11 +134,11 @@ void XmppSocket::OnEvent(rtc::StreamInterface* stream,
SignalRead();
if ((events & rtc::SE_WRITE)) {
// Write bytes if there are any
- while (buffer_.Length() != 0) {
+ while (buffer_.size() > 0) {
rtc::StreamResult result;
size_t written;
int error;
- result = stream_->Write(buffer_.Data(), buffer_.Length(),
+ result = stream_->Write(buffer_.data(), buffer_.size(),
&written, &error);
if (result == rtc::SR_ERROR) {
LOG(LS_ERROR) << "Send error: " << error;
@@ -145,7 +148,10 @@ void XmppSocket::OnEvent(rtc::StreamInterface* stream,
return;
ASSERT(result == rtc::SR_SUCCESS);
ASSERT(written > 0);
- buffer_.Shift(written);
+ ASSERT(written <= buffer_.size());
+ memmove(buffer_.data(), buffer_.data() + written,
+ buffer_.size() - written);
+ buffer_.SetSize(buffer_.size() - written);
}
}
if ((events & rtc::SE_CLOSE))
@@ -191,7 +197,7 @@ bool XmppSocket::Read(char * data, size_t len, size_t* len_read) {
}
bool XmppSocket::Write(const char * data, size_t len) {
- buffer_.WriteBytes(data, len);
+ buffer_.AppendData(data, len);
#ifndef USE_SSLSTREAM
OnWriteEvent(cricket_socket_);
#else // USE_SSLSTREAM
« no previous file with comments | « webrtc/libjingle/xmpp/xmppsocket.h ('k') | webrtc/media/base/rtpdump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698