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_udp_socket_private_proxy.h" | 5 #include "ppapi/proxy/ppb_udp_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/c/private/ppb_udp_socket_private.h" | 10 #include "ppapi/c/private/ppb_udp_socket_private.h" |
11 #include "ppapi/proxy/plugin_dispatcher.h" | 11 #include "ppapi/proxy/plugin_dispatcher.h" |
12 #include "ppapi/proxy/plugin_globals.h" | 12 #include "ppapi/proxy/plugin_globals.h" |
13 #include "ppapi/proxy/plugin_proxy_delegate.h" | |
14 #include "ppapi/proxy/plugin_resource_tracker.h" | 13 #include "ppapi/proxy/plugin_resource_tracker.h" |
15 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
16 #include "ppapi/shared_impl/private/udp_socket_private_impl.h" | 15 #include "ppapi/shared_impl/private/udp_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 |
23 namespace { | 22 namespace { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 76 |
78 void UDPSocket::SendClose() { | 77 void UDPSocket::SendClose() { |
79 // After removed from the mapping, this object won't receive any notifications | 78 // After removed from the mapping, this object won't receive any notifications |
80 // from the proxy. | 79 // from the proxy. |
81 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); | 80 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); |
82 g_id_to_socket->erase(socket_id_); | 81 g_id_to_socket->erase(socket_id_); |
83 SendToBrowser(new PpapiHostMsg_PPBUDPSocket_Close(socket_id_)); | 82 SendToBrowser(new PpapiHostMsg_PPBUDPSocket_Close(socket_id_)); |
84 } | 83 } |
85 | 84 |
86 void UDPSocket::SendToBrowser(IPC::Message* msg) { | 85 void UDPSocket::SendToBrowser(IPC::Message* msg) { |
87 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(msg); | 86 PluginGlobals::Get()->GetBrowserSender()->Send(msg); |
88 } | 87 } |
89 | 88 |
90 } // namespace | 89 } // namespace |
91 | 90 |
92 //------------------------------------------------------------------------------ | 91 //------------------------------------------------------------------------------ |
93 | 92 |
94 PPB_UDPSocket_Private_Proxy::PPB_UDPSocket_Private_Proxy(Dispatcher* dispatcher) | 93 PPB_UDPSocket_Private_Proxy::PPB_UDPSocket_Private_Proxy(Dispatcher* dispatcher) |
95 : InterfaceProxy(dispatcher) { | 94 : InterfaceProxy(dispatcher) { |
96 } | 95 } |
97 | 96 |
98 PPB_UDPSocket_Private_Proxy::~PPB_UDPSocket_Private_Proxy() { | 97 PPB_UDPSocket_Private_Proxy::~PPB_UDPSocket_Private_Proxy() { |
99 } | 98 } |
100 | 99 |
101 // static | 100 // static |
102 PP_Resource PPB_UDPSocket_Private_Proxy::CreateProxyResource( | 101 PP_Resource PPB_UDPSocket_Private_Proxy::CreateProxyResource( |
103 PP_Instance instance) { | 102 PP_Instance instance) { |
104 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 103 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
105 if (!dispatcher) | 104 if (!dispatcher) |
106 return 0; | 105 return 0; |
107 | 106 |
108 uint32 socket_id = 0; | 107 uint32 socket_id = 0; |
109 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | 108 PluginGlobals::Get()->GetBrowserSender()->Send( |
110 new PpapiHostMsg_PPBUDPSocket_Create( | 109 new PpapiHostMsg_PPBUDPSocket_Create( |
111 API_ID_PPB_UDPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), | 110 API_ID_PPB_UDPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), |
112 &socket_id)); | 111 &socket_id)); |
113 if (socket_id == 0) | 112 if (socket_id == 0) |
114 return 0; | 113 return 0; |
115 | 114 |
116 return (new UDPSocket(HostResource::MakeInstanceOnly(instance), | 115 return (new UDPSocket(HostResource::MakeInstanceOnly(instance), |
117 socket_id))->GetReference(); | 116 socket_id))->GetReference(); |
118 } | 117 } |
119 | 118 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 return; | 171 return; |
173 } | 172 } |
174 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | 173 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
175 if (iter == g_id_to_socket->end()) | 174 if (iter == g_id_to_socket->end()) |
176 return; | 175 return; |
177 iter->second->OnSendToCompleted(succeeded, bytes_written); | 176 iter->second->OnSendToCompleted(succeeded, bytes_written); |
178 } | 177 } |
179 | 178 |
180 } // namespace proxy | 179 } // namespace proxy |
181 } // namespace ppapi | 180 } // namespace ppapi |
OLD | NEW |