Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ppapi / thunk / ppb_var_dictionary_thunk.cc
blobf2ace6516f1b293d49800c3add7f692a3cce32b5
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_dictionary.h"
6 #include "ppapi/c/pp_bool.h"
7 #include "ppapi/c/pp_var.h"
8 #include "ppapi/shared_impl/dictionary_var.h"
9 #include "ppapi/shared_impl/proxy_lock.h"
10 #include "ppapi/thunk/thunk.h"
12 namespace ppapi {
13 namespace thunk {
15 namespace {
17 PP_Var Create() {
18 ProxyAutoLock lock;
20 // Var tracker will hold a reference to this object.
21 DictionaryVar* var = new DictionaryVar();
22 return var->GetPPVar();
25 PP_Var Get(PP_Var dict, PP_Var key) {
26 ProxyAutoLock lock;
28 DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
29 if (!dict_var)
30 return PP_MakeUndefined();
31 return dict_var->Get(key);
34 PP_Bool Set(PP_Var dict, PP_Var key, PP_Var value) {
35 ProxyAutoLock lock;
37 DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
38 if (!dict_var)
39 return PP_FALSE;
41 return dict_var->Set(key, value);
44 void Delete(PP_Var dict, PP_Var key) {
45 ProxyAutoLock lock;
47 DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
48 if (dict_var)
49 dict_var->Delete(key);
52 PP_Bool HasKey(PP_Var dict, PP_Var key) {
53 ProxyAutoLock lock;
55 DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
56 if (!dict_var)
57 return PP_FALSE;
58 return dict_var->HasKey(key);
61 PP_Var GetKeys(PP_Var dict) {
62 ProxyAutoLock lock;
64 DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
65 if (!dict_var)
66 return PP_MakeNull();
67 return dict_var->GetKeys();
70 const PPB_VarDictionary_1_0 g_ppb_vardictionary_1_0_thunk = {
71 &Create,
72 &Get,
73 &Set,
74 &Delete,
75 &HasKey,
76 &GetKeys
79 } // namespace
81 const PPB_VarDictionary_1_0* GetPPB_VarDictionary_1_0_Thunk() {
82 return &g_ppb_vardictionary_1_0_thunk;
85 } // namespace thunk
86 } // namespace ppapi