 Chromium Code Reviews
 Chromium Code Reviews Issue 23498015:
  [NaCl SDK] Support non blocking TCP/UDP  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 23498015:
  [NaCl SDK] Support non blocking TCP/UDP  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc | 
| diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc | 
| index be524d51e780c8c6e4bacb17d8d0654d7ea088a1..01e9609e84abede9e991af013d8b560533ed248a 100644 | 
| --- a/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc | 
| +++ b/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc | 
| @@ -18,10 +18,11 @@ | 
| namespace nacl_io { | 
| MountNodeSocket::MountNodeSocket(Mount* mount) | 
| - : MountNode(mount), | 
| + : MountNodeStream(mount), | 
| socket_resource_(0), | 
| local_addr_(0), | 
| - remote_addr_(0) { | 
| + remote_addr_(0), | 
| + socket_flags_(0) { | 
| stat_.st_mode |= S_IFSOCK; | 
| } | 
| @@ -32,11 +33,10 @@ void MountNodeSocket::Destroy() { | 
| mount_->ppapi()->ReleaseResource(local_addr_); | 
| if (remote_addr_) | 
| mount_->ppapi()->ReleaseResource(remote_addr_); | 
| -} | 
| -// Default to always signaled, until socket select support is added. | 
| -uint32_t MountNodeSocket::GetEventStatus() { | 
| - return POLLIN | POLLOUT; | 
| + socket_resource_ = 0; | 
| + local_addr_ = 0; | 
| + remote_addr_ = 0; | 
| } | 
| // Assume that |addr| and |out_addr| are non-NULL. | 
| @@ -67,10 +67,27 @@ Error MountNodeSocket::Write(size_t offs, | 
| return Send(buf, count, 0, out_bytes); | 
| } | 
| -NetAddressInterface* MountNodeSocket::NetAddress() { | 
| +NetAddressInterface* MountNodeSocket::NetInterface() { | 
| + if (mount_->ppapi() == NULL) | 
| + return NULL; | 
| + | 
| return mount_->ppapi()->GetNetAddressInterface(); | 
| } | 
| +TCPSocketInterface* MountNodeSocket::TCPInterface() { | 
| + if (mount_->ppapi() == NULL) | 
| + return NULL; | 
| + | 
| + return mount_->ppapi()->GetTCPSocketInterface(); | 
| +} | 
| + | 
| +UDPSocketInterface* MountNodeSocket::UDPInterface() { | 
| + if (mount_->ppapi() == NULL) | 
| + return NULL; | 
| + | 
| + return mount_->ppapi()->GetUDPSocketInterface(); | 
| +} | 
| + | 
| PP_Resource MountNodeSocket::SockAddrToResource(const struct sockaddr* addr, | 
| socklen_t len) { | 
| if (AF_INET == addr->sa_family) { | 
| @@ -115,7 +132,7 @@ socklen_t MountNodeSocket::ResourceToSockAddr(PP_Resource addr, | 
| PP_NetAddress_IPv4 ipv4; | 
| PP_NetAddress_IPv6 ipv6; | 
| - if (PP_TRUE == NetAddress()->DescribeAsIPv4Address(addr, &ipv4)) { | 
| + if (PP_TRUE == NetInterface()->DescribeAsIPv4Address(addr, &ipv4)) { | 
| sockaddr_in addr4; | 
| addr4.sin_family = AF_INET; | 
| addr4.sin_port = ipv4.port; | 
| @@ -126,7 +143,7 @@ socklen_t MountNodeSocket::ResourceToSockAddr(PP_Resource addr, | 
| return sizeof(sockaddr_in); | 
| } | 
| - if (PP_TRUE == NetAddress()->DescribeAsIPv6Address(addr, &ipv6)) { | 
| + if (PP_TRUE == NetInterface()->DescribeAsIPv6Address(addr, &ipv6)) { | 
| sockaddr_in6 addr6; | 
| addr6.sin6_family = AF_INET6; | 
| addr6.sin6_port = ipv6.port; | 
| @@ -258,6 +275,8 @@ Error MountNodeSocket::GetSockName(struct sockaddr* addr, socklen_t* len) { | 
| } | 
| 
binji
2013/09/15 22:18:58
nit: remove extra lines
 
noelallen1
2013/09/17 21:21:54
Done.
 | 
| + | 
| + | 
| } // namespace nacl_io | 
| #endif // PROVIDES_SOCKET_API |