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

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

Issue 2815993002: Adds a method to TCPServerSocket to adopt a socket. (Closed)
Patch Set: Refined GetSocketDescriptor per review. Created 3 years, 7 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
« no previous file with comments | « net/socket/tcp_server_socket.h ('k') | net/socket/tcp_socket_posix.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/socket_descriptor.h"
13 #include "net/socket/tcp_client_socket.h" 14 #include "net/socket/tcp_client_socket.h"
14 15
15 namespace net { 16 namespace net {
16 17
17 TCPServerSocket::TCPServerSocket(NetLog* net_log, const NetLogSource& source) 18 TCPServerSocket::TCPServerSocket(NetLog* net_log, const NetLogSource& source)
18 : socket_(nullptr, net_log, source), pending_accept_(false) {} 19 : socket_(nullptr, net_log, source), pending_accept_(false) {}
19 20
21 int TCPServerSocket::AdoptSocket(SocketDescriptor socket) {
22 return socket_.AdoptUnconnectedSocket(socket);
23 }
24
20 TCPServerSocket::~TCPServerSocket() { 25 TCPServerSocket::~TCPServerSocket() {
21 } 26 }
22 27
23 int TCPServerSocket::Listen(const IPEndPoint& address, int backlog) { 28 int TCPServerSocket::Listen(const IPEndPoint& address, int backlog) {
24 int result = socket_.Open(address.GetFamily()); 29 int result = socket_.Open(address.GetFamily());
25 if (result != OK) 30 if (result != OK)
26 return result; 31 return result;
27 32
28 result = socket_.SetDefaultOptionsForServer(); 33 result = socket_.SetDefaultOptionsForServer();
29 if (result != OK) { 34 if (result != OK) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 void TCPServerSocket::OnAcceptCompleted( 105 void TCPServerSocket::OnAcceptCompleted(
101 std::unique_ptr<StreamSocket>* output_accepted_socket, 106 std::unique_ptr<StreamSocket>* output_accepted_socket,
102 const CompletionCallback& forward_callback, 107 const CompletionCallback& forward_callback,
103 int result) { 108 int result) {
104 result = ConvertAcceptedSocket(result, output_accepted_socket); 109 result = ConvertAcceptedSocket(result, output_accepted_socket);
105 pending_accept_ = false; 110 pending_accept_ = false;
106 forward_callback.Run(result); 111 forward_callback.Run(result);
107 } 112 }
108 113
109 } // namespace net 114 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_server_socket.h ('k') | net/socket/tcp_socket_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698