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" | |
14 #include "ppapi/proxy/plugin_resource_tracker.h" | 13 #include "ppapi/proxy/plugin_resource_tracker.h" |
15 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
16 #include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" | 15 #include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" |
17 #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" | 16 #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" |
18 #include "ppapi/shared_impl/resource.h" | 17 #include "ppapi/shared_impl/resource.h" |
19 #include "ppapi/thunk/enter.h" | 18 #include "ppapi/thunk/enter.h" |
20 #include "ppapi/thunk/thunk.h" | 19 #include "ppapi/thunk/thunk.h" |
21 | 20 |
22 namespace ppapi { | 21 namespace ppapi { |
23 namespace proxy { | 22 namespace proxy { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 InterfaceProxy* proxy = | 105 InterfaceProxy* proxy = |
107 dispatcher->GetInterfaceProxy(API_ID_PPB_TCPSERVERSOCKET_PRIVATE); | 106 dispatcher->GetInterfaceProxy(API_ID_PPB_TCPSERVERSOCKET_PRIVATE); |
108 PPB_TCPServerSocket_Private_Proxy* server_socket_proxy = | 107 PPB_TCPServerSocket_Private_Proxy* server_socket_proxy = |
109 static_cast<PPB_TCPServerSocket_Private_Proxy*>(proxy); | 108 static_cast<PPB_TCPServerSocket_Private_Proxy*>(proxy); |
110 server_socket_proxy->ObjectDestroyed(socket_id_); | 109 server_socket_proxy->ObjectDestroyed(socket_id_); |
111 } | 110 } |
112 } | 111 } |
113 } | 112 } |
114 | 113 |
115 void TCPServerSocket::SendToBrowser(IPC::Message* msg) { | 114 void TCPServerSocket::SendToBrowser(IPC::Message* msg) { |
116 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(msg); | 115 PluginGlobals::Get()->GetBrowserSender()->Send(msg); |
117 } | 116 } |
118 | 117 |
119 } // namespace | 118 } // namespace |
120 | 119 |
121 //------------------------------------------------------------------------------ | 120 //------------------------------------------------------------------------------ |
122 | 121 |
123 PPB_TCPServerSocket_Private_Proxy::PPB_TCPServerSocket_Private_Proxy( | 122 PPB_TCPServerSocket_Private_Proxy::PPB_TCPServerSocket_Private_Proxy( |
124 Dispatcher* dispatcher) | 123 Dispatcher* dispatcher) |
125 : InterfaceProxy(dispatcher) { | 124 : InterfaceProxy(dispatcher) { |
126 } | 125 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 enter(socket_resource, true); | 163 enter(socket_resource, true); |
165 if (enter.succeeded()) { | 164 if (enter.succeeded()) { |
166 PPB_TCPServerSocket_Shared* server_socket = | 165 PPB_TCPServerSocket_Shared* server_socket = |
167 static_cast<PPB_TCPServerSocket_Shared*>(enter.object()); | 166 static_cast<PPB_TCPServerSocket_Shared*>(enter.object()); |
168 if (status == PP_OK) | 167 if (status == PP_OK) |
169 id_to_server_socket_[socket_id] = server_socket; | 168 id_to_server_socket_[socket_id] = server_socket; |
170 server_socket->OnListenCompleted(socket_id, status); | 169 server_socket->OnListenCompleted(socket_id, status); |
171 } else if (socket_id != 0 && status == PP_OK) { | 170 } else if (socket_id != 0 && status == PP_OK) { |
172 IPC::Message* msg = | 171 IPC::Message* msg = |
173 new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id); | 172 new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id); |
174 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(msg); | 173 PluginGlobals::Get()->GetBrowserSender()->Send(msg); |
175 } | 174 } |
176 } | 175 } |
177 | 176 |
178 void PPB_TCPServerSocket_Private_Proxy::OnMsgAcceptACK( | 177 void PPB_TCPServerSocket_Private_Proxy::OnMsgAcceptACK( |
179 uint32 plugin_dispatcher_id, | 178 uint32 plugin_dispatcher_id, |
180 uint32 server_socket_id, | 179 uint32 server_socket_id, |
181 uint32 accepted_socket_id, | 180 uint32 accepted_socket_id, |
182 const PP_NetAddress_Private& local_addr, | 181 const PP_NetAddress_Private& local_addr, |
183 const PP_NetAddress_Private& remote_addr) { | 182 const PP_NetAddress_Private& remote_addr) { |
184 IDToServerSocketMap::iterator it = | 183 IDToServerSocketMap::iterator it = |
185 id_to_server_socket_.find(server_socket_id); | 184 id_to_server_socket_.find(server_socket_id); |
186 if (it != id_to_server_socket_.end()) { | 185 if (it != id_to_server_socket_.end()) { |
187 bool succeeded = (accepted_socket_id != 0); | 186 bool succeeded = (accepted_socket_id != 0); |
188 it->second->OnAcceptCompleted(succeeded, | 187 it->second->OnAcceptCompleted(succeeded, |
189 accepted_socket_id, | 188 accepted_socket_id, |
190 local_addr, | 189 local_addr, |
191 remote_addr); | 190 remote_addr); |
192 } else if (accepted_socket_id != 0) { | 191 } else if (accepted_socket_id != 0) { |
193 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | 192 PluginGlobals::Get()->GetBrowserSender()->Send( |
194 new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); | 193 new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); |
195 } | 194 } |
196 } | 195 } |
197 | 196 |
198 } // namespace proxy | 197 } // namespace proxy |
199 } // namespace ppapi | 198 } // namespace ppapi |
OLD | NEW |