1f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// Use of this source code is governed by a BSD-style license that can be 3f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// found in the LICENSE file. 4f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 5f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// From ppb_network_list.idl modified Thu Oct 31 12:30:06 2013. 6f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 7f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson#include "ppapi/c/pp_errors.h" 8f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson#include "ppapi/c/ppb_network_list.h" 9f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson#include "ppapi/shared_impl/tracked_callback.h" 10f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson#include "ppapi/thunk/enter.h" 11f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson#include "ppapi/thunk/ppapi_thunk_export.h" 12f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson#include "ppapi/thunk/ppb_network_list_api.h" 13f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 14f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonnamespace ppapi { 15dfd8b8327b93660601d016cdc6f29f433b45a8d8Alexander Gutkinnamespace thunk { 16f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 17dfd8b8327b93660601d016cdc6f29f433b45a8d8Alexander Gutkinnamespace { 18f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 19dfd8b8327b93660601d016cdc6f29f433b45a8d8Alexander GutkinPP_Bool IsNetworkList(PP_Resource resource) { 20f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson VLOG(4) << "PPB_NetworkList::IsNetworkList()"; 21dfd8b8327b93660601d016cdc6f29f433b45a8d8Alexander Gutkin EnterResource<PPB_NetworkList_API> enter(resource, false); 22f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson return PP_FromBool(enter.succeeded()); 23dfd8b8327b93660601d016cdc6f29f433b45a8d8Alexander Gutkin} 24dfd8b8327b93660601d016cdc6f29f433b45a8d8Alexander Gutkin 25dfd8b8327b93660601d016cdc6f29f433b45a8d8Alexander Gutkinuint32_t GetCount(PP_Resource resource) { 26dfd8b8327b93660601d016cdc6f29f433b45a8d8Alexander Gutkin VLOG(4) << "PPB_NetworkList::GetCount()"; 27dfd8b8327b93660601d016cdc6f29f433b45a8d8Alexander Gutkin EnterResource<PPB_NetworkList_API> enter(resource, true); 28dfd8b8327b93660601d016cdc6f29f433b45a8d8Alexander Gutkin if (enter.failed()) 29 return 0; 30 return enter.object()->GetCount(); 31} 32 33struct 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 41PP_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 49PP_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 57int32_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 67struct 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 75uint32_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 83const 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 96PPAPI_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