Chromium Code Reviews| Index: net/socket/tcp_socket_posix.cc |
| diff --git a/net/socket/tcp_socket_posix.cc b/net/socket/tcp_socket_posix.cc |
| index c02e0fc6081818a18a598899dad98410b2b47b66..c400f8a448fbdbef904123e8cd8e8264bdbb5375 100644 |
| --- a/net/socket/tcp_socket_posix.cc |
| +++ b/net/socket/tcp_socket_posix.cc |
| @@ -290,6 +290,20 @@ int TCPSocketPosix::Read(IOBuffer* buf, |
| return rv; |
| } |
| +int TCPSocketPosix::ReadIfReady(IOBuffer* buf, |
| + int buf_len, |
| + const CompletionCallback& callback) { |
| + DCHECK(socket_); |
| + DCHECK(!callback.is_null()); |
| + |
| + int rv = socket_->ReadIfReady( |
| + buf, buf_len, base::Bind(&TCPSocketPosix::ReadIfReadyCompleted, |
| + base::Unretained(this), callback)); |
| + if (rv != ERR_IO_PENDING) |
| + rv = HandleReadCompleted(buf, rv); |
| + return rv; |
| +} |
| + |
| int TCPSocketPosix::Write(IOBuffer* buf, |
| int buf_len, |
| const CompletionCallback& callback) { |
| @@ -591,6 +605,18 @@ void TCPSocketPosix::ReadCompleted(const scoped_refptr<IOBuffer>& buf, |
| callback.Run(HandleReadCompleted(buf.get(), rv)); |
| } |
| +void TCPSocketPosix::ReadIfReadyCompleted(const CompletionCallback& callback, |
| + int rv) { |
| + DCHECK_NE(ERR_IO_PENDING, rv); |
| + DCHECK_GE(OK, rv); |
| + |
| + if (rv < 0) { |
| + net_log_.AddEvent(NetLogEventType::SOCKET_READ_ERROR, |
| + CreateNetLogSocketErrorCallback(rv, errno)); |
| + } |
| + callback.Run(rv); |
| +} |
| + |
| int TCPSocketPosix::HandleReadCompleted(IOBuffer* buf, int rv) { |
| if (tcp_fastopen_write_attempted_ && !tcp_fastopen_connected_) { |
|
davidben
2017/02/01 22:25:58
Should this code also run in the ReadIfReadyComple
xunjieli
2017/02/03 16:35:33
Done.
|
| // A TCP FastOpen connect-with-write was attempted. This read was a |