Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ppapi / shared_impl / private / net_address_private_impl.h
bloba8ba0592956bfe58c7b9c65f3fdac9e63dc0f532
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
3 // found in the LICENSE file.
5 #ifndef PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_
6 #define PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "ppapi/c/pp_stdint.h"
13 #include "ppapi/c/ppb_net_address.h"
14 #include "ppapi/shared_impl/ppapi_shared_export.h"
16 struct PP_NetAddress_Private;
17 struct sockaddr;
19 namespace ppapi {
21 class PPAPI_SHARED_EXPORT NetAddressPrivateImpl {
22 public:
23 static bool ValidateNetAddress(const PP_NetAddress_Private& addr);
25 static bool SockaddrToNetAddress(const sockaddr* sa,
26 uint32_t sa_length,
27 PP_NetAddress_Private* net_addr);
29 static bool IPEndPointToNetAddress(const std::vector<unsigned char>& address,
30 int port,
31 PP_NetAddress_Private* net_addr);
33 static bool NetAddressToIPEndPoint(const PP_NetAddress_Private& net_addr,
34 std::vector<unsigned char>* address,
35 int* port);
37 static std::string DescribeNetAddress(const PP_NetAddress_Private& addr,
38 bool include_port);
40 // Conversion methods to make PPB_NetAddress resource work with
41 // PP_NetAddress_Private.
42 // TODO(yzshen): Remove them once PPB_NetAddress resource doesn't use
43 // PP_NetAddress_Private as storage type.
44 static void CreateNetAddressPrivateFromIPv4Address(
45 const PP_NetAddress_IPv4& ipv4_addr,
46 PP_NetAddress_Private* addr);
47 static void CreateNetAddressPrivateFromIPv6Address(
48 const PP_NetAddress_IPv6& ipv6_addr,
49 PP_NetAddress_Private* addr);
50 static PP_NetAddress_Family GetFamilyFromNetAddressPrivate(
51 const PP_NetAddress_Private& addr);
52 static bool DescribeNetAddressPrivateAsIPv4Address(
53 const PP_NetAddress_Private& addr,
54 PP_NetAddress_IPv4* ipv4_addr);
55 static bool DescribeNetAddressPrivateAsIPv6Address(
56 const PP_NetAddress_Private& addr,
57 PP_NetAddress_IPv6* ipv6_addr);
59 static const PP_NetAddress_Private kInvalidNetAddress;
61 private:
62 DISALLOW_IMPLICIT_CONSTRUCTORS(NetAddressPrivateImpl);
65 } // namespace ppapi
67 #endif // PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_