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

Unified Diff: net/udp/udp_socket_win.cc

Issue 8824006: Migrate net/socket/socket.h, net/socket/stream_socket.h to base::Bind(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years 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/udp/udp_socket_win.h ('k') | net/url_request/url_request_ftp_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/udp/udp_socket_win.cc
diff --git a/net/udp/udp_socket_win.cc b/net/udp/udp_socket_win.cc
index 88aa23b2bec2d253c10ffc4b49f0776706a7690b..06f5e3da282c6f090cf8e308ebf9bd7998aa0d67 100644
--- a/net/udp/udp_socket_win.cc
+++ b/net/udp/udp_socket_win.cc
@@ -51,8 +51,6 @@ UDPSocketWin::UDPSocketWin(DatagramSocket::BindType bind_type,
ALLOW_THIS_IN_INITIALIZER_LIST(read_delegate_(this)),
ALLOW_THIS_IN_INITIALIZER_LIST(write_delegate_(this)),
recv_from_address_(NULL),
- old_read_callback_(NULL),
- write_callback_(NULL),
net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_UDP_SOCKET)) {
EnsureWinsockInit();
scoped_refptr<NetLog::EventParameters> params;
@@ -79,10 +77,9 @@ void UDPSocketWin::Close() {
return;
// Zero out any pending read/write callback state.
- old_read_callback_ = NULL;
read_callback_.Reset();
recv_from_address_ = NULL;
- write_callback_ = NULL;
+ write_callback_.Reset();
read_watcher_.StopWatching();
write_watcher_.StopWatching();
@@ -137,11 +134,6 @@ int UDPSocketWin::GetLocalAddress(IPEndPoint* address) const {
int UDPSocketWin::Read(IOBuffer* buf,
int buf_len,
- OldCompletionCallback* callback) {
- return RecvFrom(buf, buf_len, NULL, callback);
-}
-int UDPSocketWin::Read(IOBuffer* buf,
- int buf_len,
const CompletionCallback& callback) {
return RecvFrom(buf, buf_len, NULL, callback);
}
@@ -149,30 +141,10 @@ int UDPSocketWin::Read(IOBuffer* buf,
int UDPSocketWin::RecvFrom(IOBuffer* buf,
int buf_len,
IPEndPoint* address,
- OldCompletionCallback* callback) {
- DCHECK(CalledOnValidThread());
- DCHECK_NE(INVALID_SOCKET, socket_);
- DCHECK(!old_read_callback_ && read_callback_.is_null());
- DCHECK(!recv_from_address_);
- DCHECK(callback); // Synchronous operation not supported.
- DCHECK_GT(buf_len, 0);
-
- int nread = InternalRecvFrom(buf, buf_len, address);
- if (nread != ERR_IO_PENDING)
- return nread;
-
- read_iobuffer_ = buf;
- old_read_callback_ = callback;
- recv_from_address_ = address;
- return ERR_IO_PENDING;
-}
-int UDPSocketWin::RecvFrom(IOBuffer* buf,
- int buf_len,
- IPEndPoint* address,
const CompletionCallback& callback) {
DCHECK(CalledOnValidThread());
DCHECK_NE(INVALID_SOCKET, socket_);
- DCHECK(!old_read_callback_ && read_callback_.is_null());
+ DCHECK(read_callback_.is_null());
DCHECK(!recv_from_address_);
DCHECK(!callback.is_null()); // Synchronous operation not supported.
DCHECK_GT(buf_len, 0);
@@ -189,25 +161,25 @@ int UDPSocketWin::RecvFrom(IOBuffer* buf,
int UDPSocketWin::Write(IOBuffer* buf,
int buf_len,
- OldCompletionCallback* callback) {
+ const CompletionCallback& callback) {
return SendToOrWrite(buf, buf_len, NULL, callback);
}
int UDPSocketWin::SendTo(IOBuffer* buf,
int buf_len,
const IPEndPoint& address,
- OldCompletionCallback* callback) {
+ const CompletionCallback& callback) {
return SendToOrWrite(buf, buf_len, &address, callback);
}
int UDPSocketWin::SendToOrWrite(IOBuffer* buf,
int buf_len,
const IPEndPoint* address,
- OldCompletionCallback* callback) {
+ const CompletionCallback& callback) {
DCHECK(CalledOnValidThread());
DCHECK_NE(INVALID_SOCKET, socket_);
- DCHECK(!write_callback_);
- DCHECK(callback); // Synchronous operation not supported.
+ DCHECK(write_callback_.is_null());
+ DCHECK(!callback.is_null()); // Synchronous operation not supported.
DCHECK_GT(buf_len, 0);
DCHECK(!send_to_address_.get());
@@ -298,28 +270,22 @@ bool UDPSocketWin::SetSendBufferSize(int32 size) {
void UDPSocketWin::DoReadCallback(int rv) {
DCHECK_NE(rv, ERR_IO_PENDING);
- DCHECK(old_read_callback_ || !read_callback_.is_null());
+ DCHECK(!read_callback_.is_null());
// since Run may result in Read being called, clear read_callback_ up front.
- if (old_read_callback_) {
- OldCompletionCallback* c = old_read_callback_;
- old_read_callback_ = NULL;
- c->Run(rv);
- } else {
- CompletionCallback c = read_callback_;
- read_callback_.Reset();
- c.Run(rv);
- }
+ CompletionCallback c = read_callback_;
+ read_callback_.Reset();
+ c.Run(rv);
}
void UDPSocketWin::DoWriteCallback(int rv) {
DCHECK_NE(rv, ERR_IO_PENDING);
- DCHECK(write_callback_);
+ DCHECK(!write_callback_.is_null());
// since Run may result in Write being called, clear write_callback_ up front.
- OldCompletionCallback* c = write_callback_;
- write_callback_ = NULL;
- c->Run(rv);
+ CompletionCallback c = write_callback_;
+ write_callback_.Reset();
+ c.Run(rv);
}
void UDPSocketWin::DidCompleteRead() {
« no previous file with comments | « net/udp/udp_socket_win.h ('k') | net/url_request/url_request_ftp_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698