Home | History | Annotate | Download | only in thunk
      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 dev/ppb_resource_array_dev.idl modified Thu Dec 20 13:10:26 2012.
      6 
      7 #include "ppapi/c/dev/ppb_resource_array_dev.h"
      8 #include "ppapi/c/pp_errors.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_resource_array_api.h"
     13 #include "ppapi/thunk/resource_creation_api.h"
     14 #include "ppapi/thunk/thunk.h"
     15 
     16 namespace ppapi {
     17 namespace thunk {
     18 
     19 namespace {
     20 
     21 PP_Resource Create(PP_Instance instance,
     22                    const PP_Resource elements[],
     23                    uint32_t size) {
     24   VLOG(4) << "PPB_ResourceArray_Dev::Create()";
     25   EnterResourceCreation enter(instance);
     26   if (enter.failed())
     27     return 0;
     28   return enter.functions()->CreateResourceArray(instance, elements, size);
     29 }
     30 
     31 PP_Bool IsResourceArray(PP_Resource resource) {
     32   VLOG(4) << "PPB_ResourceArray_Dev::IsResourceArray()";
     33   EnterResource<PPB_ResourceArray_API> enter(resource, false);
     34   return PP_FromBool(enter.succeeded());
     35 }
     36 
     37 uint32_t GetSize(PP_Resource resource_array) {
     38   VLOG(4) << "PPB_ResourceArray_Dev::GetSize()";
     39   EnterResource<PPB_ResourceArray_API> enter(resource_array, true);
     40   if (enter.failed())
     41     return 0;
     42   return enter.object()->GetSize();
     43 }
     44 
     45 PP_Resource GetAt(PP_Resource resource_array, uint32_t index) {
     46   VLOG(4) << "PPB_ResourceArray_Dev::GetAt()";
     47   EnterResource<PPB_ResourceArray_API> enter(resource_array, true);
     48   if (enter.failed())
     49     return 0;
     50   return enter.object()->GetAt(index);
     51 }
     52 
     53 const PPB_ResourceArray_Dev_0_1 g_ppb_resourcearray_dev_thunk_0_1 = {
     54   &Create,
     55   &IsResourceArray,
     56   &GetSize,
     57   &GetAt
     58 };
     59 
     60 }  // namespace
     61 
     62 const PPB_ResourceArray_Dev_0_1* GetPPB_ResourceArray_Dev_0_1_Thunk() {
     63   return &g_ppb_resourcearray_dev_thunk_0_1;
     64 }
     65 
     66 }  // namespace thunk
     67 }  // namespace ppapi
     68