Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/proxy/ppb_tcp_server_socket_private_proxy.h" | 5 #include "ppapi/proxy/ppb_tcp_server_socket_private_proxy.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 namespace ppapi { | 21 namespace ppapi { |
| 22 namespace proxy { | 22 namespace proxy { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 class TCPServerSocket : public PPB_TCPServerSocket_Shared { | 26 class TCPServerSocket : public PPB_TCPServerSocket_Shared { |
| 27 public: | 27 public: |
| 28 TCPServerSocket(const HostResource& resource, uint32 plugin_dispatcher_id); | 28 TCPServerSocket(const HostResource& resource, uint32 plugin_dispatcher_id); |
| 29 virtual ~TCPServerSocket(); | 29 virtual ~TCPServerSocket(); |
| 30 | 30 |
| 31 virtual void OnAcceptCompleted( | 31 void OnAcceptCompleted( |
| 32 bool succeeded, | 32 bool succeeded, |
| 33 uint32 tcp_socket_id, | 33 uint32 tcp_socket_id, |
| 34 const PP_NetAddress_Private& local_addr, | 34 const PP_NetAddress_Private& local_addr, |
| 35 const PP_NetAddress_Private& remote_addr) OVERRIDE; | 35 const PP_NetAddress_Private& remote_addr); |
| 36 | 36 |
| 37 virtual void SendListen(const PP_NetAddress_Private& addr, | 37 virtual void SendListen(const PP_NetAddress_Private& addr, |
| 38 int32_t backlog) OVERRIDE; | 38 int32_t backlog) OVERRIDE; |
| 39 virtual void SendAccept() OVERRIDE; | 39 virtual void SendAccept() OVERRIDE; |
| 40 virtual void SendStopListening() OVERRIDE; | 40 virtual void SendStopListening() OVERRIDE; |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 void SendToBrowser(IPC::Message* msg); | 43 void SendToBrowser(IPC::Message* msg); |
| 44 | 44 |
| 45 uint32 plugin_dispatcher_id_; | 45 uint32 plugin_dispatcher_id_; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 id_to_server_socket_[socket_id] = server_socket; | 169 id_to_server_socket_[socket_id] = server_socket; |
| 170 server_socket->OnListenCompleted(socket_id, local_addr, status); | 170 server_socket->OnListenCompleted(socket_id, local_addr, status); |
| 171 } else if (socket_id != 0 && status == PP_OK) { | 171 } else if (socket_id != 0 && status == PP_OK) { |
| 172 IPC::Message* msg = | 172 IPC::Message* msg = |
| 173 new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id); | 173 new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id); |
| 174 PluginGlobals::Get()->GetBrowserSender()->Send(msg); | 174 PluginGlobals::Get()->GetBrowserSender()->Send(msg); |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 void PPB_TCPServerSocket_Private_Proxy::OnMsgAcceptACK( | 178 void PPB_TCPServerSocket_Private_Proxy::OnMsgAcceptACK( |
| 179 uint32 plugin_dispatcher_id, | 179 int32 socket_routing_id, |
| 180 uint32 server_socket_id, | 180 uint32 server_socket_id, |
| 181 uint32 accepted_socket_id, | 181 uint32 accepted_socket_id, |
| 182 const PP_NetAddress_Private& local_addr, | 182 const PP_NetAddress_Private& local_addr, |
| 183 const PP_NetAddress_Private& remote_addr) { | 183 const PP_NetAddress_Private& remote_addr) { |
| 184 IDToServerSocketMap::iterator it = | 184 IDToServerSocketMap::iterator it = |
| 185 id_to_server_socket_.find(server_socket_id); | 185 id_to_server_socket_.find(server_socket_id); |
| 186 if (it != id_to_server_socket_.end()) { | 186 if (it != id_to_server_socket_.end()) { |
| 187 bool succeeded = (accepted_socket_id != 0); | 187 bool succeeded = (accepted_socket_id != 0); |
| 188 it->second->OnAcceptCompleted(succeeded, | 188 TCPServerSocket* socket = static_cast<TCPServerSocket*>(it->second); |
|
dmichael (off chromium)
2013/08/01 22:43:01
suggestion: You could DCHECK(PpapiGlobals::Get()->
| |
| 189 accepted_socket_id, | 189 socket->OnAcceptCompleted(succeeded, |
| 190 local_addr, | 190 accepted_socket_id, |
| 191 remote_addr); | 191 local_addr, |
| 192 remote_addr); | |
| 192 } else if (accepted_socket_id != 0) { | 193 } else if (accepted_socket_id != 0) { |
| 193 PluginGlobals::Get()->GetBrowserSender()->Send( | 194 PluginGlobals::Get()->GetBrowserSender()->Send( |
| 194 new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); | 195 new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); |
| 195 } | 196 } |
| 196 } | 197 } |
| 197 | 198 |
| 198 } // namespace proxy | 199 } // namespace proxy |
| 199 } // namespace ppapi | 200 } // namespace ppapi |
| OLD | NEW |