Revert 233414 "x11: Move XInput2 availability information out of..."
[chromium-blink-merge.git] / ppapi / thunk / ppb_network_list_thunk.cc
blob393a752cc01390d063b8d44b7ed99b7706b295e1
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.
5 // From ppb_network_list.idl modified Mon Sep 9 11:18:02 2013.
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/ppb_instance_api.h"
12 #include "ppapi/thunk/ppb_network_list_api.h"
13 #include "ppapi/thunk/resource_creation_api.h"
14 #include "ppapi/thunk/thunk.h"
16 namespace ppapi {
17 namespace thunk {
19 namespace {
21 PP_Bool IsNetworkList(PP_Resource resource) {
22 VLOG(4) << "PPB_NetworkList::IsNetworkList()";
23 EnterResource<PPB_NetworkList_API> enter(resource, false);
24 return PP_FromBool(enter.succeeded());
27 uint32_t GetCount(PP_Resource resource) {
28 VLOG(4) << "PPB_NetworkList::GetCount()";
29 EnterResource<PPB_NetworkList_API> enter(resource, true);
30 if (enter.failed())
31 return 0;
32 return enter.object()->GetCount();
35 struct PP_Var GetName(PP_Resource resource, uint32_t index) {
36 VLOG(4) << "PPB_NetworkList::GetName()";
37 EnterResource<PPB_NetworkList_API> enter(resource, true);
38 if (enter.failed())
39 return PP_MakeUndefined();
40 return enter.object()->GetName(index);
43 PP_NetworkList_Type GetType(PP_Resource resource, uint32_t index) {
44 VLOG(4) << "PPB_NetworkList::GetType()";
45 EnterResource<PPB_NetworkList_API> enter(resource, true);
46 if (enter.failed())
47 return PP_NETWORKLIST_TYPE_UNKNOWN;
48 return enter.object()->GetType(index);
51 PP_NetworkList_State GetState(PP_Resource resource, uint32_t index) {
52 VLOG(4) << "PPB_NetworkList::GetState()";
53 EnterResource<PPB_NetworkList_API> enter(resource, true);
54 if (enter.failed())
55 return PP_NETWORKLIST_STATE_DOWN;
56 return enter.object()->GetState(index);
59 int32_t GetIpAddresses(PP_Resource resource,
60 uint32_t index,
61 struct PP_ArrayOutput output) {
62 VLOG(4) << "PPB_NetworkList::GetIpAddresses()";
63 EnterResource<PPB_NetworkList_API> enter(resource, true);
64 if (enter.failed())
65 return enter.retval();
66 return enter.object()->GetIpAddresses(index, output);
69 struct PP_Var GetDisplayName(PP_Resource resource, uint32_t index) {
70 VLOG(4) << "PPB_NetworkList::GetDisplayName()";
71 EnterResource<PPB_NetworkList_API> enter(resource, true);
72 if (enter.failed())
73 return PP_MakeUndefined();
74 return enter.object()->GetDisplayName(index);
77 uint32_t GetMTU(PP_Resource resource, uint32_t index) {
78 VLOG(4) << "PPB_NetworkList::GetMTU()";
79 EnterResource<PPB_NetworkList_API> enter(resource, true);
80 if (enter.failed())
81 return 0;
82 return enter.object()->GetMTU(index);
85 const PPB_NetworkList_1_0 g_ppb_networklist_thunk_1_0 = {
86 &IsNetworkList,
87 &GetCount,
88 &GetName,
89 &GetType,
90 &GetState,
91 &GetIpAddresses,
92 &GetDisplayName,
93 &GetMTU
96 } // namespace
98 const PPB_NetworkList_1_0* GetPPB_NetworkList_1_0_Thunk() {
99 return &g_ppb_networklist_thunk_1_0;
102 } // namespace thunk
103 } // namespace ppapi