| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_flash_tcp_socket_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_tcp_socket_proxy.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 // PPB_Flash_TCPSocket_API implementation. | 68 // PPB_Flash_TCPSocket_API implementation. |
| 69 virtual int32_t Connect(const char* host, | 69 virtual int32_t Connect(const char* host, |
| 70 uint16_t port, | 70 uint16_t port, |
| 71 PP_CompletionCallback callback) OVERRIDE; | 71 PP_CompletionCallback callback) OVERRIDE; |
| 72 virtual int32_t ConnectWithNetAddress( | 72 virtual int32_t ConnectWithNetAddress( |
| 73 const PP_Flash_NetAddress* addr, | 73 const PP_Flash_NetAddress* addr, |
| 74 PP_CompletionCallback callback) OVERRIDE; | 74 PP_CompletionCallback callback) OVERRIDE; |
| 75 virtual PP_Bool GetLocalAddress(PP_Flash_NetAddress* local_addr) OVERRIDE; | 75 virtual PP_Bool GetLocalAddress(PP_Flash_NetAddress* local_addr) OVERRIDE; |
| 76 virtual PP_Bool GetRemoteAddress(PP_Flash_NetAddress* remote_addr) OVERRIDE; | 76 virtual PP_Bool GetRemoteAddress(PP_Flash_NetAddress* remote_addr) OVERRIDE; |
| 77 virtual int32_t InitiateSSL(const char* server_name, | 77 virtual int32_t SSLHandshake(const char* server_name, |
| 78 PP_CompletionCallback callback) OVERRIDE; | 78 uint16_t server_port, |
| 79 PP_CompletionCallback callback) OVERRIDE; |
| 79 virtual int32_t Read(char* buffer, | 80 virtual int32_t Read(char* buffer, |
| 80 int32_t bytes_to_read, | 81 int32_t bytes_to_read, |
| 81 PP_CompletionCallback callback) OVERRIDE; | 82 PP_CompletionCallback callback) OVERRIDE; |
| 82 virtual int32_t Write(const char* buffer, | 83 virtual int32_t Write(const char* buffer, |
| 83 int32_t bytes_to_write, | 84 int32_t bytes_to_write, |
| 84 PP_CompletionCallback callback) OVERRIDE; | 85 PP_CompletionCallback callback) OVERRIDE; |
| 85 virtual void Disconnect() OVERRIDE; | 86 virtual void Disconnect() OVERRIDE; |
| 86 | 87 |
| 87 // Notifications from the proxy. | 88 // Notifications from the proxy. |
| 88 void OnConnectCompleted(bool succeeded, | 89 void OnConnectCompleted(bool succeeded, |
| 89 const PP_Flash_NetAddress& local_addr, | 90 const PP_Flash_NetAddress& local_addr, |
| 90 const PP_Flash_NetAddress& remote_addr); | 91 const PP_Flash_NetAddress& remote_addr); |
| 92 void OnSSLHandshakeCompleted(bool succeeded); |
| 91 void OnReadCompleted(bool succeeded, const std::string& data); | 93 void OnReadCompleted(bool succeeded, const std::string& data); |
| 92 void OnWriteCompleted(bool succeeded, int32_t bytes_written); | 94 void OnWriteCompleted(bool succeeded, int32_t bytes_written); |
| 93 | 95 |
| 94 private: | 96 private: |
| 95 enum ConnectionState { | 97 enum ConnectionState { |
| 96 // Before a connection is successfully established (including a connect | 98 // Before a connection is successfully established (including a connect |
| 97 // request is pending or a previous connect request failed). | 99 // request is pending or a previous connect request failed). |
| 98 BEFORE_CONNECT, | 100 BEFORE_CONNECT, |
| 101 // A connection has been successfully established (including a request of |
| 102 // initiating SSL is pending). |
| 99 CONNECTED, | 103 CONNECTED, |
| 104 // An SSL connection has been successfully established. |
| 105 SSL_CONNECTED, |
| 106 // The connection has been ended. |
| 100 DISCONNECTED | 107 DISCONNECTED |
| 101 }; | 108 }; |
| 102 | 109 |
| 110 bool IsConnected() const; |
| 111 |
| 103 // Backend for both Connect() and ConnectWithNetAddress(). To keep things | 112 // Backend for both Connect() and ConnectWithNetAddress(). To keep things |
| 104 // generic, the message is passed in (on error, it's deleted). | 113 // generic, the message is passed in (on error, it's deleted). |
| 105 int32_t ConnectWithMessage(IPC::Message* msg, | 114 int32_t ConnectWithMessage(IPC::Message* msg, |
| 106 PP_CompletionCallback callback); | 115 PP_CompletionCallback callback); |
| 107 | 116 |
| 108 void PostAbortAndClearIfNecessary(PP_CompletionCallback* callback); | 117 void PostAbortAndClearIfNecessary(PP_CompletionCallback* callback); |
| 109 | 118 |
| 110 uint32 socket_id_; | 119 uint32 socket_id_; |
| 111 ConnectionState connection_state_; | 120 ConnectionState connection_state_; |
| 112 | 121 |
| 113 PP_CompletionCallback connect_callback_; | 122 PP_CompletionCallback connect_callback_; |
| 123 PP_CompletionCallback ssl_handshake_callback_; |
| 114 PP_CompletionCallback read_callback_; | 124 PP_CompletionCallback read_callback_; |
| 115 PP_CompletionCallback write_callback_; | 125 PP_CompletionCallback write_callback_; |
| 116 | 126 |
| 117 char* read_buffer_; | 127 char* read_buffer_; |
| 118 int32_t bytes_to_read_; | 128 int32_t bytes_to_read_; |
| 119 | 129 |
| 120 PP_Flash_NetAddress local_addr_; | 130 PP_Flash_NetAddress local_addr_; |
| 121 PP_Flash_NetAddress remote_addr_; | 131 PP_Flash_NetAddress remote_addr_; |
| 122 | 132 |
| 123 DISALLOW_COPY_AND_ASSIGN(FlashTCPSocket); | 133 DISALLOW_COPY_AND_ASSIGN(FlashTCPSocket); |
| 124 }; | 134 }; |
| 125 | 135 |
| 126 FlashTCPSocket::FlashTCPSocket(const HostResource& resource, uint32 socket_id) | 136 FlashTCPSocket::FlashTCPSocket(const HostResource& resource, uint32 socket_id) |
| 127 : PluginResource(resource), | 137 : PluginResource(resource), |
| 128 socket_id_(socket_id), | 138 socket_id_(socket_id), |
| 129 connection_state_(BEFORE_CONNECT), | 139 connection_state_(BEFORE_CONNECT), |
| 130 connect_callback_(PP_BlockUntilComplete()), | 140 connect_callback_(PP_BlockUntilComplete()), |
| 141 ssl_handshake_callback_(PP_BlockUntilComplete()), |
| 131 read_callback_(PP_BlockUntilComplete()), | 142 read_callback_(PP_BlockUntilComplete()), |
| 132 write_callback_(PP_BlockUntilComplete()), | 143 write_callback_(PP_BlockUntilComplete()), |
| 133 read_buffer_(NULL), | 144 read_buffer_(NULL), |
| 134 bytes_to_read_(-1) { | 145 bytes_to_read_(-1) { |
| 135 DCHECK(socket_id != 0); | 146 DCHECK(socket_id != 0); |
| 136 | 147 |
| 137 local_addr_.size = 0; | 148 local_addr_.size = 0; |
| 138 memset(local_addr_.data, 0, sizeof(local_addr_.data)); | 149 memset(local_addr_.data, 0, sizeof(local_addr_.data)); |
| 139 remote_addr_.size = 0; | 150 remote_addr_.size = 0; |
| 140 memset(remote_addr_.data, 0, sizeof(remote_addr_.data)); | 151 memset(remote_addr_.data, 0, sizeof(remote_addr_.data)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 170 if (!addr) | 181 if (!addr) |
| 171 return PP_ERROR_BADARGUMENT; | 182 return PP_ERROR_BADARGUMENT; |
| 172 | 183 |
| 173 return ConnectWithMessage( | 184 return ConnectWithMessage( |
| 174 new PpapiHostMsg_PPBFlashTCPSocket_ConnectWithNetAddress( | 185 new PpapiHostMsg_PPBFlashTCPSocket_ConnectWithNetAddress( |
| 175 socket_id_, *addr), | 186 socket_id_, *addr), |
| 176 callback); | 187 callback); |
| 177 } | 188 } |
| 178 | 189 |
| 179 PP_Bool FlashTCPSocket::GetLocalAddress(PP_Flash_NetAddress* local_addr) { | 190 PP_Bool FlashTCPSocket::GetLocalAddress(PP_Flash_NetAddress* local_addr) { |
| 180 if (connection_state_ != CONNECTED || !local_addr) | 191 if (!IsConnected() || !local_addr) |
| 181 return PP_FALSE; | 192 return PP_FALSE; |
| 182 | 193 |
| 183 *local_addr = local_addr_; | 194 *local_addr = local_addr_; |
| 184 return PP_TRUE; | 195 return PP_TRUE; |
| 185 } | 196 } |
| 186 | 197 |
| 187 PP_Bool FlashTCPSocket::GetRemoteAddress(PP_Flash_NetAddress* remote_addr) { | 198 PP_Bool FlashTCPSocket::GetRemoteAddress(PP_Flash_NetAddress* remote_addr) { |
| 188 if (connection_state_ != CONNECTED || !remote_addr) | 199 if (!IsConnected() || !remote_addr) |
| 189 return PP_FALSE; | 200 return PP_FALSE; |
| 190 | 201 |
| 191 *remote_addr = remote_addr_; | 202 *remote_addr = remote_addr_; |
| 192 return PP_TRUE; | 203 return PP_TRUE; |
| 193 } | 204 } |
| 194 | 205 |
| 195 int32_t FlashTCPSocket::InitiateSSL(const char* server_name, | 206 int32_t FlashTCPSocket::SSLHandshake(const char* server_name, |
| 196 PP_CompletionCallback callback) { | 207 uint16_t server_port, |
| 197 // TODO(yzshen): add it. | 208 PP_CompletionCallback callback) { |
| 198 return PP_ERROR_FAILED; | 209 if (!server_name || !callback.func) |
| 210 return PP_ERROR_BADARGUMENT; |
| 211 |
| 212 if (connection_state_ != CONNECTED) |
| 213 return PP_ERROR_FAILED; |
| 214 if (ssl_handshake_callback_.func || read_callback_.func || |
| 215 write_callback_.func) |
| 216 return PP_ERROR_INPROGRESS; |
| 217 |
| 218 ssl_handshake_callback_ = callback; |
| 219 |
| 220 // Send the request, the browser will call us back via SSLHandshakeACK. |
| 221 GetDispatcher()->SendToBrowser( |
| 222 new PpapiHostMsg_PPBFlashTCPSocket_SSLHandshake( |
| 223 socket_id_, std::string(server_name), server_port)); |
| 224 return PP_OK_COMPLETIONPENDING; |
| 199 } | 225 } |
| 200 | 226 |
| 201 int32_t FlashTCPSocket::Read(char* buffer, | 227 int32_t FlashTCPSocket::Read(char* buffer, |
| 202 int32_t bytes_to_read, | 228 int32_t bytes_to_read, |
| 203 PP_CompletionCallback callback) { | 229 PP_CompletionCallback callback) { |
| 204 if (!buffer || bytes_to_read <= 0 || !callback.func) | 230 if (!buffer || bytes_to_read <= 0 || !callback.func) |
| 205 return PP_ERROR_BADARGUMENT; | 231 return PP_ERROR_BADARGUMENT; |
| 206 | 232 |
| 207 if (connection_state_ != CONNECTED) | 233 if (!IsConnected()) |
| 208 return PP_ERROR_FAILED; | 234 return PP_ERROR_FAILED; |
| 209 if (read_callback_.func) | 235 if (read_callback_.func || ssl_handshake_callback_.func) |
| 210 return PP_ERROR_INPROGRESS; | 236 return PP_ERROR_INPROGRESS; |
| 211 | 237 |
| 212 read_buffer_ = buffer; | 238 read_buffer_ = buffer; |
| 213 bytes_to_read_ = std::min(bytes_to_read, kFlashTCPSocketMaxReadSize); | 239 bytes_to_read_ = std::min(bytes_to_read, kFlashTCPSocketMaxReadSize); |
| 214 read_callback_ = callback; | 240 read_callback_ = callback; |
| 215 | 241 |
| 216 // Send the request, the browser will call us back via ReadACK. | 242 // Send the request, the browser will call us back via ReadACK. |
| 217 GetDispatcher()->SendToBrowser( | 243 GetDispatcher()->SendToBrowser( |
| 218 new PpapiHostMsg_PPBFlashTCPSocket_Read(socket_id_, bytes_to_read_)); | 244 new PpapiHostMsg_PPBFlashTCPSocket_Read(socket_id_, bytes_to_read_)); |
| 219 return PP_OK_COMPLETIONPENDING; | 245 return PP_OK_COMPLETIONPENDING; |
| 220 } | 246 } |
| 221 | 247 |
| 222 int32_t FlashTCPSocket::Write(const char* buffer, | 248 int32_t FlashTCPSocket::Write(const char* buffer, |
| 223 int32_t bytes_to_write, | 249 int32_t bytes_to_write, |
| 224 PP_CompletionCallback callback) { | 250 PP_CompletionCallback callback) { |
| 225 if (!buffer || bytes_to_write <= 0 || !callback.func) | 251 if (!buffer || bytes_to_write <= 0 || !callback.func) |
| 226 return PP_ERROR_BADARGUMENT; | 252 return PP_ERROR_BADARGUMENT; |
| 227 | 253 |
| 228 if (connection_state_ != CONNECTED) | 254 if (!IsConnected()) |
| 229 return PP_ERROR_FAILED; | 255 return PP_ERROR_FAILED; |
| 230 if (write_callback_.func) | 256 if (write_callback_.func || ssl_handshake_callback_.func) |
| 231 return PP_ERROR_INPROGRESS; | 257 return PP_ERROR_INPROGRESS; |
| 232 | 258 |
| 233 if (bytes_to_write > kFlashTCPSocketMaxWriteSize) | 259 if (bytes_to_write > kFlashTCPSocketMaxWriteSize) |
| 234 bytes_to_write = kFlashTCPSocketMaxWriteSize; | 260 bytes_to_write = kFlashTCPSocketMaxWriteSize; |
| 235 | 261 |
| 236 write_callback_ = callback; | 262 write_callback_ = callback; |
| 237 | 263 |
| 238 // Send the request, the browser will call us back via WriteACK. | 264 // Send the request, the browser will call us back via WriteACK. |
| 239 GetDispatcher()->SendToBrowser( | 265 GetDispatcher()->SendToBrowser( |
| 240 new PpapiHostMsg_PPBFlashTCPSocket_Write( | 266 new PpapiHostMsg_PPBFlashTCPSocket_Write( |
| 241 socket_id_, std::string(buffer, bytes_to_write))); | 267 socket_id_, std::string(buffer, bytes_to_write))); |
| 242 return PP_OK_COMPLETIONPENDING; | 268 return PP_OK_COMPLETIONPENDING; |
| 243 } | 269 } |
| 244 | 270 |
| 245 void FlashTCPSocket::Disconnect() { | 271 void FlashTCPSocket::Disconnect() { |
| 246 if (connection_state_ == DISCONNECTED) | 272 if (connection_state_ == DISCONNECTED) |
| 247 return; | 273 return; |
| 248 | 274 |
| 249 connection_state_ = DISCONNECTED; | 275 connection_state_ = DISCONNECTED; |
| 250 // After removed from the mapping, this object won't receive any notfications | 276 // After removed from the mapping, this object won't receive any notifications |
| 251 // from the proxy. | 277 // from the proxy. |
| 252 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); | 278 DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); |
| 253 g_id_to_socket->erase(socket_id_); | 279 g_id_to_socket->erase(socket_id_); |
| 254 | 280 |
| 255 GetDispatcher()->SendToBrowser( | 281 GetDispatcher()->SendToBrowser( |
| 256 new PpapiHostMsg_PPBFlashTCPSocket_Disconnect(socket_id_)); | 282 new PpapiHostMsg_PPBFlashTCPSocket_Disconnect(socket_id_)); |
| 257 socket_id_ = 0; | 283 socket_id_ = 0; |
| 258 | 284 |
| 259 PostAbortAndClearIfNecessary(&connect_callback_); | 285 PostAbortAndClearIfNecessary(&connect_callback_); |
| 286 PostAbortAndClearIfNecessary(&ssl_handshake_callback_); |
| 260 PostAbortAndClearIfNecessary(&read_callback_); | 287 PostAbortAndClearIfNecessary(&read_callback_); |
| 261 PostAbortAndClearIfNecessary(&write_callback_); | 288 PostAbortAndClearIfNecessary(&write_callback_); |
| 262 read_buffer_ = NULL; | 289 read_buffer_ = NULL; |
| 263 bytes_to_read_ = -1; | 290 bytes_to_read_ = -1; |
| 264 } | 291 } |
| 265 | 292 |
| 266 void FlashTCPSocket::OnConnectCompleted( | 293 void FlashTCPSocket::OnConnectCompleted( |
| 267 bool succeeded, | 294 bool succeeded, |
| 268 const PP_Flash_NetAddress& local_addr, | 295 const PP_Flash_NetAddress& local_addr, |
| 269 const PP_Flash_NetAddress& remote_addr) { | 296 const PP_Flash_NetAddress& remote_addr) { |
| 270 if (connection_state_ != BEFORE_CONNECT || !connect_callback_.func) { | 297 if (connection_state_ != BEFORE_CONNECT || !connect_callback_.func) { |
| 271 NOTREACHED(); | 298 NOTREACHED(); |
| 272 return; | 299 return; |
| 273 } | 300 } |
| 274 | 301 |
| 275 if (succeeded) { | 302 if (succeeded) { |
| 276 local_addr_ = local_addr; | 303 local_addr_ = local_addr; |
| 277 remote_addr_ = remote_addr; | 304 remote_addr_ = remote_addr; |
| 278 connection_state_ = CONNECTED; | 305 connection_state_ = CONNECTED; |
| 279 } | 306 } |
| 280 PP_RunAndClearCompletionCallback(&connect_callback_, | 307 PP_RunAndClearCompletionCallback(&connect_callback_, |
| 281 succeeded ? PP_OK : PP_ERROR_FAILED); | 308 succeeded ? PP_OK : PP_ERROR_FAILED); |
| 282 } | 309 } |
| 283 | 310 |
| 311 void FlashTCPSocket::OnSSLHandshakeCompleted(bool succeeded) { |
| 312 if (connection_state_ != CONNECTED || !ssl_handshake_callback_.func) { |
| 313 NOTREACHED(); |
| 314 return; |
| 315 } |
| 316 |
| 317 if (succeeded) { |
| 318 connection_state_ = SSL_CONNECTED; |
| 319 PP_RunAndClearCompletionCallback(&ssl_handshake_callback_, PP_OK); |
| 320 } else { |
| 321 PP_RunAndClearCompletionCallback(&ssl_handshake_callback_, PP_ERROR_FAILED); |
| 322 Disconnect(); |
| 323 } |
| 324 } |
| 325 |
| 284 void FlashTCPSocket::OnReadCompleted(bool succeeded, const std::string& data) { | 326 void FlashTCPSocket::OnReadCompleted(bool succeeded, const std::string& data) { |
| 285 if (!read_callback_.func || !read_buffer_) { | 327 if (!read_callback_.func || !read_buffer_) { |
| 286 NOTREACHED(); | 328 NOTREACHED(); |
| 287 return; | 329 return; |
| 288 } | 330 } |
| 289 | 331 |
| 290 if (succeeded) { | 332 if (succeeded) { |
| 291 CHECK_LE(static_cast<int32_t>(data.size()), bytes_to_read_); | 333 CHECK_LE(static_cast<int32_t>(data.size()), bytes_to_read_); |
| 292 if (!data.empty()) | 334 if (!data.empty()) |
| 293 memcpy(read_buffer_, data.c_str(), data.size()); | 335 memcpy(read_buffer_, data.c_str(), data.size()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 305 if (!write_callback_.func || (succeeded && bytes_written < 0)) { | 347 if (!write_callback_.func || (succeeded && bytes_written < 0)) { |
| 306 NOTREACHED(); | 348 NOTREACHED(); |
| 307 return; | 349 return; |
| 308 } | 350 } |
| 309 | 351 |
| 310 PP_RunAndClearCompletionCallback( | 352 PP_RunAndClearCompletionCallback( |
| 311 &write_callback_, | 353 &write_callback_, |
| 312 succeeded ? bytes_written : static_cast<int32_t>(PP_ERROR_FAILED)); | 354 succeeded ? bytes_written : static_cast<int32_t>(PP_ERROR_FAILED)); |
| 313 } | 355 } |
| 314 | 356 |
| 357 bool FlashTCPSocket::IsConnected() const { |
| 358 return connection_state_ == CONNECTED || connection_state_ == SSL_CONNECTED; |
| 359 } |
| 360 |
| 315 int32_t FlashTCPSocket::ConnectWithMessage(IPC::Message* msg, | 361 int32_t FlashTCPSocket::ConnectWithMessage(IPC::Message* msg, |
| 316 PP_CompletionCallback callback) { | 362 PP_CompletionCallback callback) { |
| 317 scoped_ptr<IPC::Message> msg_deletor(msg); | 363 scoped_ptr<IPC::Message> msg_deletor(msg); |
| 318 if (!callback.func) | 364 if (!callback.func) |
| 319 return PP_ERROR_BADARGUMENT; | 365 return PP_ERROR_BADARGUMENT; |
| 320 if (connection_state_ != BEFORE_CONNECT) | 366 if (connection_state_ != BEFORE_CONNECT) |
| 321 return PP_ERROR_FAILED; | 367 return PP_ERROR_FAILED; |
| 322 if (connect_callback_.func) | 368 if (connect_callback_.func) |
| 323 return PP_ERROR_INPROGRESS; // Can only have one pending request. | 369 return PP_ERROR_INPROGRESS; // Can only have one pending request. |
| 324 | 370 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 return 0; | 421 return 0; |
| 376 | 422 |
| 377 return PluginResourceTracker::GetInstance()->AddResource( | 423 return PluginResourceTracker::GetInstance()->AddResource( |
| 378 new FlashTCPSocket(HostResource::MakeInstanceOnly(instance), socket_id)); | 424 new FlashTCPSocket(HostResource::MakeInstanceOnly(instance), socket_id)); |
| 379 } | 425 } |
| 380 | 426 |
| 381 bool PPB_Flash_TCPSocket_Proxy::OnMessageReceived(const IPC::Message& msg) { | 427 bool PPB_Flash_TCPSocket_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 382 bool handled = true; | 428 bool handled = true; |
| 383 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_TCPSocket_Proxy, msg) | 429 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_TCPSocket_Proxy, msg) |
| 384 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_ConnectACK, OnMsgConnectACK) | 430 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_ConnectACK, OnMsgConnectACK) |
| 431 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_SSLHandshakeACK, |
| 432 OnMsgSSLHandshakeACK) |
| 385 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_ReadACK, OnMsgReadACK) | 433 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_ReadACK, OnMsgReadACK) |
| 386 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_WriteACK, OnMsgWriteACK) | 434 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_WriteACK, OnMsgWriteACK) |
| 387 IPC_MESSAGE_UNHANDLED(handled = false) | 435 IPC_MESSAGE_UNHANDLED(handled = false) |
| 388 IPC_END_MESSAGE_MAP() | 436 IPC_END_MESSAGE_MAP() |
| 389 return handled; | 437 return handled; |
| 390 } | 438 } |
| 391 | 439 |
| 392 void PPB_Flash_TCPSocket_Proxy::OnMsgConnectACK( | 440 void PPB_Flash_TCPSocket_Proxy::OnMsgConnectACK( |
| 393 uint32 /* plugin_dispatcher_id */, | 441 uint32 /* plugin_dispatcher_id */, |
| 394 uint32 socket_id, | 442 uint32 socket_id, |
| 395 bool succeeded, | 443 bool succeeded, |
| 396 const PP_Flash_NetAddress& local_addr, | 444 const PP_Flash_NetAddress& local_addr, |
| 397 const PP_Flash_NetAddress& remote_addr) { | 445 const PP_Flash_NetAddress& remote_addr) { |
| 398 if (!g_id_to_socket) { | 446 if (!g_id_to_socket) { |
| 399 NOTREACHED(); | 447 NOTREACHED(); |
| 400 return; | 448 return; |
| 401 } | 449 } |
| 402 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | 450 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
| 403 if (iter == g_id_to_socket->end()) | 451 if (iter == g_id_to_socket->end()) |
| 404 return; | 452 return; |
| 405 iter->second->OnConnectCompleted(succeeded, local_addr, remote_addr); | 453 iter->second->OnConnectCompleted(succeeded, local_addr, remote_addr); |
| 406 } | 454 } |
| 407 | 455 |
| 456 void PPB_Flash_TCPSocket_Proxy::OnMsgSSLHandshakeACK( |
| 457 uint32 /* plugin_dispatcher_id */, |
| 458 uint32 socket_id, |
| 459 bool succeeded) { |
| 460 if (!g_id_to_socket) { |
| 461 NOTREACHED(); |
| 462 return; |
| 463 } |
| 464 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
| 465 if (iter == g_id_to_socket->end()) |
| 466 return; |
| 467 iter->second->OnSSLHandshakeCompleted(succeeded); |
| 468 } |
| 469 |
| 408 void PPB_Flash_TCPSocket_Proxy::OnMsgReadACK(uint32 /* plugin_dispatcher_id */, | 470 void PPB_Flash_TCPSocket_Proxy::OnMsgReadACK(uint32 /* plugin_dispatcher_id */, |
| 409 uint32 socket_id, | 471 uint32 socket_id, |
| 410 bool succeeded, | 472 bool succeeded, |
| 411 const std::string& data) { | 473 const std::string& data) { |
| 412 if (!g_id_to_socket) { | 474 if (!g_id_to_socket) { |
| 413 NOTREACHED(); | 475 NOTREACHED(); |
| 414 return; | 476 return; |
| 415 } | 477 } |
| 416 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | 478 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
| 417 if (iter == g_id_to_socket->end()) | 479 if (iter == g_id_to_socket->end()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 428 return; | 490 return; |
| 429 } | 491 } |
| 430 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); | 492 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); |
| 431 if (iter == g_id_to_socket->end()) | 493 if (iter == g_id_to_socket->end()) |
| 432 return; | 494 return; |
| 433 iter->second->OnWriteCompleted(succeeded, bytes_written); | 495 iter->second->OnWriteCompleted(succeeded, bytes_written); |
| 434 } | 496 } |
| 435 | 497 |
| 436 } // namespace proxy | 498 } // namespace proxy |
| 437 } // namespace pp | 499 } // namespace pp |
| OLD | NEW |