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" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 virtual void SendConnectWithNetAddress( | 39 virtual void SendConnectWithNetAddress( |
40 const PP_NetAddress_Private& addr) OVERRIDE; | 40 const PP_NetAddress_Private& addr) OVERRIDE; |
41 virtual void SendSSLHandshake( | 41 virtual void SendSSLHandshake( |
42 const std::string& server_name, | 42 const std::string& server_name, |
43 uint16_t server_port, | 43 uint16_t server_port, |
44 const std::vector<std::vector<char> >& trusted_certs, | 44 const std::vector<std::vector<char> >& trusted_certs, |
45 const std::vector<std::vector<char> >& untrusted_certs) OVERRIDE; | 45 const std::vector<std::vector<char> >& untrusted_certs) OVERRIDE; |
46 virtual void SendRead(int32_t bytes_to_read) OVERRIDE; | 46 virtual void SendRead(int32_t bytes_to_read) OVERRIDE; |
47 virtual void SendWrite(const std::string& buffer) OVERRIDE; | 47 virtual void SendWrite(const std::string& buffer) OVERRIDE; |
48 virtual void SendDisconnect() OVERRIDE; | 48 virtual void SendDisconnect() OVERRIDE; |
49 virtual void SendBoolSocketFeature(int32_t name, bool value) OVERRIDE; | |
yzshen1
2013/02/08 21:51:11
Please use the enum type instead of int32_t.
Wez
2013/02/10 04:47:02
Done.
| |
49 | 50 |
50 private: | 51 private: |
51 void SendToBrowser(IPC::Message* msg); | 52 void SendToBrowser(IPC::Message* msg); |
52 | 53 |
53 DISALLOW_COPY_AND_ASSIGN(TCPSocket); | 54 DISALLOW_COPY_AND_ASSIGN(TCPSocket); |
54 }; | 55 }; |
55 | 56 |
56 TCPSocket::TCPSocket(const HostResource& resource, uint32 socket_id) | 57 TCPSocket::TCPSocket(const HostResource& resource, uint32 socket_id) |
57 : TCPSocketPrivateImpl(resource, socket_id) { | 58 : TCPSocketPrivateImpl(resource, socket_id) { |
58 if (!g_id_to_socket) | 59 if (!g_id_to_socket) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 } | 110 } |
110 | 111 |
111 void TCPSocket::SendDisconnect() { | 112 void TCPSocket::SendDisconnect() { |
112 // After removed from the mapping, this object won't receive any notifications | 113 // After removed from the mapping, this object won't receive any notifications |
113 // from the proxy. | 114 // from the proxy. |
114 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); | 115 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); |
115 g_id_to_socket->erase(socket_id_); | 116 g_id_to_socket->erase(socket_id_); |
116 SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); | 117 SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); |
117 } | 118 } |
118 | 119 |
120 void TCPSocket::SendBoolSocketFeature(int32_t name, bool value) { | |
121 SendToBrowser(new PpapiHostMsg_PPBTCPSocket_SetBoolFeature( | |
122 socket_id_, name, value)); | |
123 } | |
124 | |
119 void TCPSocket::SendToBrowser(IPC::Message* msg) { | 125 void TCPSocket::SendToBrowser(IPC::Message* msg) { |
120 PluginGlobals::Get()->GetBrowserSender()->Send(msg); | 126 PluginGlobals::Get()->GetBrowserSender()->Send(msg); |
121 } | 127 } |
122 | 128 |
123 } // namespace | 129 } // namespace |
124 | 130 |
125 //------------------------------------------------------------------------------ | 131 //------------------------------------------------------------------------------ |
126 | 132 |
127 PPB_TCPSocket_Private_Proxy::PPB_TCPSocket_Private_Proxy(Dispatcher* dispatcher) | 133 PPB_TCPSocket_Private_Proxy::PPB_TCPSocket_Private_Proxy(Dispatcher* dispatcher) |
128 : InterfaceProxy(dispatcher) { | 134 : InterfaceProxy(dispatcher) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 | 169 |
164 bool PPB_TCPSocket_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { | 170 bool PPB_TCPSocket_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { |
165 bool handled = true; | 171 bool handled = true; |
166 IPC_BEGIN_MESSAGE_MAP(PPB_TCPSocket_Private_Proxy, msg) | 172 IPC_BEGIN_MESSAGE_MAP(PPB_TCPSocket_Private_Proxy, msg) |
167 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, | 173 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, |
168 OnMsgConnectACK) | 174 OnMsgConnectACK) |
169 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, | 175 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, |
170 OnMsgSSLHandshakeACK) | 176 OnMsgSSLHandshakeACK) |
171 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnMsgReadACK) | 177 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnMsgReadACK) |
172 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnMsgWriteACK) | 178 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnMsgWriteACK) |
179 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetBoolFeatureACK, | |
180 OnMsgSetBoolFeatureACK) | |
173 IPC_MESSAGE_UNHANDLED(handled = false) | 181 IPC_MESSAGE_UNHANDLED(handled = false) |
174 IPC_END_MESSAGE_MAP() | 182 IPC_END_MESSAGE_MAP() |
175 return handled; | 183 return handled; |
176 } | 184 } |
177 | 185 |
178 void PPB_TCPSocket_Private_Proxy::OnMsgConnectACK( | 186 void PPB_TCPSocket_Private_Proxy::OnMsgConnectACK( |
179 uint32 /* plugin_dispatcher_id */, | 187 uint32 /* plugin_dispatcher_id */, |
180 uint32 socket_id, | 188 uint32 socket_id, |
181 bool succeeded, | 189 bool succeeded, |
182 const PP_NetAddress_Private& local_addr, | 190 const PP_NetAddress_Private& local_addr, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 if (!g_id_to_socket) { | 237 if (!g_id_to_socket) { |
230 NOTREACHED(); | 238 NOTREACHED(); |
231 return; | 239 return; |
232 } | 240 } |
233 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | 241 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
234 if (iter == g_id_to_socket->end()) | 242 if (iter == g_id_to_socket->end()) |
235 return; | 243 return; |
236 iter->second->OnWriteCompleted(succeeded, bytes_written); | 244 iter->second->OnWriteCompleted(succeeded, bytes_written); |
237 } | 245 } |
238 | 246 |
247 void PPB_TCPSocket_Private_Proxy::OnMsgSetBoolFeatureACK( | |
248 uint32 /* plugin_dispatcher_id */, | |
249 uint32 socket_id, | |
250 bool succeeded) { | |
251 if (!g_id_to_socket) { | |
252 NOTREACHED(); | |
253 return; | |
254 } | |
255 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | |
256 if (iter == g_id_to_socket->end()) | |
257 return; | |
258 iter->second->OnSetSocketFeatureCompleted(succeeded); | |
259 } | |
260 | |
239 } // namespace proxy | 261 } // namespace proxy |
240 } // namespace ppapi | 262 } // namespace ppapi |
OLD | NEW |