OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ppapi/cpp/private/tcp_server_socket_private.h" |
| 6 |
| 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/cpp/completion_callback.h" |
| 9 #include "ppapi/cpp/instance_handle.h" |
| 10 #include "ppapi/cpp/module.h" |
| 11 #include "ppapi/cpp/module_impl.h" |
| 12 |
| 13 namespace pp { |
| 14 |
| 15 namespace { |
| 16 |
| 17 template <> const char* interface_name<PPB_TCPServerSocket_Private>() { |
| 18 return PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE; |
| 19 } |
| 20 |
| 21 } // namespace |
| 22 |
| 23 TCPServerSocketPrivate::TCPServerSocketPrivate(const InstanceHandle& instance) { |
| 24 if (has_interface<PPB_TCPServerSocket_Private>()) { |
| 25 PassRefFromConstructor(get_interface<PPB_TCPServerSocket_Private>()->Create( |
| 26 instance.pp_instance())); |
| 27 } |
| 28 } |
| 29 |
| 30 // static |
| 31 bool TCPServerSocketPrivate::IsAvailable() { |
| 32 return has_interface<PPB_TCPServerSocket_Private>(); |
| 33 } |
| 34 |
| 35 int32_t TCPServerSocketPrivate::Listen(const PP_NetAddress_Private* addr, |
| 36 int32_t backlog, |
| 37 const CompletionCallback& callback) { |
| 38 if (!has_interface<PPB_TCPServerSocket_Private>()) |
| 39 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 40 return get_interface<PPB_TCPServerSocket_Private>()->Listen( |
| 41 pp_resource(), addr, backlog, callback.pp_completion_callback()); |
| 42 } |
| 43 |
| 44 int32_t TCPServerSocketPrivate::Accept(PP_Resource* tcp_socket, |
| 45 const CompletionCallback& callback) { |
| 46 if (!has_interface<PPB_TCPServerSocket_Private>()) |
| 47 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 48 return get_interface<PPB_TCPServerSocket_Private>()->Accept( |
| 49 pp_resource(), tcp_socket, callback.pp_completion_callback()); |
| 50 } |
| 51 |
| 52 void TCPServerSocketPrivate::StopListening() { |
| 53 if (!has_interface<PPB_TCPServerSocket_Private>()) |
| 54 return; |
| 55 return get_interface<PPB_TCPServerSocket_Private>()->StopListening( |
| 56 pp_resource()); |
| 57 } |
| 58 |
| 59 } // namespace pp |
OLD | NEW |