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_SOCKET_LIBEVENT_H_ | 5 #ifndef NET_SOCKET_SOCKET_LIBEVENT_H_ |
6 #define NET_SOCKET_SOCKET_LIBEVENT_H_ | 6 #define NET_SOCKET_SOCKET_LIBEVENT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 public: | 27 public: |
28 SocketLibevent(); | 28 SocketLibevent(); |
29 virtual ~SocketLibevent(); | 29 virtual ~SocketLibevent(); |
30 | 30 |
31 // Opens a socket and returns net::OK if |address_family| is AF_INET, AF_INET6 | 31 // Opens a socket and returns net::OK if |address_family| is AF_INET, AF_INET6 |
32 // or AF_UNIX. Otherwise, it does DCHECK() and returns a net error. | 32 // or AF_UNIX. Otherwise, it does DCHECK() and returns a net error. |
33 int Open(int address_family); | 33 int Open(int address_family); |
34 // Takes ownership of |socket|. | 34 // Takes ownership of |socket|. |
35 int AdoptConnectedSocket(SocketDescriptor socket, | 35 int AdoptConnectedSocket(SocketDescriptor socket, |
36 const SockaddrStorage& peer_address); | 36 const SockaddrStorage& peer_address); |
| 37 // Releases ownership of |socket_fd_| to caller. |
| 38 SocketDescriptor ReleaseConnectedSocket(); |
37 | 39 |
38 int Bind(const SockaddrStorage& address); | 40 int Bind(const SockaddrStorage& address); |
39 | 41 |
40 int Listen(int backlog); | 42 int Listen(int backlog); |
41 int Accept(scoped_ptr<SocketLibevent>* socket, | 43 int Accept(scoped_ptr<SocketLibevent>* socket, |
42 const CompletionCallback& callback); | 44 const CompletionCallback& callback); |
43 | 45 |
44 // Connects socket. On non-ERR_IO_PENDING error, sets errno and returns a net | 46 // Connects socket. On non-ERR_IO_PENDING error, sets errno and returns a net |
45 // error code. On ERR_IO_PENDING, |callback| is called with a net error code, | 47 // error code. On ERR_IO_PENDING, |callback| is called with a net error code, |
46 // not errno, though errno is set if connect event happens with error. | 48 // not errno, though errno is set if connect event happens with error. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 scoped_ptr<SockaddrStorage> peer_address_; | 120 scoped_ptr<SockaddrStorage> peer_address_; |
119 | 121 |
120 base::ThreadChecker thread_checker_; | 122 base::ThreadChecker thread_checker_; |
121 | 123 |
122 DISALLOW_COPY_AND_ASSIGN(SocketLibevent); | 124 DISALLOW_COPY_AND_ASSIGN(SocketLibevent); |
123 }; | 125 }; |
124 | 126 |
125 } // namespace net | 127 } // namespace net |
126 | 128 |
127 #endif // NET_SOCKET_SOCKET_LIBEVENT_H_ | 129 #endif // NET_SOCKET_SOCKET_LIBEVENT_H_ |
OLD | NEW |