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 "content/renderer/pepper/ppb_tcp_server_socket_private_impl.h" | 5 #include "content/renderer/pepper/ppb_tcp_server_socket_private_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/renderer/pepper/host_globals.h" | 8 #include "content/renderer/pepper/host_globals.h" |
9 #include "content/renderer/pepper/plugin_delegate.h" | 9 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |
10 #include "content/renderer/pepper/ppb_tcp_socket_private_impl.h" | 10 #include "content/renderer/pepper/ppb_tcp_socket_private_impl.h" |
11 #include "content/renderer/pepper/resource_helper.h" | 11 #include "content/renderer/pepper/resource_helper.h" |
| 12 #include "ppapi/proxy/ppapi_messages.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 | 15 |
15 PPB_TCPServerSocket_Private_Impl::PPB_TCPServerSocket_Private_Impl( | 16 PPB_TCPServerSocket_Private_Impl::PPB_TCPServerSocket_Private_Impl( |
16 PP_Instance instance) | 17 PP_Instance instance) |
17 : ::ppapi::PPB_TCPServerSocket_Shared(instance) { | 18 : ::ppapi::PPB_TCPServerSocket_Shared(instance) { |
18 } | 19 } |
19 | 20 |
20 PPB_TCPServerSocket_Private_Impl::~PPB_TCPServerSocket_Private_Impl() { | 21 PPB_TCPServerSocket_Private_Impl::~PPB_TCPServerSocket_Private_Impl() { |
21 StopListening(); | 22 StopListening(); |
(...skipping 25 matching lines...) Expand all Loading... |
47 remote_addr); | 48 remote_addr); |
48 } | 49 } |
49 tcp_socket_buffer_ = NULL; | 50 tcp_socket_buffer_ = NULL; |
50 | 51 |
51 accept_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED); | 52 accept_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED); |
52 } | 53 } |
53 | 54 |
54 void PPB_TCPServerSocket_Private_Impl::SendListen( | 55 void PPB_TCPServerSocket_Private_Impl::SendListen( |
55 const PP_NetAddress_Private& addr, | 56 const PP_NetAddress_Private& addr, |
56 int32_t backlog) { | 57 int32_t backlog) { |
57 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 58 PepperPluginDelegateImpl* plugin_delegate = GetPluginDelegate(); |
58 if (!plugin_delegate) | 59 if (!plugin_delegate) |
59 return; | 60 return; |
60 | 61 |
61 plugin_delegate->TCPServerSocketListen(pp_resource(), addr, backlog); | 62 plugin_delegate->Send(new PpapiHostMsg_PPBTCPServerSocket_Listen( |
| 63 plugin_delegate->routing_id(), 0, pp_resource(), addr, backlog)); |
62 } | 64 } |
63 | 65 |
64 void PPB_TCPServerSocket_Private_Impl::SendAccept() { | 66 void PPB_TCPServerSocket_Private_Impl::SendAccept() { |
65 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 67 PepperPluginDelegateImpl* plugin_delegate = GetPluginDelegate(); |
66 if (!plugin_delegate) | 68 if (!plugin_delegate) |
67 return; | 69 return; |
68 | 70 |
69 plugin_delegate->TCPServerSocketAccept(socket_id_); | 71 plugin_delegate->Send(new PpapiHostMsg_PPBTCPServerSocket_Accept( |
| 72 plugin_delegate->routing_id(), socket_id_)); |
70 } | 73 } |
71 | 74 |
72 void PPB_TCPServerSocket_Private_Impl::SendStopListening() { | 75 void PPB_TCPServerSocket_Private_Impl::SendStopListening() { |
73 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 76 PepperPluginDelegateImpl* plugin_delegate = GetPluginDelegate(); |
74 if (!plugin_delegate) | 77 if (!plugin_delegate) |
75 return; | 78 return; |
76 | 79 |
77 plugin_delegate->TCPServerSocketStopListening(pp_resource(), socket_id_); | 80 if (socket_id_ != 0) { |
| 81 plugin_delegate->Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy( |
| 82 socket_id_)); |
| 83 plugin_delegate->TCPServerSocketStopListening(socket_id_); |
| 84 } |
| 85 } |
| 86 |
| 87 PepperPluginDelegateImpl* |
| 88 PPB_TCPServerSocket_Private_Impl::GetPluginDelegate() { |
| 89 return static_cast<PepperPluginDelegateImpl*>( |
| 90 ResourceHelper::GetPluginDelegate(this)); |
78 } | 91 } |
79 | 92 |
80 } // namespace content | 93 } // namespace content |
OLD | NEW |