Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / ppapi / thunk / ppb_var_array_thunk.cc
blob9ab52ac6ccdcad92041fc0b443788cd5610e032d
1 // Copyright (c) 2013 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 #include "ppapi/c/ppb_var_array.h"
6 #include "ppapi/shared_impl/array_var.h"
7 #include "ppapi/shared_impl/proxy_lock.h"
8 #include "ppapi/thunk/thunk.h"
10 namespace ppapi {
11 namespace thunk {
13 namespace {
15 PP_Var Create() {
16 ProxyAutoLock lock;
18 // Var tracker will hold a reference to this object.
19 ArrayVar* var = new ArrayVar();
20 return var->GetPPVar();
23 PP_Var Get(PP_Var array, uint32_t index) {
24 ProxyAutoLock lock;
26 ArrayVar* array_var = ArrayVar::FromPPVar(array);
27 if (!array_var)
28 return PP_MakeUndefined();
29 return array_var->Get(index);
32 PP_Bool Set(PP_Var array, uint32_t index, PP_Var value) {
33 ProxyAutoLock lock;
35 ArrayVar* array_var = ArrayVar::FromPPVar(array);
36 if (!array_var)
37 return PP_FALSE;
38 return array_var->Set(index, value);
41 uint32_t GetLength(PP_Var array) {
42 ProxyAutoLock lock;
44 ArrayVar* array_var = ArrayVar::FromPPVar(array);
45 if (!array_var)
46 return 0;
47 return array_var->GetLength();
50 PP_Bool SetLength(PP_Var array, uint32_t length) {
51 ProxyAutoLock lock;
53 ArrayVar* array_var = ArrayVar::FromPPVar(array);
54 if (!array_var)
55 return PP_FALSE;
56 return array_var->SetLength(length);
59 const PPB_VarArray_1_0 g_ppb_vararray_1_0_thunk = {
60 &Create,
61 &Get,
62 &Set,
63 &GetLength,
64 &SetLength
67 } // namespace
69 const PPB_VarArray_1_0* GetPPB_VarArray_1_0_Thunk() {
70 return &g_ppb_vararray_1_0_thunk;
73 } // namespace thunk
74 } // namespace ppapi