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_udp_socket_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_udp_socket_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 virtual ~AbortCallbackTask() {} | 42 virtual ~AbortCallbackTask() {} |
43 virtual void Run() { | 43 virtual void Run() { |
44 if (callback_.func) | 44 if (callback_.func) |
45 PP_RunCompletionCallback(&callback_, PP_ERROR_ABORTED); | 45 PP_RunCompletionCallback(&callback_, PP_ERROR_ABORTED); |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 PP_CompletionCallback callback_; | 49 PP_CompletionCallback callback_; |
50 }; | 50 }; |
51 | 51 |
52 InterfaceProxy* CreateFlashUDPSocketProxy(Dispatcher* dispatcher) { | |
53 return new PPB_Flash_UDPSocket_Proxy(dispatcher); | |
54 } | |
55 | |
56 class FlashUDPSocket : public PPB_Flash_UDPSocket_API, | 52 class FlashUDPSocket : public PPB_Flash_UDPSocket_API, |
57 public Resource { | 53 public Resource { |
58 public: | 54 public: |
59 FlashUDPSocket(const HostResource& resource, uint32 socket_id); | 55 FlashUDPSocket(const HostResource& resource, uint32 socket_id); |
60 virtual ~FlashUDPSocket(); | 56 virtual ~FlashUDPSocket(); |
61 | 57 |
62 // ResourceObjectBase overrides. | 58 // ResourceObjectBase overrides. |
63 virtual PPB_Flash_UDPSocket_API* AsPPB_Flash_UDPSocket_API() OVERRIDE; | 59 virtual PPB_Flash_UDPSocket_API* AsPPB_Flash_UDPSocket_API() OVERRIDE; |
64 | 60 |
65 // PPB_Flash_UDPSocket_API implementation. | 61 // PPB_Flash_UDPSocket_API implementation. |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } // namespace | 286 } // namespace |
291 | 287 |
292 PPB_Flash_UDPSocket_Proxy::PPB_Flash_UDPSocket_Proxy(Dispatcher* dispatcher) | 288 PPB_Flash_UDPSocket_Proxy::PPB_Flash_UDPSocket_Proxy(Dispatcher* dispatcher) |
293 : InterfaceProxy(dispatcher) { | 289 : InterfaceProxy(dispatcher) { |
294 } | 290 } |
295 | 291 |
296 PPB_Flash_UDPSocket_Proxy::~PPB_Flash_UDPSocket_Proxy() { | 292 PPB_Flash_UDPSocket_Proxy::~PPB_Flash_UDPSocket_Proxy() { |
297 } | 293 } |
298 | 294 |
299 // static | 295 // static |
300 const InterfaceProxy::Info* PPB_Flash_UDPSocket_Proxy::GetInfo() { | |
301 static const Info info = { | |
302 ::ppapi::thunk::GetPPB_Flash_UDPSocket_Thunk(), | |
303 PPB_FLASH_UDPSOCKET_INTERFACE, | |
304 API_ID_PPB_FLASH_UDPSOCKET, | |
305 false, | |
306 &CreateFlashUDPSocketProxy, | |
307 }; | |
308 return &info; | |
309 } | |
310 | |
311 // static | |
312 PP_Resource PPB_Flash_UDPSocket_Proxy::CreateProxyResource( | 296 PP_Resource PPB_Flash_UDPSocket_Proxy::CreateProxyResource( |
313 PP_Instance instance) { | 297 PP_Instance instance) { |
314 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 298 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
315 if (!dispatcher) | 299 if (!dispatcher) |
316 return 0; | 300 return 0; |
317 | 301 |
318 uint32 socket_id = 0; | 302 uint32 socket_id = 0; |
319 dispatcher->SendToBrowser(new PpapiHostMsg_PPBFlashUDPSocket_Create( | 303 dispatcher->SendToBrowser(new PpapiHostMsg_PPBFlashUDPSocket_Create( |
320 API_ID_PPB_FLASH_UDPSOCKET, dispatcher->plugin_dispatcher_id(), | 304 API_ID_PPB_FLASH_UDPSOCKET, dispatcher->plugin_dispatcher_id(), |
321 &socket_id)); | 305 &socket_id)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 } | 365 } |
382 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | 366 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
383 if (iter == g_id_to_socket->end()) | 367 if (iter == g_id_to_socket->end()) |
384 return; | 368 return; |
385 iter->second->OnSendToCompleted(succeeded, bytes_written); | 369 iter->second->OnSendToCompleted(succeeded, bytes_written); |
386 } | 370 } |
387 | 371 |
388 } // namespace proxy | 372 } // namespace proxy |
389 } // namespace ppapi | 373 } // namespace ppapi |
390 | 374 |
OLD | NEW |