OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PACKAGES_LIBRARIES_NACL_MOUNTS_NET_TCP_SERVER_SOCKET_H_ |
| 6 #define PACKAGES_LIBRARIES_NACL_MOUNTS_NET_TCP_SERVER_SOCKET_H_ |
| 7 |
| 8 #include <string> |
| 9 #include "ppapi/cpp/completion_callback.h" |
| 10 #include "../ppapi/cpp/private/tcp_server_socket_private.h" |
| 11 #include "../net/SocketSubSystem.h" |
| 12 #include "../util/PthreadHelpers.h" |
| 13 |
| 14 class TCPServerSocket : public Socket { |
| 15 public: |
| 16 TCPServerSocket(SocketSubSystem* sys, |
| 17 int oflag, const sockaddr* saddr, socklen_t addrlen); |
| 18 virtual ~TCPServerSocket(); |
| 19 |
| 20 bool is_open() { return socket_ != NULL; } |
| 21 |
| 22 virtual void addref(); |
| 23 virtual void release(); |
| 24 |
| 25 virtual int read(char* buf, size_t count, size_t* nread); |
| 26 virtual int write(const char* buf, size_t count, size_t* nwrote); |
| 27 virtual void close(); |
| 28 |
| 29 virtual int fcntl(int cmd, va_list ap); |
| 30 |
| 31 virtual bool is_read_ready(); |
| 32 virtual bool is_write_ready(); |
| 33 virtual bool is_exception(); |
| 34 |
| 35 bool listen(int backlog); |
| 36 PP_Resource accept(); |
| 37 |
| 38 private: |
| 39 void Listen(int32_t result, int backlog, int32_t* pres); |
| 40 void Accept(int32_t result, int32_t* pres); |
| 41 void OnAccept(int32_t result); |
| 42 void Close(int32_t result, int32_t* pres); |
| 43 bool CreateNetAddress(const sockaddr* saddr, PP_NetAddress_Private* addr); |
| 44 |
| 45 SocketSubSystem* sys_; |
| 46 int ref_; |
| 47 int oflag_; |
| 48 pp::CompletionCallbackFactory<TCPServerSocket, ThreadSafeRefCount> factory_; |
| 49 pp::TCPServerSocketPrivate* socket_; |
| 50 sockaddr_in6 sin6_; |
| 51 PP_Resource resource_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(TCPServerSocket); |
| 54 }; |
| 55 |
| 56 #endif // PACKAGES_LIBRARIES_NACL_MOUNTS_NET_TCP_SERVER_SOCKET_H_ |
| 57 |
OLD | NEW |