diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-09 01:06:19 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-09 01:06:19 +0000 |
commit | f749f9cee070a7a15107fa9cce6b89ad1d969bcf (patch) | |
tree | 0ecb3a7dd6daff154a8e2bf441ee097704651815 /net/udp | |
parent | 4df3c1c675ded79c6c5d2f210a3131808ac93abd (diff) | |
download | chromium_src-f749f9cee070a7a15107fa9cce6b89ad1d969bcf.zip chromium_src-f749f9cee070a7a15107fa9cce6b89ad1d969bcf.tar.gz chromium_src-f749f9cee070a7a15107fa9cce6b89ad1d969bcf.tar.bz2 |
Revert 113699 - base::Bind: Convert Socket::Write.
BUG=none
TEST=none
R=csilv
Review URL: http://codereview.chromium.org/8831001
TBR=jhawkins@chromium.org
Review URL: http://codereview.chromium.org/8889036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113719 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/udp')
-rw-r--r-- | net/udp/udp_client_socket.cc | 5 | ||||
-rw-r--r-- | net/udp/udp_client_socket.h | 2 | ||||
-rw-r--r-- | net/udp/udp_socket_libevent.cc | 58 | ||||
-rw-r--r-- | net/udp/udp_socket_libevent.h | 10 | ||||
-rw-r--r-- | net/udp/udp_socket_win.cc | 47 | ||||
-rw-r--r-- | net/udp/udp_socket_win.h | 8 |
6 files changed, 17 insertions, 113 deletions
diff --git a/net/udp/udp_client_socket.cc b/net/udp/udp_client_socket.cc index 08b2cbe..4bb3885 100644 --- a/net/udp/udp_client_socket.cc +++ b/net/udp/udp_client_socket.cc @@ -38,11 +38,6 @@ int UDPClientSocket::Write(IOBuffer* buf, OldCompletionCallback* callback) { return socket_.Write(buf, buf_len, callback); } -int UDPClientSocket::Write(IOBuffer* buf, - int buf_len, - const CompletionCallback& callback) { - return socket_.Write(buf, buf_len, callback); -} void UDPClientSocket::Close() { socket_.Close(); diff --git a/net/udp/udp_client_socket.h b/net/udp/udp_client_socket.h index 2fee21a..b25df63 100644 --- a/net/udp/udp_client_socket.h +++ b/net/udp/udp_client_socket.h @@ -32,8 +32,6 @@ class NET_EXPORT_PRIVATE UDPClientSocket : public DatagramClientSocket { const CompletionCallback& callback) OVERRIDE; virtual int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback) OVERRIDE; - virtual int Write(IOBuffer* buf, int buf_len, - const CompletionCallback& callback) OVERRIDE; virtual void Close() OVERRIDE; virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE; virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; diff --git a/net/udp/udp_socket_libevent.cc b/net/udp/udp_socket_libevent.cc index 9777626..a669c37 100644 --- a/net/udp/udp_socket_libevent.cc +++ b/net/udp/udp_socket_libevent.cc @@ -48,7 +48,7 @@ UDPSocketLibevent::UDPSocketLibevent( recv_from_address_(NULL), write_buf_len_(0), old_read_callback_(NULL), - old_write_callback_(NULL), + write_callback_(NULL), net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_UDP_SOCKET)) { scoped_refptr<NetLog::EventParameters> params; if (source.is_valid()) @@ -77,8 +77,7 @@ void UDPSocketLibevent::Close() { recv_from_address_ = NULL; write_buf_ = NULL; write_buf_len_ = 0; - old_write_callback_ = NULL; - write_callback_.Reset(); + write_callback_ = NULL; send_to_address_.reset(); bool ok = read_socket_watcher_.StopWatchingFileDescriptor(); @@ -213,11 +212,6 @@ int UDPSocketLibevent::Write(IOBuffer* buf, OldCompletionCallback* callback) { return SendToOrWrite(buf, buf_len, NULL, callback); } -int UDPSocketLibevent::Write(IOBuffer* buf, - int buf_len, - const CompletionCallback& callback) { - return SendToOrWrite(buf, buf_len, NULL, callback); -} int UDPSocketLibevent::SendTo(IOBuffer* buf, int buf_len, @@ -232,7 +226,7 @@ int UDPSocketLibevent::SendToOrWrite(IOBuffer* buf, OldCompletionCallback* callback) { DCHECK(CalledOnValidThread()); DCHECK_NE(kInvalidSocket, socket_); - DCHECK(!old_write_callback_ && write_callback_.is_null()); + DCHECK(!write_callback_); DCHECK(callback); // Synchronous operation not supported DCHECK_GT(buf_len, 0); @@ -255,38 +249,6 @@ int UDPSocketLibevent::SendToOrWrite(IOBuffer* buf, if (address) { send_to_address_.reset(new IPEndPoint(*address)); } - old_write_callback_ = callback; - return ERR_IO_PENDING; -} -int UDPSocketLibevent::SendToOrWrite(IOBuffer* buf, - int buf_len, - const IPEndPoint* address, - const CompletionCallback& callback) { - DCHECK(CalledOnValidThread()); - DCHECK_NE(kInvalidSocket, socket_); - DCHECK(!old_write_callback_ && write_callback_.is_null()); - DCHECK(!callback.is_null()); // Synchronous operation not supported - DCHECK_GT(buf_len, 0); - - int result = InternalSendTo(buf, buf_len, address); - if (result != ERR_IO_PENDING) - return result; - - if (!MessageLoopForIO::current()->WatchFileDescriptor( - socket_, true, MessageLoopForIO::WATCH_WRITE, - &write_socket_watcher_, &write_watcher_)) { - DVLOG(1) << "WatchFileDescriptor failed on write, errno " << errno; - int result = MapSystemError(errno); - LogWrite(result, NULL, NULL); - return result; - } - - write_buf_ = buf; - write_buf_len_ = buf_len; - DCHECK(!send_to_address_.get()); - if (address) { - send_to_address_.reset(new IPEndPoint(*address)); - } write_callback_ = callback; return ERR_IO_PENDING; } @@ -377,18 +339,12 @@ void UDPSocketLibevent::DoReadCallback(int rv) { void UDPSocketLibevent::DoWriteCallback(int rv) { DCHECK_NE(rv, ERR_IO_PENDING); - DCHECK(old_write_callback_ || !write_callback_.is_null()); + DCHECK(write_callback_); // since Run may result in Write being called, clear write_callback_ up front. - if (old_write_callback_) { - OldCompletionCallback* c = old_write_callback_; - old_write_callback_ = NULL; - c->Run(rv); - } else { - CompletionCallback c = write_callback_; - write_callback_.Reset(); - c.Run(rv); - } + OldCompletionCallback* c = write_callback_; + write_callback_ = NULL; + c->Run(rv); } void UDPSocketLibevent::DidCompleteRead() { diff --git a/net/udp/udp_socket_libevent.h b/net/udp/udp_socket_libevent.h index 45ec1bb..6cef1c0 100644 --- a/net/udp/udp_socket_libevent.h +++ b/net/udp/udp_socket_libevent.h @@ -61,7 +61,6 @@ class UDPSocketLibevent : public base::NonThreadSafe { // Only usable from the client-side of a UDP socket, after the socket // has been connected. int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); - int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); // Read from a socket and receive sender address information. // |buf| is the buffer to read data into. @@ -141,7 +140,7 @@ class UDPSocketLibevent : public base::NonThreadSafe { virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE {} virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE { - if (socket_->old_write_callback_) + if (socket_->write_callback_) socket_->DidCompleteWrite(); } @@ -174,10 +173,6 @@ class UDPSocketLibevent : public base::NonThreadSafe { int buf_len, const IPEndPoint* address, OldCompletionCallback* callback); - int SendToOrWrite(IOBuffer* buf, - int buf_len, - const IPEndPoint* address, - const CompletionCallback& callback); int InternalConnect(const IPEndPoint& address); int InternalRecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address); @@ -223,8 +218,7 @@ class UDPSocketLibevent : public base::NonThreadSafe { CompletionCallback read_callback_; // External callback; called when write is complete. - OldCompletionCallback* old_write_callback_; - CompletionCallback write_callback_; + OldCompletionCallback* write_callback_; BoundNetLog net_log_; diff --git a/net/udp/udp_socket_win.cc b/net/udp/udp_socket_win.cc index 6499444..88aa23b 100644 --- a/net/udp/udp_socket_win.cc +++ b/net/udp/udp_socket_win.cc @@ -52,7 +52,7 @@ UDPSocketWin::UDPSocketWin(DatagramSocket::BindType bind_type, ALLOW_THIS_IN_INITIALIZER_LIST(write_delegate_(this)), recv_from_address_(NULL), old_read_callback_(NULL), - old_write_callback_(NULL), + write_callback_(NULL), net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_UDP_SOCKET)) { EnsureWinsockInit(); scoped_refptr<NetLog::EventParameters> params; @@ -82,8 +82,7 @@ void UDPSocketWin::Close() { old_read_callback_ = NULL; read_callback_.Reset(); recv_from_address_ = NULL; - old_write_callback_ = NULL; - write_callback_.Reset(); + write_callback_ = NULL; read_watcher_.StopWatching(); write_watcher_.StopWatching(); @@ -193,11 +192,6 @@ int UDPSocketWin::Write(IOBuffer* buf, OldCompletionCallback* callback) { return SendToOrWrite(buf, buf_len, NULL, callback); } -int UDPSocketWin::Write(IOBuffer* buf, - int buf_len, - const CompletionCallback& callback) { - return SendToOrWrite(buf, buf_len, NULL, callback); -} int UDPSocketWin::SendTo(IOBuffer* buf, int buf_len, @@ -212,7 +206,7 @@ int UDPSocketWin::SendToOrWrite(IOBuffer* buf, OldCompletionCallback* callback) { DCHECK(CalledOnValidThread()); DCHECK_NE(INVALID_SOCKET, socket_); - DCHECK(!old_write_callback_ && write_callback_.is_null()); + DCHECK(!write_callback_); DCHECK(callback); // Synchronous operation not supported. DCHECK_GT(buf_len, 0); DCHECK(!send_to_address_.get()); @@ -224,27 +218,6 @@ int UDPSocketWin::SendToOrWrite(IOBuffer* buf, if (address) send_to_address_.reset(new IPEndPoint(*address)); write_iobuffer_ = buf; - old_write_callback_ = callback; - return ERR_IO_PENDING; -} -int UDPSocketWin::SendToOrWrite(IOBuffer* buf, - int buf_len, - const IPEndPoint* address, - const CompletionCallback& callback) { - DCHECK(CalledOnValidThread()); - DCHECK_NE(INVALID_SOCKET, socket_); - DCHECK(!old_write_callback_ && write_callback_.is_null()); - DCHECK(!callback.is_null()); // Synchronous operation not supported. - DCHECK_GT(buf_len, 0); - DCHECK(!send_to_address_.get()); - - int nwrite = InternalSendTo(buf, buf_len, address); - if (nwrite != ERR_IO_PENDING) - return nwrite; - - if (address) - send_to_address_.reset(new IPEndPoint(*address)); - write_iobuffer_ = buf; write_callback_ = callback; return ERR_IO_PENDING; } @@ -341,18 +314,12 @@ void UDPSocketWin::DoReadCallback(int rv) { void UDPSocketWin::DoWriteCallback(int rv) { DCHECK_NE(rv, ERR_IO_PENDING); - DCHECK(old_write_callback_ && !write_callback_.is_null()); + DCHECK(write_callback_); // since Run may result in Write being called, clear write_callback_ up front. - if (old_write_callback_) { - OldCompletionCallback* c = old_write_callback_; - old_write_callback_ = NULL; - c->Run(rv); - } else { - CompletionCallback c = write_callback_; - write_callback_.Reset(); - c.Run(rv); - } + OldCompletionCallback* c = write_callback_; + write_callback_ = NULL; + c->Run(rv); } void UDPSocketWin::DidCompleteRead() { diff --git a/net/udp/udp_socket_win.h b/net/udp/udp_socket_win.h index 4436860..6aace29 100644 --- a/net/udp/udp_socket_win.h +++ b/net/udp/udp_socket_win.h @@ -62,7 +62,6 @@ class UDPSocketWin : public base::NonThreadSafe { // Only usable from the client-side of a UDP socket, after the socket // has been connected. int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); - int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); // Read from a socket and receive sender address information. // |buf| is the buffer to read data into. @@ -157,10 +156,6 @@ class UDPSocketWin : public base::NonThreadSafe { int buf_len, const IPEndPoint* address, OldCompletionCallback* callback); - int SendToOrWrite(IOBuffer* buf, - int buf_len, - const IPEndPoint* address, - const CompletionCallback& callback); int InternalConnect(const IPEndPoint& address); int InternalRecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address); @@ -217,8 +212,7 @@ class UDPSocketWin : public base::NonThreadSafe { CompletionCallback read_callback_; // External callback; called when write is complete. - OldCompletionCallback* old_write_callback_; - CompletionCallback write_callback_; + OldCompletionCallback* write_callback_; BoundNetLog net_log_; |