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_tcp_socket_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_tcp_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* CreateFlashTCPSocketProxy(Dispatcher* dispatcher) { | |
53 return new PPB_Flash_TCPSocket_Proxy(dispatcher); | |
54 } | |
55 | |
56 } // namespace | 52 } // namespace |
57 | 53 |
58 class FlashTCPSocket : public PPB_Flash_TCPSocket_API, | 54 class FlashTCPSocket : public PPB_Flash_TCPSocket_API, |
59 public Resource { | 55 public Resource { |
60 public: | 56 public: |
61 FlashTCPSocket(const HostResource& resource, uint32 socket_id); | 57 FlashTCPSocket(const HostResource& resource, uint32 socket_id); |
62 virtual ~FlashTCPSocket(); | 58 virtual ~FlashTCPSocket(); |
63 | 59 |
64 // Resource overrides. | 60 // Resource overrides. |
65 virtual PPB_Flash_TCPSocket_API* AsPPB_Flash_TCPSocket_API() OVERRIDE; | 61 virtual PPB_Flash_TCPSocket_API* AsPPB_Flash_TCPSocket_API() OVERRIDE; |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 } | 391 } |
396 | 392 |
397 PPB_Flash_TCPSocket_Proxy::PPB_Flash_TCPSocket_Proxy(Dispatcher* dispatcher) | 393 PPB_Flash_TCPSocket_Proxy::PPB_Flash_TCPSocket_Proxy(Dispatcher* dispatcher) |
398 : InterfaceProxy(dispatcher) { | 394 : InterfaceProxy(dispatcher) { |
399 } | 395 } |
400 | 396 |
401 PPB_Flash_TCPSocket_Proxy::~PPB_Flash_TCPSocket_Proxy() { | 397 PPB_Flash_TCPSocket_Proxy::~PPB_Flash_TCPSocket_Proxy() { |
402 } | 398 } |
403 | 399 |
404 // static | 400 // static |
405 const InterfaceProxy::Info* PPB_Flash_TCPSocket_Proxy::GetInfo() { | |
406 static const Info info = { | |
407 thunk::GetPPB_Flash_TCPSocket_Thunk(), | |
408 PPB_FLASH_TCPSOCKET_INTERFACE, | |
409 API_ID_PPB_FLASH_TCPSOCKET, | |
410 false, | |
411 &CreateFlashTCPSocketProxy, | |
412 }; | |
413 return &info; | |
414 } | |
415 | |
416 // static | |
417 PP_Resource PPB_Flash_TCPSocket_Proxy::CreateProxyResource( | 401 PP_Resource PPB_Flash_TCPSocket_Proxy::CreateProxyResource( |
418 PP_Instance instance) { | 402 PP_Instance instance) { |
419 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 403 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
420 if (!dispatcher) | 404 if (!dispatcher) |
421 return 0; | 405 return 0; |
422 | 406 |
423 uint32 socket_id = 0; | 407 uint32 socket_id = 0; |
424 dispatcher->SendToBrowser(new PpapiHostMsg_PPBFlashTCPSocket_Create( | 408 dispatcher->SendToBrowser(new PpapiHostMsg_PPBFlashTCPSocket_Create( |
425 API_ID_PPB_FLASH_TCPSOCKET, dispatcher->plugin_dispatcher_id(), | 409 API_ID_PPB_FLASH_TCPSOCKET, dispatcher->plugin_dispatcher_id(), |
426 &socket_id)); | 410 &socket_id)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 return; | 480 return; |
497 } | 481 } |
498 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | 482 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
499 if (iter == g_id_to_socket->end()) | 483 if (iter == g_id_to_socket->end()) |
500 return; | 484 return; |
501 iter->second->OnWriteCompleted(succeeded, bytes_written); | 485 iter->second->OnWriteCompleted(succeeded, bytes_written); |
502 } | 486 } |
503 | 487 |
504 } // namespace proxy | 488 } // namespace proxy |
505 } // namespace ppapi | 489 } // namespace ppapi |
OLD | NEW |