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/c/pp_errors.h"
6 #include "ppapi/c/ppb_net_address.h"
7 #include "ppapi/shared_impl/tracked_callback.h"
8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_instance_api.h"
10 #include "ppapi/thunk/ppb_net_address_api.h"
11 #include "ppapi/thunk/resource_creation_api.h"
12 #include "ppapi/thunk/thunk.h"
19 PP_Resource
CreateFromIPv4Address(
21 const struct PP_NetAddress_IPv4
* ipv4_addr
) {
22 VLOG(4) << "PPB_NetAddress::CreateFromIPv4Address()";
23 EnterResourceCreation
enter(instance
);
26 return enter
.functions()->CreateNetAddressFromIPv4Address(instance
,
30 PP_Resource
CreateFromIPv6Address(
32 const struct PP_NetAddress_IPv6
* ipv6_addr
) {
33 VLOG(4) << "PPB_NetAddress::CreateFromIPv6Address()";
34 EnterResourceCreation
enter(instance
);
37 return enter
.functions()->CreateNetAddressFromIPv6Address(instance
,
41 PP_Bool
IsNetAddress(PP_Resource resource
) {
42 VLOG(4) << "PPB_NetAddress::IsNetAddress()";
43 EnterResource
<PPB_NetAddress_API
> enter(resource
, false);
44 return PP_FromBool(enter
.succeeded());
47 PP_NetAddress_Family
GetFamily(PP_Resource addr
) {
48 VLOG(4) << "PPB_NetAddress::GetFamily()";
49 EnterResource
<PPB_NetAddress_API
> enter(addr
, true);
51 return PP_NETADDRESS_FAMILY_UNSPECIFIED
;
52 return enter
.object()->GetFamily();
55 struct PP_Var
DescribeAsString(PP_Resource addr
, PP_Bool include_port
) {
56 VLOG(4) << "PPB_NetAddress::DescribeAsString()";
57 EnterResource
<PPB_NetAddress_API
> enter(addr
, true);
59 return PP_MakeUndefined();
60 return enter
.object()->DescribeAsString(include_port
);
63 PP_Bool
DescribeAsIPv4Address(PP_Resource addr
,
64 struct PP_NetAddress_IPv4
* ipv4_addr
) {
65 VLOG(4) << "PPB_NetAddress::DescribeAsIPv4Address()";
66 EnterResource
<PPB_NetAddress_API
> enter(addr
, true);
69 return enter
.object()->DescribeAsIPv4Address(ipv4_addr
);
72 PP_Bool
DescribeAsIPv6Address(PP_Resource addr
,
73 struct PP_NetAddress_IPv6
* ipv6_addr
) {
74 VLOG(4) << "PPB_NetAddress::DescribeAsIPv6Address()";
75 EnterResource
<PPB_NetAddress_API
> enter(addr
, true);
78 return enter
.object()->DescribeAsIPv6Address(ipv6_addr
);
81 const PPB_NetAddress_1_0 g_ppb_netaddress_thunk_1_0
= {
82 &CreateFromIPv4Address
,
83 &CreateFromIPv6Address
,
87 &DescribeAsIPv4Address
,
88 &DescribeAsIPv6Address
93 const PPB_NetAddress_1_0
* GetPPB_NetAddress_1_0_Thunk() {
94 return &g_ppb_netaddress_thunk_1_0
;