| 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" |
| 11 #include "ppapi/proxy/plugin_dispatcher.h" | 11 #include "ppapi/proxy/plugin_dispatcher.h" |
| 12 #include "ppapi/proxy/plugin_globals.h" | 12 #include "ppapi/proxy/plugin_globals.h" |
| 13 #include "ppapi/proxy/plugin_proxy_delegate.h" | 13 #include "ppapi/proxy/plugin_proxy_delegate.h" |
| 14 #include "ppapi/proxy/plugin_resource_tracker.h" | 14 #include "ppapi/proxy/plugin_resource_tracker.h" |
| 15 #include "ppapi/proxy/ppapi_messages.h" | 15 #include "ppapi/proxy/ppapi_messages.h" |
| 16 #include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" | 16 #include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" |
| 17 #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" | 17 #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" |
| 18 #include "ppapi/shared_impl/resource.h" | 18 #include "ppapi/shared_impl/resource.h" |
| 19 #include "ppapi/thunk/enter.h" | 19 #include "ppapi/thunk/enter.h" |
| 20 #include "ppapi/thunk/thunk.h" | 20 #include "ppapi/thunk/thunk.h" |
| 21 | 21 |
| 22 namespace ppapi { | 22 namespace ppapi { |
| 23 namespace proxy { | 23 namespace proxy { |
| 24 | 24 |
| 25 typedef thunk::EnterResource<thunk::PPB_TCPServerSocket_Private_API> | |
| 26 EnterTCPServerSocket; | |
| 27 | |
| 28 namespace { | 25 namespace { |
| 29 | 26 |
| 30 class TCPServerSocket : public PPB_TCPServerSocket_Shared { | 27 class TCPServerSocket : public PPB_TCPServerSocket_Shared { |
| 31 public: | 28 public: |
| 32 TCPServerSocket(const HostResource& resource, uint32 plugin_dispatcher_id); | 29 TCPServerSocket(const HostResource& resource, uint32 plugin_dispatcher_id); |
| 33 virtual ~TCPServerSocket(); | 30 virtual ~TCPServerSocket(); |
| 34 | 31 |
| 35 virtual void OnAcceptCompleted( | 32 virtual void OnAcceptCompleted( |
| 36 bool succeeded, | 33 bool succeeded, |
| 37 uint32 tcp_socket_id, | 34 uint32 tcp_socket_id, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 IPC_MESSAGE_UNHANDLED(handled = false) | 154 IPC_MESSAGE_UNHANDLED(handled = false) |
| 158 IPC_END_MESSAGE_MAP() | 155 IPC_END_MESSAGE_MAP() |
| 159 return handled; | 156 return handled; |
| 160 } | 157 } |
| 161 | 158 |
| 162 void PPB_TCPServerSocket_Private_Proxy::OnMsgListenACK( | 159 void PPB_TCPServerSocket_Private_Proxy::OnMsgListenACK( |
| 163 uint32 plugin_dispatcher_id, | 160 uint32 plugin_dispatcher_id, |
| 164 PP_Resource socket_resource, | 161 PP_Resource socket_resource, |
| 165 uint32 socket_id, | 162 uint32 socket_id, |
| 166 int32_t status) { | 163 int32_t status) { |
| 167 EnterTCPServerSocket enter(socket_resource, true); | 164 thunk::EnterResourceNoLock<thunk::PPB_TCPServerSocket_Private_API> |
| 165 enter(socket_resource, true); |
| 168 if (enter.succeeded()) { | 166 if (enter.succeeded()) { |
| 169 PPB_TCPServerSocket_Shared* server_socket = | 167 PPB_TCPServerSocket_Shared* server_socket = |
| 170 static_cast<PPB_TCPServerSocket_Shared*>(enter.object()); | 168 static_cast<PPB_TCPServerSocket_Shared*>(enter.object()); |
| 171 if (status == PP_OK) | 169 if (status == PP_OK) |
| 172 id_to_server_socket_[socket_id] = server_socket; | 170 id_to_server_socket_[socket_id] = server_socket; |
| 173 server_socket->OnListenCompleted(socket_id, status); | 171 server_socket->OnListenCompleted(socket_id, status); |
| 174 } else if (socket_id != 0 && status == PP_OK) { | 172 } else if (socket_id != 0 && status == PP_OK) { |
| 175 IPC::Message* msg = | 173 IPC::Message* msg = |
| 176 new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id); | 174 new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id); |
| 177 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(msg); | 175 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(msg); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 193 local_addr, | 191 local_addr, |
| 194 remote_addr); | 192 remote_addr); |
| 195 } else if (accepted_socket_id != 0) { | 193 } else if (accepted_socket_id != 0) { |
| 196 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | 194 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
| 197 new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); | 195 new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); |
| 198 } | 196 } |
| 199 } | 197 } |
| 200 | 198 |
| 201 } // namespace proxy | 199 } // namespace proxy |
| 202 } // namespace ppapi | 200 } // namespace ppapi |
| OLD | NEW |