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 SendSetBoolOption(PP_TCPSocketOption_Private name, |
| 50 bool value) OVERRIDE; |
49 | 51 |
50 private: | 52 private: |
51 void SendToBrowser(IPC::Message* msg); | 53 void SendToBrowser(IPC::Message* msg); |
52 | 54 |
53 DISALLOW_COPY_AND_ASSIGN(TCPSocket); | 55 DISALLOW_COPY_AND_ASSIGN(TCPSocket); |
54 }; | 56 }; |
55 | 57 |
56 TCPSocket::TCPSocket(const HostResource& resource, uint32 socket_id) | 58 TCPSocket::TCPSocket(const HostResource& resource, uint32 socket_id) |
57 : TCPSocketPrivateImpl(resource, socket_id) { | 59 : TCPSocketPrivateImpl(resource, socket_id) { |
58 if (!g_id_to_socket) | 60 if (!g_id_to_socket) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 111 } |
110 | 112 |
111 void TCPSocket::SendDisconnect() { | 113 void TCPSocket::SendDisconnect() { |
112 // After removed from the mapping, this object won't receive any notifications | 114 // After removed from the mapping, this object won't receive any notifications |
113 // from the proxy. | 115 // from the proxy. |
114 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); | 116 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); |
115 g_id_to_socket->erase(socket_id_); | 117 g_id_to_socket->erase(socket_id_); |
116 SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); | 118 SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); |
117 } | 119 } |
118 | 120 |
| 121 void TCPSocket::SendSetBoolOption(PP_TCPSocketOption_Private name, bool value) { |
| 122 SendToBrowser( |
| 123 new PpapiHostMsg_PPBTCPSocket_SetBoolOption(socket_id_, name, value)); |
| 124 } |
| 125 |
119 void TCPSocket::SendToBrowser(IPC::Message* msg) { | 126 void TCPSocket::SendToBrowser(IPC::Message* msg) { |
120 PluginGlobals::Get()->GetBrowserSender()->Send(msg); | 127 PluginGlobals::Get()->GetBrowserSender()->Send(msg); |
121 } | 128 } |
122 | 129 |
123 } // namespace | 130 } // namespace |
124 | 131 |
125 //------------------------------------------------------------------------------ | 132 //------------------------------------------------------------------------------ |
126 | 133 |
127 PPB_TCPSocket_Private_Proxy::PPB_TCPSocket_Private_Proxy(Dispatcher* dispatcher) | 134 PPB_TCPSocket_Private_Proxy::PPB_TCPSocket_Private_Proxy(Dispatcher* dispatcher) |
128 : InterfaceProxy(dispatcher) { | 135 : InterfaceProxy(dispatcher) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 170 |
164 bool PPB_TCPSocket_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { | 171 bool PPB_TCPSocket_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { |
165 bool handled = true; | 172 bool handled = true; |
166 IPC_BEGIN_MESSAGE_MAP(PPB_TCPSocket_Private_Proxy, msg) | 173 IPC_BEGIN_MESSAGE_MAP(PPB_TCPSocket_Private_Proxy, msg) |
167 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, | 174 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, |
168 OnMsgConnectACK) | 175 OnMsgConnectACK) |
169 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, | 176 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, |
170 OnMsgSSLHandshakeACK) | 177 OnMsgSSLHandshakeACK) |
171 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnMsgReadACK) | 178 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnMsgReadACK) |
172 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnMsgWriteACK) | 179 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnMsgWriteACK) |
| 180 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetBoolOptionACK, |
| 181 OnMsgSetBoolOptionACK) |
173 IPC_MESSAGE_UNHANDLED(handled = false) | 182 IPC_MESSAGE_UNHANDLED(handled = false) |
174 IPC_END_MESSAGE_MAP() | 183 IPC_END_MESSAGE_MAP() |
175 return handled; | 184 return handled; |
176 } | 185 } |
177 | 186 |
178 void PPB_TCPSocket_Private_Proxy::OnMsgConnectACK( | 187 void PPB_TCPSocket_Private_Proxy::OnMsgConnectACK( |
179 uint32 /* plugin_dispatcher_id */, | 188 uint32 /* plugin_dispatcher_id */, |
180 uint32 socket_id, | 189 uint32 socket_id, |
181 bool succeeded, | 190 bool succeeded, |
182 const PP_NetAddress_Private& local_addr, | 191 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) { | 238 if (!g_id_to_socket) { |
230 NOTREACHED(); | 239 NOTREACHED(); |
231 return; | 240 return; |
232 } | 241 } |
233 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | 242 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
234 if (iter == g_id_to_socket->end()) | 243 if (iter == g_id_to_socket->end()) |
235 return; | 244 return; |
236 iter->second->OnWriteCompleted(succeeded, bytes_written); | 245 iter->second->OnWriteCompleted(succeeded, bytes_written); |
237 } | 246 } |
238 | 247 |
| 248 void PPB_TCPSocket_Private_Proxy::OnMsgSetBoolOptionACK( |
| 249 uint32 /* plugin_dispatcher_id */, |
| 250 uint32 socket_id, |
| 251 bool succeeded) { |
| 252 if (!g_id_to_socket) { |
| 253 NOTREACHED(); |
| 254 return; |
| 255 } |
| 256 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
| 257 if (iter == g_id_to_socket->end()) |
| 258 return; |
| 259 iter->second->OnSetOptionCompleted(succeeded); |
| 260 } |
| 261 |
239 } // namespace proxy | 262 } // namespace proxy |
240 } // namespace ppapi | 263 } // namespace ppapi |
OLD | NEW |