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

Unified Diff: net/udp/udp_socket_libevent.cc

Issue 8889036: Revert 113699 - base::Bind: Convert Socket::Write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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_libevent.h ('k') | net/udp/udp_socket_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/udp/udp_socket_libevent.cc
===================================================================
--- net/udp/udp_socket_libevent.cc (revision 113718)
+++ net/udp/udp_socket_libevent.cc (working copy)
@@ -48,7 +48,7 @@
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 @@
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 @@
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 @@
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 @@
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::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() {
« no previous file with comments | « net/udp/udp_socket_libevent.h ('k') | net/udp/udp_socket_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698