| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_flash_net_connector_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_net_connector_proxy.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/c/private/ppb_flash_net_connector.h" | 10 #include "ppapi/c/private/ppb_flash_net_connector.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 int32_t FlashNetConnector::ConnectTcp( | 111 int32_t FlashNetConnector::ConnectTcp( |
| 112 const char* host, | 112 const char* host, |
| 113 uint16_t port, | 113 uint16_t port, |
| 114 PP_FileHandle* socket_out, | 114 PP_FileHandle* socket_out, |
| 115 PP_Flash_NetAddress* local_addr_out, | 115 PP_Flash_NetAddress* local_addr_out, |
| 116 PP_Flash_NetAddress* remote_addr_out, | 116 PP_Flash_NetAddress* remote_addr_out, |
| 117 PP_CompletionCallback callback) { | 117 PP_CompletionCallback callback) { |
| 118 return ConnectWithMessage( | 118 return ConnectWithMessage( |
| 119 new PpapiHostMsg_PPBFlashNetConnector_ConnectTcp( | 119 new PpapiHostMsg_PPBFlashNetConnector_ConnectTcp( |
| 120 INTERFACE_ID_PPB_FLASH_NETCONNECTOR, host_resource(), host, port), | 120 API_ID_PPB_FLASH_NETCONNECTOR, host_resource(), host, port), |
| 121 socket_out, local_addr_out, remote_addr_out, callback); | 121 socket_out, local_addr_out, remote_addr_out, callback); |
| 122 } | 122 } |
| 123 | 123 |
| 124 int32_t FlashNetConnector::ConnectTcpAddress( | 124 int32_t FlashNetConnector::ConnectTcpAddress( |
| 125 const PP_Flash_NetAddress* addr, | 125 const PP_Flash_NetAddress* addr, |
| 126 PP_FileHandle* socket_out, | 126 PP_FileHandle* socket_out, |
| 127 PP_Flash_NetAddress* local_addr_out, | 127 PP_Flash_NetAddress* local_addr_out, |
| 128 PP_Flash_NetAddress* remote_addr_out, | 128 PP_Flash_NetAddress* remote_addr_out, |
| 129 PP_CompletionCallback callback) { | 129 PP_CompletionCallback callback) { |
| 130 return ConnectWithMessage( | 130 return ConnectWithMessage( |
| 131 new PpapiHostMsg_PPBFlashNetConnector_ConnectTcpAddress( | 131 new PpapiHostMsg_PPBFlashNetConnector_ConnectTcpAddress( |
| 132 INTERFACE_ID_PPB_FLASH_NETCONNECTOR, | 132 API_ID_PPB_FLASH_NETCONNECTOR, |
| 133 host_resource(), NetAddressToString(*addr)), | 133 host_resource(), NetAddressToString(*addr)), |
| 134 socket_out, local_addr_out, remote_addr_out, callback); | 134 socket_out, local_addr_out, remote_addr_out, callback); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void FlashNetConnector::ConnectComplete( | 137 void FlashNetConnector::ConnectComplete( |
| 138 int32_t result, | 138 int32_t result, |
| 139 base::PlatformFile file, | 139 base::PlatformFile file, |
| 140 const std::string& local_addr_as_string, | 140 const std::string& local_addr_as_string, |
| 141 const std::string& remote_addr_as_string) { | 141 const std::string& remote_addr_as_string) { |
| 142 if (!callback_.func) { | 142 if (!callback_.func) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 202 } |
| 203 | 203 |
| 204 PPB_Flash_NetConnector_Proxy::~PPB_Flash_NetConnector_Proxy() { | 204 PPB_Flash_NetConnector_Proxy::~PPB_Flash_NetConnector_Proxy() { |
| 205 } | 205 } |
| 206 | 206 |
| 207 // static | 207 // static |
| 208 const InterfaceProxy::Info* PPB_Flash_NetConnector_Proxy::GetInfo() { | 208 const InterfaceProxy::Info* PPB_Flash_NetConnector_Proxy::GetInfo() { |
| 209 static const Info info = { | 209 static const Info info = { |
| 210 ppapi::thunk::GetPPB_Flash_NetConnector_Thunk(), | 210 ppapi::thunk::GetPPB_Flash_NetConnector_Thunk(), |
| 211 PPB_FLASH_NETCONNECTOR_INTERFACE, | 211 PPB_FLASH_NETCONNECTOR_INTERFACE, |
| 212 INTERFACE_ID_PPB_FLASH_NETCONNECTOR, | 212 API_ID_PPB_FLASH_NETCONNECTOR, |
| 213 false, | 213 false, |
| 214 &CreateFlashNetConnectorProxy | 214 &CreateFlashNetConnectorProxy |
| 215 }; | 215 }; |
| 216 return &info; | 216 return &info; |
| 217 } | 217 } |
| 218 | 218 |
| 219 // static | 219 // static |
| 220 PP_Resource PPB_Flash_NetConnector_Proxy::CreateProxyResource( | 220 PP_Resource PPB_Flash_NetConnector_Proxy::CreateProxyResource( |
| 221 PP_Instance instance) { | 221 PP_Instance instance) { |
| 222 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 222 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 223 if (!dispatcher) | 223 if (!dispatcher) |
| 224 return 0; | 224 return 0; |
| 225 | 225 |
| 226 HostResource result; | 226 HostResource result; |
| 227 dispatcher->Send(new PpapiHostMsg_PPBFlashNetConnector_Create( | 227 dispatcher->Send(new PpapiHostMsg_PPBFlashNetConnector_Create( |
| 228 INTERFACE_ID_PPB_FLASH_NETCONNECTOR, instance, &result)); | 228 API_ID_PPB_FLASH_NETCONNECTOR, instance, &result)); |
| 229 if (result.is_null()) | 229 if (result.is_null()) |
| 230 return 0; | 230 return 0; |
| 231 return (new FlashNetConnector(result))->GetReference(); | 231 return (new FlashNetConnector(result))->GetReference(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool PPB_Flash_NetConnector_Proxy::OnMessageReceived(const IPC::Message& msg) { | 234 bool PPB_Flash_NetConnector_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 235 bool handled = true; | 235 bool handled = true; |
| 236 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_NetConnector_Proxy, msg) | 236 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_NetConnector_Proxy, msg) |
| 237 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashNetConnector_Create, | 237 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashNetConnector_Create, |
| 238 OnMsgCreate) | 238 OnMsgCreate) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 317 } |
| 318 | 318 |
| 319 void PPB_Flash_NetConnector_Proxy::OnCompleteCallbackInHost( | 319 void PPB_Flash_NetConnector_Proxy::OnCompleteCallbackInHost( |
| 320 int32_t result, | 320 int32_t result, |
| 321 ConnectCallbackInfo* info) { | 321 ConnectCallbackInfo* info) { |
| 322 // Callback must always delete the info. | 322 // Callback must always delete the info. |
| 323 scoped_ptr<ConnectCallbackInfo> info_deletor(info); | 323 scoped_ptr<ConnectCallbackInfo> info_deletor(info); |
| 324 | 324 |
| 325 if (result == PP_OK) { | 325 if (result == PP_OK) { |
| 326 dispatcher()->Send(new PpapiMsg_PPBFlashNetConnector_ConnectACK( | 326 dispatcher()->Send(new PpapiMsg_PPBFlashNetConnector_ConnectACK( |
| 327 INTERFACE_ID_PPB_FLASH_NETCONNECTOR, | 327 API_ID_PPB_FLASH_NETCONNECTOR, |
| 328 info->resource, result, | 328 info->resource, result, |
| 329 dispatcher()->ShareHandleWithRemote( | 329 dispatcher()->ShareHandleWithRemote( |
| 330 static_cast<base::PlatformFile>(info->handle), true), | 330 static_cast<base::PlatformFile>(info->handle), true), |
| 331 NetAddressToString(info->local_addr), | 331 NetAddressToString(info->local_addr), |
| 332 NetAddressToString(info->remote_addr))); | 332 NetAddressToString(info->remote_addr))); |
| 333 } else { | 333 } else { |
| 334 dispatcher()->Send(new PpapiMsg_PPBFlashNetConnector_ConnectACK( | 334 dispatcher()->Send(new PpapiMsg_PPBFlashNetConnector_ConnectACK( |
| 335 INTERFACE_ID_PPB_FLASH_NETCONNECTOR, | 335 API_ID_PPB_FLASH_NETCONNECTOR, |
| 336 info->resource, result, | 336 info->resource, result, |
| 337 IPC::InvalidPlatformFileForTransit(), std::string(), std::string())); | 337 IPC::InvalidPlatformFileForTransit(), std::string(), std::string())); |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 | 340 |
| 341 } // namespace proxy | 341 } // namespace proxy |
| 342 } // namespace ppapi | 342 } // namespace ppapi |
| OLD | NEW |