| 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/udp_socket_private.h" | 5 #include "ppapi/cpp/private/udp_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.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 int32_t UDPSocketPrivate::Bind(const PP_NetAddress_Private* addr, | 31 int32_t UDPSocketPrivate::Bind(const PP_NetAddress_Private* addr, |
| 32 const CompletionCallback& callback) { | 32 const CompletionCallback& callback) { |
| 33 if (!has_interface<PPB_UDPSocket_Private>()) | 33 if (!has_interface<PPB_UDPSocket_Private>()) |
| 34 return PP_ERROR_NOINTERFACE; | 34 return PP_ERROR_NOINTERFACE; |
| 35 return get_interface<PPB_UDPSocket_Private>()->Bind( | 35 return get_interface<PPB_UDPSocket_Private>()->Bind( |
| 36 pp_resource(), addr, callback.pp_completion_callback()); | 36 pp_resource(), addr, callback.pp_completion_callback()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool UDPSocketPrivate::GetBoundAddress(PP_NetAddress_Private* addr) { |
| 40 if (!has_interface<PPB_UDPSocket_Private>()) |
| 41 return false; |
| 42 |
| 43 PP_Bool result = get_interface<PPB_UDPSocket_Private>()->GetBoundAddress( |
| 44 pp_resource(), addr); |
| 45 return PP_ToBool(result); |
| 46 } |
| 47 |
| 39 int32_t UDPSocketPrivate::RecvFrom(char* buffer, | 48 int32_t UDPSocketPrivate::RecvFrom(char* buffer, |
| 40 int32_t num_bytes, | 49 int32_t num_bytes, |
| 41 const CompletionCallback& callback) { | 50 const CompletionCallback& callback) { |
| 42 if (!has_interface<PPB_UDPSocket_Private>()) | 51 if (!has_interface<PPB_UDPSocket_Private>()) |
| 43 return PP_ERROR_NOINTERFACE; | 52 return PP_ERROR_NOINTERFACE; |
| 44 return get_interface<PPB_UDPSocket_Private>()->RecvFrom( | 53 return get_interface<PPB_UDPSocket_Private>()->RecvFrom( |
| 45 pp_resource(), buffer, num_bytes, callback.pp_completion_callback()); | 54 pp_resource(), buffer, num_bytes, callback.pp_completion_callback()); |
| 46 } | 55 } |
| 47 | 56 |
| 48 bool UDPSocketPrivate::GetRecvFromAddress(PP_NetAddress_Private* addr) { | 57 bool UDPSocketPrivate::GetRecvFromAddress(PP_NetAddress_Private* addr) { |
| 49 if (!has_interface<PPB_UDPSocket_Private>()) | 58 if (!has_interface<PPB_UDPSocket_Private>()) |
| 50 return false; | 59 return false; |
| 51 | 60 |
| 52 PP_Bool result = get_interface<PPB_UDPSocket_Private>()->GetRecvFromAddress( | 61 PP_Bool result = get_interface<PPB_UDPSocket_Private>()->GetRecvFromAddress( |
| 53 pp_resource(), addr); | 62 pp_resource(), addr); |
| 54 return PP_ToBool(result); | 63 return PP_ToBool(result); |
| 55 } | 64 } |
| 56 | 65 |
| 57 int32_t UDPSocketPrivate::SendTo(const char* buffer, | 66 int32_t UDPSocketPrivate::SendTo(const char* buffer, |
| 58 int32_t num_bytes, | 67 int32_t num_bytes, |
| 59 const PP_NetAddress_Private* addr, | 68 const PP_NetAddress_Private* addr, |
| 60 const CompletionCallback& callback) { | 69 const CompletionCallback& callback) { |
| 61 if (!has_interface<PPB_UDPSocket_Private>()) | 70 if (!has_interface<PPB_UDPSocket_Private>()) |
| 62 return PP_ERROR_NOINTERFACE; | 71 return PP_ERROR_NOINTERFACE; |
| 63 return get_interface<PPB_UDPSocket_Private>()->SendTo( | 72 return get_interface<PPB_UDPSocket_Private>()->SendTo( |
| 64 pp_resource(), buffer, num_bytes, addr, | 73 pp_resource(), buffer, num_bytes, addr, |
| 65 callback.pp_completion_callback()); | 74 callback.pp_completion_callback()); |
| 66 } | 75 } |
| 67 | 76 |
| 77 void UDPSocketPrivate::Close() { |
| 78 if (!has_interface<PPB_UDPSocket_Private>()) |
| 79 return; |
| 80 return get_interface<PPB_UDPSocket_Private>()->Close(pp_resource()); |
| 81 } |
| 68 } // namespace pp | 82 } // namespace pp |
| 69 | 83 |
| OLD | NEW |