1 // Copyright 2013 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 #include "ppapi/proxy/net_address_resource.h"
9 #include "ppapi/c/pp_bool.h"
10 #include "ppapi/shared_impl/private/net_address_private_impl.h"
11 #include "ppapi/shared_impl/var.h"
16 NetAddressResource::NetAddressResource(
17 Connection connection
,
19 const PP_NetAddress_IPv4
& ipv4_addr
)
20 : PluginResource(connection
, instance
) {
21 NetAddressPrivateImpl::CreateNetAddressPrivateFromIPv4Address(ipv4_addr
,
25 NetAddressResource::NetAddressResource(
26 Connection connection
,
28 const PP_NetAddress_IPv6
& ipv6_addr
)
29 : PluginResource(connection
, instance
) {
30 NetAddressPrivateImpl::CreateNetAddressPrivateFromIPv6Address(ipv6_addr
,
34 NetAddressResource::NetAddressResource(
35 Connection connection
,
37 const PP_NetAddress_Private
& private_addr
)
38 : PluginResource(connection
, instance
) {
39 address_
= private_addr
;
42 NetAddressResource::~NetAddressResource() {
45 thunk::PPB_NetAddress_API
* NetAddressResource::AsPPB_NetAddress_API() {
49 PP_NetAddress_Family
NetAddressResource::GetFamily() {
50 return NetAddressPrivateImpl::GetFamilyFromNetAddressPrivate(address_
);
53 PP_Var
NetAddressResource::DescribeAsString(PP_Bool include_port
) {
54 std::string description
= NetAddressPrivateImpl::DescribeNetAddress(
55 address_
, PP_ToBool(include_port
));
57 if (description
.empty())
58 return PP_MakeUndefined();
59 return StringVar::StringToPPVar(description
);
62 PP_Bool
NetAddressResource::DescribeAsIPv4Address(
63 PP_NetAddress_IPv4
* ipv4_addr
) {
65 NetAddressPrivateImpl::DescribeNetAddressPrivateAsIPv4Address(
66 address_
, ipv4_addr
));
69 PP_Bool
NetAddressResource::DescribeAsIPv6Address(
70 PP_NetAddress_IPv6
* ipv6_addr
) {
72 NetAddressPrivateImpl::DescribeNetAddressPrivateAsIPv6Address(
73 address_
, ipv6_addr
));
76 const PP_NetAddress_Private
& NetAddressResource::GetNetAddressPrivate() {