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_socket_private_proxy.h" | 5 #include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
11 #include "ppapi/proxy/plugin_globals.h" | 11 #include "ppapi/proxy/plugin_globals.h" |
12 #include "ppapi/proxy/plugin_proxy_delegate.h" | |
13 #include "ppapi/proxy/plugin_resource_tracker.h" | 12 #include "ppapi/proxy/plugin_resource_tracker.h" |
14 #include "ppapi/proxy/ppapi_messages.h" | 13 #include "ppapi/proxy/ppapi_messages.h" |
15 #include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" | 14 #include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" |
16 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" | 15 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" |
17 #include "ppapi/shared_impl/resource.h" | 16 #include "ppapi/shared_impl/resource.h" |
18 #include "ppapi/thunk/thunk.h" | 17 #include "ppapi/thunk/thunk.h" |
19 | 18 |
20 namespace ppapi { | 19 namespace ppapi { |
21 namespace proxy { | 20 namespace proxy { |
22 | 21 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 110 |
112 void TCPSocket::SendDisconnect() { | 111 void TCPSocket::SendDisconnect() { |
113 // After removed from the mapping, this object won't receive any notifications | 112 // After removed from the mapping, this object won't receive any notifications |
114 // from the proxy. | 113 // from the proxy. |
115 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); | 114 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); |
116 g_id_to_socket->erase(socket_id_); | 115 g_id_to_socket->erase(socket_id_); |
117 SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); | 116 SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); |
118 } | 117 } |
119 | 118 |
120 void TCPSocket::SendToBrowser(IPC::Message* msg) { | 119 void TCPSocket::SendToBrowser(IPC::Message* msg) { |
121 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(msg); | 120 PluginGlobals::Get()->GetBrowserSender()->Send(msg); |
122 } | 121 } |
123 | 122 |
124 } // namespace | 123 } // namespace |
125 | 124 |
126 //------------------------------------------------------------------------------ | 125 //------------------------------------------------------------------------------ |
127 | 126 |
128 PPB_TCPSocket_Private_Proxy::PPB_TCPSocket_Private_Proxy(Dispatcher* dispatcher) | 127 PPB_TCPSocket_Private_Proxy::PPB_TCPSocket_Private_Proxy(Dispatcher* dispatcher) |
129 : InterfaceProxy(dispatcher) { | 128 : InterfaceProxy(dispatcher) { |
130 } | 129 } |
131 | 130 |
132 PPB_TCPSocket_Private_Proxy::~PPB_TCPSocket_Private_Proxy() { | 131 PPB_TCPSocket_Private_Proxy::~PPB_TCPSocket_Private_Proxy() { |
133 } | 132 } |
134 | 133 |
135 // static | 134 // static |
136 PP_Resource PPB_TCPSocket_Private_Proxy::CreateProxyResource( | 135 PP_Resource PPB_TCPSocket_Private_Proxy::CreateProxyResource( |
137 PP_Instance instance) { | 136 PP_Instance instance) { |
138 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 137 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
139 if (!dispatcher) | 138 if (!dispatcher) |
140 return 0; | 139 return 0; |
141 | 140 |
142 uint32 socket_id = 0; | 141 uint32 socket_id = 0; |
143 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | 142 PluginGlobals::Get()->GetBrowserSender()->Send( |
144 new PpapiHostMsg_PPBTCPSocket_Create( | 143 new PpapiHostMsg_PPBTCPSocket_Create( |
145 API_ID_PPB_TCPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), | 144 API_ID_PPB_TCPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), |
146 &socket_id)); | 145 &socket_id)); |
147 if (socket_id == 0) | 146 if (socket_id == 0) |
148 return 0; | 147 return 0; |
149 return (new TCPSocket(HostResource::MakeInstanceOnly(instance), | 148 return (new TCPSocket(HostResource::MakeInstanceOnly(instance), |
150 socket_id))->GetReference(); | 149 socket_id))->GetReference(); |
151 } | 150 } |
152 | 151 |
153 // static | 152 // static |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 return; | 231 return; |
233 } | 232 } |
234 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | 233 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
235 if (iter == g_id_to_socket->end()) | 234 if (iter == g_id_to_socket->end()) |
236 return; | 235 return; |
237 iter->second->OnWriteCompleted(succeeded, bytes_written); | 236 iter->second->OnWriteCompleted(succeeded, bytes_written); |
238 } | 237 } |
239 | 238 |
240 } // namespace proxy | 239 } // namespace proxy |
241 } // namespace ppapi | 240 } // namespace ppapi |
OLD | NEW |