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

Side by Side Diff: net/socket/tcp_server_socket.cc

Issue 2815993002: Adds a method to TCPServerSocket to adopt a socket. (Closed)
Patch Set: Fixed (I hope) Windows compile failure. Created 3 years, 8 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/tcp_server_socket.h" 5 #include "net/socket/tcp_server_socket.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/socket/tcp_client_socket.h" 13 #include "net/socket/tcp_client_socket.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 TCPServerSocket::TCPServerSocket(NetLog* net_log, const NetLogSource& source) 17 TCPServerSocket::TCPServerSocket(NetLog* net_log, const NetLogSource& source)
18 : socket_(nullptr, net_log, source), pending_accept_(false) {} 18 : socket_(nullptr, net_log, source), pending_accept_(false) {}
19 19
20 #if defined(OS_POSIX)
21 int TCPServerSocket::AdopListeningRawSocket(int socket_fd) {
22 // A TCPSocketPosix can adopt any socket, whether connected or not, so the
23 // following method is a slight misnomer.
24 return socket_.AdoptConnectedSocket(socket_fd, IPEndPoint());
mmenke 2017/04/17 17:42:18 Using IPEndPoint() seems to violate the API promis
Raul Vera 2017/04/17 23:51:57 The AdoptConnectedSocket method on TCPSocketPosix
mmenke 2017/04/18 16:15:24 I'm not seeing a consumer in the chrome repo that
25 }
26 #endif
27
20 TCPServerSocket::~TCPServerSocket() { 28 TCPServerSocket::~TCPServerSocket() {
21 } 29 }
22 30
23 int TCPServerSocket::Listen(const IPEndPoint& address, int backlog) { 31 int TCPServerSocket::Listen(const IPEndPoint& address, int backlog) {
24 int result = socket_.Open(address.GetFamily()); 32 int result = socket_.Open(address.GetFamily());
25 if (result != OK) 33 if (result != OK)
26 return result; 34 return result;
27 35
28 result = socket_.SetDefaultOptionsForServer(); 36 result = socket_.SetDefaultOptionsForServer();
29 if (result != OK) { 37 if (result != OK) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 void TCPServerSocket::OnAcceptCompleted( 108 void TCPServerSocket::OnAcceptCompleted(
101 std::unique_ptr<StreamSocket>* output_accepted_socket, 109 std::unique_ptr<StreamSocket>* output_accepted_socket,
102 const CompletionCallback& forward_callback, 110 const CompletionCallback& forward_callback,
103 int result) { 111 int result) {
104 result = ConvertAcceptedSocket(result, output_accepted_socket); 112 result = ConvertAcceptedSocket(result, output_accepted_socket);
105 pending_accept_ = false; 113 pending_accept_ = false;
106 forward_callback.Run(result); 114 forward_callback.Run(result);
107 } 115 }
108 116
109 } // namespace net 117 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698