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_handle.h" | 10 #include "ppapi/cpp/instance_handle.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 TCPSocketPrivate::TCPSocketPrivate(const InstanceHandle& instance) { | 24 TCPSocketPrivate::TCPSocketPrivate(const InstanceHandle& instance) { |
25 if (has_interface<PPB_TCPSocket_Private>()) { | 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 TCPSocketPrivate::TCPSocketPrivate(PassRef, PP_Resource resource) |
| 32 : Resource(PASS_REF, resource) { |
| 33 } |
| 34 |
31 // static | 35 // static |
32 bool TCPSocketPrivate::IsAvailable() { | 36 bool TCPSocketPrivate::IsAvailable() { |
33 return has_interface<PPB_TCPSocket_Private>(); | 37 return has_interface<PPB_TCPSocket_Private>(); |
34 } | 38 } |
35 | 39 |
36 int32_t TCPSocketPrivate::Connect(const char* host, | 40 int32_t TCPSocketPrivate::Connect(const char* host, |
37 uint16_t port, | 41 uint16_t port, |
38 const CompletionCallback& callback) { | 42 const CompletionCallback& callback) { |
39 if (!has_interface<PPB_TCPSocket_Private>()) | 43 if (!has_interface<PPB_TCPSocket_Private>()) |
40 return callback.MayForce(PP_ERROR_NOINTERFACE); | 44 return callback.MayForce(PP_ERROR_NOINTERFACE); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback()); | 100 pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback()); |
97 } | 101 } |
98 | 102 |
99 void TCPSocketPrivate::Disconnect() { | 103 void TCPSocketPrivate::Disconnect() { |
100 if (!has_interface<PPB_TCPSocket_Private>()) | 104 if (!has_interface<PPB_TCPSocket_Private>()) |
101 return; | 105 return; |
102 return get_interface<PPB_TCPSocket_Private>()->Disconnect(pp_resource()); | 106 return get_interface<PPB_TCPSocket_Private>()->Disconnect(pp_resource()); |
103 } | 107 } |
104 | 108 |
105 } // namespace pp | 109 } // namespace pp |
OLD | NEW |