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

Unified Diff: net/base/tcp_client_socket_win.cc

Issue 87073: Extend the use of IOBuffers to the code underneath... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 | « net/base/tcp_client_socket_win.h ('k') | net/http/http_network_transaction.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/tcp_client_socket_win.cc
===================================================================
--- net/base/tcp_client_socket_win.cc (revision 14682)
+++ net/base/tcp_client_socket_win.cc (working copy)
@@ -173,6 +173,8 @@
waiting_read_ = false;
waiting_write_ = false;
+ read_iobuffer_ = NULL;
+ write_iobuffer_ = NULL;
waiting_connect_ = false;
}
@@ -207,15 +209,16 @@
return true;
}
-int TCPClientSocketWin::Read(char* buf,
+int TCPClientSocketWin::Read(IOBuffer* buf,
int buf_len,
CompletionCallback* callback) {
DCHECK_NE(socket_, INVALID_SOCKET);
DCHECK(!waiting_read_);
DCHECK(!read_callback_);
+ DCHECK(!read_iobuffer_);
read_buffer_.len = buf_len;
- read_buffer_.buf = buf;
+ read_buffer_.buf = buf->data();
TRACE_EVENT_BEGIN("socket.read", this, "");
// TODO(wtc): Remove the CHECK after enough testing.
@@ -241,21 +244,23 @@
read_watcher_.StartWatching(read_overlapped_.hEvent, &reader_);
waiting_read_ = true;
read_callback_ = callback;
+ read_iobuffer_ = buf;
return ERR_IO_PENDING;
}
return MapWinsockError(err);
}
-int TCPClientSocketWin::Write(const char* buf,
+int TCPClientSocketWin::Write(IOBuffer* buf,
int buf_len,
CompletionCallback* callback) {
DCHECK_NE(socket_, INVALID_SOCKET);
DCHECK(!waiting_write_);
DCHECK(!write_callback_);
DCHECK_GT(buf_len, 0);
+ DCHECK(!write_iobuffer_);
write_buffer_.len = buf_len;
- write_buffer_.buf = const_cast<char*>(buf);
+ write_buffer_.buf = buf->data();
TRACE_EVENT_BEGIN("socket.write", this, "");
// TODO(wtc): Remove the CHECK after enough testing.
@@ -273,6 +278,7 @@
write_watcher_.StartWatching(write_overlapped_.hEvent, &writer_);
waiting_write_ = true;
write_callback_ = callback;
+ write_iobuffer_ = buf;
return ERR_IO_PENDING;
}
return MapWinsockError(err);
@@ -405,6 +411,7 @@
if (tcp_socket_->waiting_connect_) {
tcp_socket_->DidCompleteConnect();
} else {
+ DCHECK(tcp_socket_->waiting_read_);
DWORD num_bytes, flags;
BOOL ok = WSAGetOverlappedResult(
tcp_socket_->socket_, &tcp_socket_->read_overlapped_, &num_bytes,
@@ -413,6 +420,7 @@
TRACE_EVENT_END("socket.read", tcp_socket_,
StringPrintf("%d bytes", num_bytes));
tcp_socket_->waiting_read_ = false;
+ tcp_socket_->read_iobuffer_ = NULL;
tcp_socket_->DoReadCallback(
ok ? num_bytes : MapWinsockError(WSAGetLastError()));
}
@@ -420,6 +428,7 @@
void TCPClientSocketWin::WriteDelegate::OnObjectSignaled(HANDLE object) {
DCHECK_EQ(object, tcp_socket_->write_overlapped_.hEvent);
+ DCHECK(tcp_socket_->waiting_write_);
DWORD num_bytes, flags;
BOOL ok = WSAGetOverlappedResult(
@@ -429,6 +438,7 @@
TRACE_EVENT_END("socket.write", tcp_socket_,
StringPrintf("%d bytes", num_bytes));
tcp_socket_->waiting_write_ = false;
+ tcp_socket_->write_iobuffer_ = NULL;
tcp_socket_->DoWriteCallback(
ok ? num_bytes : MapWinsockError(WSAGetLastError()));
}
« no previous file with comments | « net/base/tcp_client_socket_win.h ('k') | net/http/http_network_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698