| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/socket/socket_posix.h" | 5 #include "net/socket/socket_posix.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <netinet/in.h> | 8 #include <netinet/in.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/posix/eintr_wrapper.h" | 15 #include "base/posix/eintr_wrapper.h" |
| 15 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 16 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
| 17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 18 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
| 19 | 20 |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 new_peer_address.addr, | 371 new_peer_address.addr, |
| 371 &new_peer_address.addr_len)); | 372 &new_peer_address.addr_len)); |
| 372 if (new_socket < 0) | 373 if (new_socket < 0) |
| 373 return MapAcceptError(errno); | 374 return MapAcceptError(errno); |
| 374 | 375 |
| 375 scoped_ptr<SocketPosix> accepted_socket(new SocketPosix); | 376 scoped_ptr<SocketPosix> accepted_socket(new SocketPosix); |
| 376 int rv = accepted_socket->AdoptConnectedSocket(new_socket, new_peer_address); | 377 int rv = accepted_socket->AdoptConnectedSocket(new_socket, new_peer_address); |
| 377 if (rv != OK) | 378 if (rv != OK) |
| 378 return rv; | 379 return rv; |
| 379 | 380 |
| 380 *socket = accepted_socket.Pass(); | 381 *socket = std::move(accepted_socket); |
| 381 return OK; | 382 return OK; |
| 382 } | 383 } |
| 383 | 384 |
| 384 void SocketPosix::AcceptCompleted() { | 385 void SocketPosix::AcceptCompleted() { |
| 385 DCHECK(accept_socket_); | 386 DCHECK(accept_socket_); |
| 386 int rv = DoAccept(accept_socket_); | 387 int rv = DoAccept(accept_socket_); |
| 387 if (rv == ERR_IO_PENDING) | 388 if (rv == ERR_IO_PENDING) |
| 388 return; | 389 return; |
| 389 | 390 |
| 390 bool ok = accept_socket_watcher_.StopWatchingFileDescriptor(); | 391 bool ok = accept_socket_watcher_.StopWatchingFileDescriptor(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 write_buf_ = NULL; | 478 write_buf_ = NULL; |
| 478 write_buf_len_ = 0; | 479 write_buf_len_ = 0; |
| 479 write_callback_.Reset(); | 480 write_callback_.Reset(); |
| 480 } | 481 } |
| 481 | 482 |
| 482 waiting_connect_ = false; | 483 waiting_connect_ = false; |
| 483 peer_address_.reset(); | 484 peer_address_.reset(); |
| 484 } | 485 } |
| 485 | 486 |
| 486 } // namespace net | 487 } // namespace net |
| OLD | NEW |