| 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 // TODO(yzshen): See the comment in corresponding .h file. | 5 // TODO(yzshen): See the comment in corresponding .h file. |
| 6 | 6 |
| 7 #include "ppapi/cpp/private/flash_tcp_socket.h" | 7 #include "ppapi/cpp/private/flash_tcp_socket.h" |
| 8 | 8 |
| 9 #include "ppapi/c/pp_bool.h" | 9 #include "ppapi/c/pp_bool.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool TCPSocket::GetRemoteAddress(PP_Flash_NetAddress* remote_addr) { | 61 bool TCPSocket::GetRemoteAddress(PP_Flash_NetAddress* remote_addr) { |
| 62 if (!has_interface<PPB_Flash_TCPSocket>()) | 62 if (!has_interface<PPB_Flash_TCPSocket>()) |
| 63 return false; | 63 return false; |
| 64 PP_Bool result = get_interface<PPB_Flash_TCPSocket>()->GetRemoteAddress( | 64 PP_Bool result = get_interface<PPB_Flash_TCPSocket>()->GetRemoteAddress( |
| 65 pp_resource(), remote_addr); | 65 pp_resource(), remote_addr); |
| 66 return PP_ToBool(result); | 66 return PP_ToBool(result); |
| 67 } | 67 } |
| 68 | 68 |
| 69 int32_t TCPSocket::InitiateSSL(const char* server_name, | 69 int32_t TCPSocket::SSLHandshake(const char* host, |
| 70 const CompletionCallback& callback) { | 70 uint16_t port, |
| 71 const CompletionCallback& callback) { |
| 71 if (!has_interface<PPB_Flash_TCPSocket>()) | 72 if (!has_interface<PPB_Flash_TCPSocket>()) |
| 72 return callback.MayForce(PP_ERROR_NOINTERFACE); | 73 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 73 return get_interface<PPB_Flash_TCPSocket>()->InitiateSSL( | 74 return get_interface<PPB_Flash_TCPSocket>()->SSLHandshake( |
| 74 pp_resource(), server_name, callback.pp_completion_callback()); | 75 pp_resource(), host, port, callback.pp_completion_callback()); |
| 75 } | 76 } |
| 76 | 77 |
| 77 int32_t TCPSocket::Read(char* buffer, | 78 int32_t TCPSocket::Read(char* buffer, |
| 78 int32_t bytes_to_read, | 79 int32_t bytes_to_read, |
| 79 const CompletionCallback& callback) { | 80 const CompletionCallback& callback) { |
| 80 if (!has_interface<PPB_Flash_TCPSocket>()) | 81 if (!has_interface<PPB_Flash_TCPSocket>()) |
| 81 return callback.MayForce(PP_ERROR_NOINTERFACE); | 82 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 82 return get_interface<PPB_Flash_TCPSocket>()->Read( | 83 return get_interface<PPB_Flash_TCPSocket>()->Read( |
| 83 pp_resource(), buffer, bytes_to_read, callback.pp_completion_callback()); | 84 pp_resource(), buffer, bytes_to_read, callback.pp_completion_callback()); |
| 84 } | 85 } |
| 85 | 86 |
| 86 int32_t TCPSocket::Write(const char* buffer, | 87 int32_t TCPSocket::Write(const char* buffer, |
| 87 int32_t bytes_to_write, | 88 int32_t bytes_to_write, |
| 88 const CompletionCallback& callback) { | 89 const CompletionCallback& callback) { |
| 89 if (!has_interface<PPB_Flash_TCPSocket>()) | 90 if (!has_interface<PPB_Flash_TCPSocket>()) |
| 90 return callback.MayForce(PP_ERROR_NOINTERFACE); | 91 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 91 return get_interface<PPB_Flash_TCPSocket>()->Write( | 92 return get_interface<PPB_Flash_TCPSocket>()->Write( |
| 92 pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback()); | 93 pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void TCPSocket::Disconnect() { | 96 void TCPSocket::Disconnect() { |
| 96 if (!has_interface<PPB_Flash_TCPSocket>()) | 97 if (!has_interface<PPB_Flash_TCPSocket>()) |
| 97 return; | 98 return; |
| 98 return get_interface<PPB_Flash_TCPSocket>()->Disconnect(pp_resource()); | 99 return get_interface<PPB_Flash_TCPSocket>()->Disconnect(pp_resource()); |
| 99 } | 100 } |
| 100 | 101 |
| 101 } // namespace flash | 102 } // namespace flash |
| 102 } // namespace pp | 103 } // namespace pp |
| OLD | NEW |