Revert 233414 "x11: Move XInput2 availability information out of..."
[chromium-blink-merge.git] / ppapi / thunk / ppb_resource_array_dev_thunk.cc
blob6d51a564d8a49d7f46eebe390c4d709302d84b70
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 dev/ppb_resource_array_dev.idl modified Thu Dec 20 13:10:26 2012.
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"
16 namespace ppapi {
17 namespace thunk {
19 namespace {
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);
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());
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();
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);
53 const PPB_ResourceArray_Dev_0_1 g_ppb_resourcearray_dev_thunk_0_1 = {
54 &Create,
55 &IsResourceArray,
56 &GetSize,
57 &GetAt
60 } // namespace
62 const PPB_ResourceArray_Dev_0_1* GetPPB_ResourceArray_Dev_0_1_Thunk() {
63 return &g_ppb_resourcearray_dev_thunk_0_1;
66 } // namespace thunk
67 } // namespace ppapi