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 #ifndef NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_ | 5 #ifndef NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_ |
6 #define NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_ | 6 #define NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_ |
7 | 7 |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 // ServerSocket implementation. | 53 // ServerSocket implementation. |
54 virtual int Listen(const IPEndPoint& address, int backlog) OVERRIDE; | 54 virtual int Listen(const IPEndPoint& address, int backlog) OVERRIDE; |
55 virtual int ListenWithAddressAndPort(const std::string& unix_domain_path, | 55 virtual int ListenWithAddressAndPort(const std::string& unix_domain_path, |
56 int port_unused, | 56 int port_unused, |
57 int backlog) OVERRIDE; | 57 int backlog) OVERRIDE; |
58 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; | 58 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; |
59 virtual int Accept(scoped_ptr<StreamSocket>* socket, | 59 virtual int Accept(scoped_ptr<StreamSocket>* socket, |
60 const CompletionCallback& callback) OVERRIDE; | 60 const CompletionCallback& callback) OVERRIDE; |
61 | 61 |
| 62 // Accepts an incoming connection on |listen_socket_|, but passes back |
| 63 // a raw SocketDescriptor instead of a StreamSocket. |
| 64 int AcceptSocketDescriptor(SocketDescriptor* socket_descriptor, |
| 65 const CompletionCallback& callback); |
| 66 |
62 private: | 67 private: |
63 void AcceptCompleted(scoped_ptr<StreamSocket>* socket, | 68 // A callback to wrap the setting of the out-parameter to Accept(). |
| 69 // This allows the internal machinery of that call to be implemented in |
| 70 // a manner that's agnostic to the caller's desired output. |
| 71 typedef base::Callback<void(scoped_ptr<SocketLibevent>)> SetterCallback; |
| 72 |
| 73 int DoAccept(const SetterCallback& setter_callback, |
| 74 const CompletionCallback& callback); |
| 75 void AcceptCompleted(const SetterCallback& setter_callback, |
64 const CompletionCallback& callback, | 76 const CompletionCallback& callback, |
65 int rv); | 77 int rv); |
66 bool AuthenticateAndGetStreamSocket(scoped_ptr<StreamSocket>* socket); | 78 bool AuthenticateAndGetStreamSocket(const SetterCallback& setter_callback); |
67 | 79 |
68 scoped_ptr<SocketLibevent> listen_socket_; | 80 scoped_ptr<SocketLibevent> listen_socket_; |
69 const AuthCallback auth_callback_; | 81 const AuthCallback auth_callback_; |
70 const bool use_abstract_namespace_; | 82 const bool use_abstract_namespace_; |
71 | 83 |
72 scoped_ptr<SocketLibevent> accept_socket_; | 84 scoped_ptr<SocketLibevent> accept_socket_; |
73 | 85 |
74 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocket); | 86 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocket); |
75 }; | 87 }; |
76 | 88 |
77 } // namespace net | 89 } // namespace net |
78 | 90 |
79 #endif // NET_SOCKET_UNIX_DOMAIN_SOCKET_POSIX_H_ | 91 #endif // NET_SOCKET_UNIX_DOMAIN_SOCKET_POSIX_H_ |
OLD | NEW |