1 // Copyright (c) 2012 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.
4
5 // From ppb_network_list.idl modified Thu Oct 31 12:30:06 2013.
6
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_network_list.h"
9 #include "ppapi/shared_impl/tracked_callback.h"
10 #include "ppapi/thunk/enter.h"
11 #include "ppapi/thunk/ppapi_thunk_export.h"
12 #include "ppapi/thunk/ppb_network_list_api.h"
13
14 namespace ppapi {
15 namespace thunk {
16
17 namespace {
18
IsNetworkList(PP_Resource resource)19 PP_Bool IsNetworkList(PP_Resource resource) {
20 VLOG(4) << "PPB_NetworkList::IsNetworkList()";
21 EnterResource<PPB_NetworkList_API> enter(resource, false);
22 return PP_FromBool(enter.succeeded());
23 }
24
GetCount(PP_Resource resource)25 uint32_t GetCount(PP_Resource resource) {
26 VLOG(4) << "PPB_NetworkList::GetCount()";
27 EnterResource<PPB_NetworkList_API> enter(resource, true);
28 if (enter.failed())
29 return 0;
30 return enter.object()->GetCount();
31 }
32
GetName(PP_Resource resource,uint32_t index)33 struct PP_Var GetName(PP_Resource resource, uint32_t index) {
34 VLOG(4) << "PPB_NetworkList::GetName()";
35 EnterResource<PPB_NetworkList_API> enter(resource, true);
36 if (enter.failed())
37 return PP_MakeUndefined();
38 return enter.object()->GetName(index);
39 }
40
GetType(PP_Resource resource,uint32_t index)41 PP_NetworkList_Type GetType(PP_Resource resource, uint32_t index) {
42 VLOG(4) << "PPB_NetworkList::GetType()";
43 EnterResource<PPB_NetworkList_API> enter(resource, true);
44 if (enter.failed())
45 return PP_NETWORKLIST_TYPE_UNKNOWN;
46 return enter.object()->GetType(index);
47 }
48
GetState(PP_Resource resource,uint32_t index)49 PP_NetworkList_State GetState(PP_Resource resource, uint32_t index) {
50 VLOG(4) << "PPB_NetworkList::GetState()";
51 EnterResource<PPB_NetworkList_API> enter(resource, true);
52 if (enter.failed())
53 return PP_NETWORKLIST_STATE_DOWN;
54 return enter.object()->GetState(index);
55 }
56
GetIpAddresses(PP_Resource resource,uint32_t index,struct PP_ArrayOutput output)57 int32_t GetIpAddresses(PP_Resource resource,
58 uint32_t index,
59 struct PP_ArrayOutput output) {
60 VLOG(4) << "PPB_NetworkList::GetIpAddresses()";
61 EnterResource<PPB_NetworkList_API> enter(resource, true);
62 if (enter.failed())
63 return enter.retval();
64 return enter.object()->GetIpAddresses(index, output);
65 }
66
GetDisplayName(PP_Resource resource,uint32_t index)67 struct PP_Var GetDisplayName(PP_Resource resource, uint32_t index) {
68 VLOG(4) << "PPB_NetworkList::GetDisplayName()";
69 EnterResource<PPB_NetworkList_API> enter(resource, true);
70 if (enter.failed())
71 return PP_MakeUndefined();
72 return enter.object()->GetDisplayName(index);
73 }
74
GetMTU(PP_Resource resource,uint32_t index)75 uint32_t GetMTU(PP_Resource resource, uint32_t index) {
76 VLOG(4) << "PPB_NetworkList::GetMTU()";
77 EnterResource<PPB_NetworkList_API> enter(resource, true);
78 if (enter.failed())
79 return 0;
80 return enter.object()->GetMTU(index);
81 }
82
83 const PPB_NetworkList_1_0 g_ppb_networklist_thunk_1_0 = {
84 &IsNetworkList,
85 &GetCount,
86 &GetName,
87 &GetType,
88 &GetState,
89 &GetIpAddresses,
90 &GetDisplayName,
91 &GetMTU
92 };
93
94 } // namespace
95
GetPPB_NetworkList_1_0_Thunk()96 PPAPI_THUNK_EXPORT const PPB_NetworkList_1_0* GetPPB_NetworkList_1_0_Thunk() {
97 return &g_ppb_networklist_thunk_1_0;
98 }
99
100 } // namespace thunk
101 } // namespace ppapi
102