blob: f2ace6516f1b293d49800c3add7f692a3cce32b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/c/ppb_var_dictionary.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/shared_impl/dictionary_var.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/thunk/thunk.h"
namespace ppapi {
namespace thunk {
namespace {
PP_Var Create() {
ProxyAutoLock lock;
// Var tracker will hold a reference to this object.
DictionaryVar* var = new DictionaryVar();
return var->GetPPVar();
}
PP_Var Get(PP_Var dict, PP_Var key) {
ProxyAutoLock lock;
DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
if (!dict_var)
return PP_MakeUndefined();
return dict_var->Get(key);
}
PP_Bool Set(PP_Var dict, PP_Var key, PP_Var value) {
ProxyAutoLock lock;
DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
if (!dict_var)
return PP_FALSE;
return dict_var->Set(key, value);
}
void Delete(PP_Var dict, PP_Var key) {
ProxyAutoLock lock;
DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
if (dict_var)
dict_var->Delete(key);
}
PP_Bool HasKey(PP_Var dict, PP_Var key) {
ProxyAutoLock lock;
DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
if (!dict_var)
return PP_FALSE;
return dict_var->HasKey(key);
}
PP_Var GetKeys(PP_Var dict) {
ProxyAutoLock lock;
DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
if (!dict_var)
return PP_MakeNull();
return dict_var->GetKeys();
}
const PPB_VarDictionary_1_0 g_ppb_vardictionary_1_0_thunk = {
&Create,
&Get,
&Set,
&Delete,
&HasKey,
&GetKeys
};
} // namespace
const PPB_VarDictionary_1_0* GetPPB_VarDictionary_1_0_Thunk() {
return &g_ppb_vardictionary_1_0_thunk;
}
} // namespace thunk
} // namespace ppapi
|