OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/c/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
6 #include "ppapi/c/ppb_net_address.h" | 6 #include "ppapi/c/ppb_net_address.h" |
7 #include "ppapi/shared_impl/tracked_callback.h" | 7 #include "ppapi/shared_impl/tracked_callback.h" |
8 #include "ppapi/thunk/enter.h" | 8 #include "ppapi/thunk/enter.h" |
9 #include "ppapi/thunk/ppb_instance_api.h" | 9 #include "ppapi/thunk/ppb_instance_api.h" |
10 #include "ppapi/thunk/ppb_net_address_api.h" | 10 #include "ppapi/thunk/ppb_net_address_api.h" |
11 #include "ppapi/thunk/resource_creation_api.h" | 11 #include "ppapi/thunk/resource_creation_api.h" |
12 #include "ppapi/thunk/thunk.h" | 12 #include "ppapi/thunk/thunk.h" |
13 | 13 |
14 namespace ppapi { | 14 namespace ppapi { |
15 namespace thunk { | 15 namespace thunk { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 PP_Resource CreateFromIPv4Address( | 19 PP_Resource CreateFromIPv4Address(PP_Instance instance, |
20 PP_Instance instance, | 20 const struct PP_NetAddress_IPv4* ipv4_addr) { |
21 const struct PP_NetAddress_IPv4* ipv4_addr) { | |
22 VLOG(4) << "PPB_NetAddress::CreateFromIPv4Address()"; | 21 VLOG(4) << "PPB_NetAddress::CreateFromIPv4Address()"; |
23 EnterResourceCreation enter(instance); | 22 EnterResourceCreation enter(instance); |
24 if (enter.failed()) | 23 if (enter.failed()) |
25 return 0; | 24 return 0; |
26 return enter.functions()->CreateNetAddressFromIPv4Address(instance, | 25 return enter.functions()->CreateNetAddressFromIPv4Address(instance, |
27 ipv4_addr); | 26 ipv4_addr); |
28 } | 27 } |
29 | 28 |
30 PP_Resource CreateFromIPv6Address( | 29 PP_Resource CreateFromIPv6Address(PP_Instance instance, |
31 PP_Instance instance, | 30 const struct PP_NetAddress_IPv6* ipv6_addr) { |
32 const struct PP_NetAddress_IPv6* ipv6_addr) { | |
33 VLOG(4) << "PPB_NetAddress::CreateFromIPv6Address()"; | 31 VLOG(4) << "PPB_NetAddress::CreateFromIPv6Address()"; |
34 EnterResourceCreation enter(instance); | 32 EnterResourceCreation enter(instance); |
35 if (enter.failed()) | 33 if (enter.failed()) |
36 return 0; | 34 return 0; |
37 return enter.functions()->CreateNetAddressFromIPv6Address(instance, | 35 return enter.functions()->CreateNetAddressFromIPv6Address(instance, |
38 ipv6_addr); | 36 ipv6_addr); |
39 } | 37 } |
40 | 38 |
41 PP_Bool IsNetAddress(PP_Resource resource) { | 39 PP_Bool IsNetAddress(PP_Resource resource) { |
42 VLOG(4) << "PPB_NetAddress::IsNetAddress()"; | 40 VLOG(4) << "PPB_NetAddress::IsNetAddress()"; |
(...skipping 29 matching lines...) Expand all Loading... |
72 PP_Bool DescribeAsIPv6Address(PP_Resource addr, | 70 PP_Bool DescribeAsIPv6Address(PP_Resource addr, |
73 struct PP_NetAddress_IPv6* ipv6_addr) { | 71 struct PP_NetAddress_IPv6* ipv6_addr) { |
74 VLOG(4) << "PPB_NetAddress::DescribeAsIPv6Address()"; | 72 VLOG(4) << "PPB_NetAddress::DescribeAsIPv6Address()"; |
75 EnterResource<PPB_NetAddress_API> enter(addr, true); | 73 EnterResource<PPB_NetAddress_API> enter(addr, true); |
76 if (enter.failed()) | 74 if (enter.failed()) |
77 return PP_FALSE; | 75 return PP_FALSE; |
78 return enter.object()->DescribeAsIPv6Address(ipv6_addr); | 76 return enter.object()->DescribeAsIPv6Address(ipv6_addr); |
79 } | 77 } |
80 | 78 |
81 const PPB_NetAddress_1_0 g_ppb_netaddress_thunk_1_0 = { | 79 const PPB_NetAddress_1_0 g_ppb_netaddress_thunk_1_0 = { |
82 &CreateFromIPv4Address, | 80 &CreateFromIPv4Address, &CreateFromIPv6Address, &IsNetAddress, |
83 &CreateFromIPv6Address, | 81 &GetFamily, &DescribeAsString, &DescribeAsIPv4Address, |
84 &IsNetAddress, | 82 &DescribeAsIPv6Address}; |
85 &GetFamily, | |
86 &DescribeAsString, | |
87 &DescribeAsIPv4Address, | |
88 &DescribeAsIPv6Address | |
89 }; | |
90 | 83 |
91 } // namespace | 84 } // namespace |
92 | 85 |
93 const PPB_NetAddress_1_0* GetPPB_NetAddress_1_0_Thunk() { | 86 const PPB_NetAddress_1_0* GetPPB_NetAddress_1_0_Thunk() { |
94 return &g_ppb_netaddress_thunk_1_0; | 87 return &g_ppb_netaddress_thunk_1_0; |
95 } | 88 } |
96 | 89 |
97 } // namespace thunk | 90 } // namespace thunk |
98 } // namespace ppapi | 91 } // namespace ppapi |
OLD | NEW |