| 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/cpp/private/tcp_socket_private.h" | 5 #include "ppapi/cpp/private/tcp_socket_private.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_bool.h" | 7 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
| 10 #include "ppapi/cpp/instance.h" | 10 #include "ppapi/cpp/instance_handle.h" |
| 11 #include "ppapi/cpp/module.h" | 11 #include "ppapi/cpp/module.h" |
| 12 #include "ppapi/cpp/module_impl.h" | 12 #include "ppapi/cpp/module_impl.h" |
| 13 | 13 |
| 14 namespace pp { | 14 namespace pp { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 template <> const char* interface_name<PPB_TCPSocket_Private>() { | 18 template <> const char* interface_name<PPB_TCPSocket_Private>() { |
| 19 return PPB_TCPSOCKET_PRIVATE_INTERFACE; | 19 return PPB_TCPSOCKET_PRIVATE_INTERFACE; |
| 20 } | 20 } |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 TCPSocketPrivate::TCPSocketPrivate(Instance* instance) { | 24 TCPSocketPrivate::TCPSocketPrivate(const InstanceHandle& instance) { |
| 25 if (has_interface<PPB_TCPSocket_Private>() && instance) { | 25 if (has_interface<PPB_TCPSocket_Private>()) { |
| 26 PassRefFromConstructor(get_interface<PPB_TCPSocket_Private>()->Create( | 26 PassRefFromConstructor(get_interface<PPB_TCPSocket_Private>()->Create( |
| 27 instance->pp_instance())); | 27 instance.pp_instance())); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 bool TCPSocketPrivate::IsAvailable() { | 32 bool TCPSocketPrivate::IsAvailable() { |
| 33 return has_interface<PPB_TCPSocket_Private>(); | 33 return has_interface<PPB_TCPSocket_Private>(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 int32_t TCPSocketPrivate::Connect(const char* host, | 36 int32_t TCPSocketPrivate::Connect(const char* host, |
| 37 uint16_t port, | 37 uint16_t port, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback()); | 96 pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void TCPSocketPrivate::Disconnect() { | 99 void TCPSocketPrivate::Disconnect() { |
| 100 if (!has_interface<PPB_TCPSocket_Private>()) | 100 if (!has_interface<PPB_TCPSocket_Private>()) |
| 101 return; | 101 return; |
| 102 return get_interface<PPB_TCPSocket_Private>()->Disconnect(pp_resource()); | 102 return get_interface<PPB_TCPSocket_Private>()->Disconnect(pp_resource()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace pp | 105 } // namespace pp |
| OLD | NEW |