| 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 #ifndef PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ |
| 6 #define PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ | 6 #define PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | |
| 11 | 10 |
| 12 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "net/base/ip_address.h" |
| 13 #include "ppapi/c/pp_stdint.h" | 13 #include "ppapi/c/pp_stdint.h" |
| 14 #include "ppapi/c/ppb_net_address.h" | 14 #include "ppapi/c/ppb_net_address.h" |
| 15 #include "ppapi/shared_impl/ppapi_shared_export.h" | 15 #include "ppapi/shared_impl/ppapi_shared_export.h" |
| 16 | 16 |
| 17 struct PP_NetAddress_Private; | 17 struct PP_NetAddress_Private; |
| 18 struct sockaddr; | 18 struct sockaddr; |
| 19 | 19 |
| 20 namespace ppapi { | 20 namespace ppapi { |
| 21 | 21 |
| 22 class PPAPI_SHARED_EXPORT NetAddressPrivateImpl { | 22 class PPAPI_SHARED_EXPORT NetAddressPrivateImpl { |
| 23 public: | 23 public: |
| 24 static bool ValidateNetAddress(const PP_NetAddress_Private& addr); | 24 static bool ValidateNetAddress(const PP_NetAddress_Private& addr); |
| 25 | 25 |
| 26 static bool SockaddrToNetAddress(const sockaddr* sa, | 26 static bool SockaddrToNetAddress(const sockaddr* sa, |
| 27 uint32_t sa_length, | 27 uint32_t sa_length, |
| 28 PP_NetAddress_Private* net_addr); | 28 PP_NetAddress_Private* net_addr); |
| 29 | 29 |
| 30 static bool IPEndPointToNetAddress(const std::vector<uint8_t>& address, | 30 static bool IPEndPointToNetAddress( |
| 31 uint16_t port, | 31 const net::IPAddress::IPAddressBytes& address, |
| 32 PP_NetAddress_Private* net_addr); | 32 uint16_t port, |
| 33 PP_NetAddress_Private* net_addr); |
| 33 | 34 |
| 34 static bool NetAddressToIPEndPoint(const PP_NetAddress_Private& net_addr, | 35 static bool NetAddressToIPEndPoint(const PP_NetAddress_Private& net_addr, |
| 35 std::vector<uint8_t>* address, | 36 net::IPAddress::IPAddressBytes* address, |
| 36 uint16_t* port); | 37 uint16_t* port); |
| 37 | 38 |
| 38 static std::string DescribeNetAddress(const PP_NetAddress_Private& addr, | 39 static std::string DescribeNetAddress(const PP_NetAddress_Private& addr, |
| 39 bool include_port); | 40 bool include_port); |
| 40 | 41 |
| 41 static void GetAnyAddress(PP_Bool is_ipv6, PP_NetAddress_Private* addr); | 42 static void GetAnyAddress(PP_Bool is_ipv6, PP_NetAddress_Private* addr); |
| 42 | 43 |
| 43 // Conversion methods to make PPB_NetAddress resource work with | 44 // Conversion methods to make PPB_NetAddress resource work with |
| 44 // PP_NetAddress_Private. | 45 // PP_NetAddress_Private. |
| 45 // TODO(yzshen): Remove them once PPB_NetAddress resource doesn't use | 46 // TODO(yzshen): Remove them once PPB_NetAddress resource doesn't use |
| (...skipping 15 matching lines...) Expand all Loading... |
| 61 | 62 |
| 62 static const PP_NetAddress_Private kInvalidNetAddress; | 63 static const PP_NetAddress_Private kInvalidNetAddress; |
| 63 | 64 |
| 64 private: | 65 private: |
| 65 DISALLOW_IMPLICIT_CONSTRUCTORS(NetAddressPrivateImpl); | 66 DISALLOW_IMPLICIT_CONSTRUCTORS(NetAddressPrivateImpl); |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 } // namespace ppapi | 69 } // namespace ppapi |
| 69 | 70 |
| 70 #endif // PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ | 71 #endif // PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_ |
| OLD | NEW |