Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: ppapi/thunk/ppb_var_dictionary_thunk.cc

Issue 12387073: Add PPB_VarDictionary_Dev support - part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use correct base branch. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "ppapi/c/dev/ppb_var_dictionary_dev.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"
11
12 namespace ppapi {
13 namespace thunk {
14
15 namespace {
16
17 PP_Var Create() {
18 ProxyAutoLock lock;
19
20 // Var tracker will hold a reference to this object.
21 DictionaryVar* var = new DictionaryVar();
22 return var->GetPPVar();
23 }
24
25 PP_Var Get(PP_Var dict, PP_Var key) {
26 ProxyAutoLock lock;
27
28 DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
29 if (!dict_var)
30 return PP_MakeUndefined();
31 return dict_var->Get(key);
32 }
33
34 PP_Bool Set(PP_Var dict, PP_Var key, PP_Var value) {
35 ProxyAutoLock lock;
36
37 DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
38 if (!dict_var)
39 return PP_FALSE;
40
41 return dict_var->Set(key, value);
42 }
43
44 void Delete(PP_Var dict, PP_Var key) {
45 ProxyAutoLock lock;
46
47 DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
48 if (dict_var)
49 dict_var->Delete(key);
50 }
51
52 PP_Bool HasKey(PP_Var dict, PP_Var key) {
53 ProxyAutoLock lock;
54
55 DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
56 if (!dict_var)
57 return PP_FALSE;
58 return dict_var->HasKey(key);
59 }
60
61 PP_Var GetKeys(PP_Var dict) {
62 ProxyAutoLock lock;
63
64 DictionaryVar* dict_var = DictionaryVar::FromPPVar(dict);
65 if (!dict_var)
66 return PP_MakeNull();
67 return dict_var->GetKeys();
68 }
69
70 const PPB_VarDictionary_Dev_0_1 g_ppb_vardictionary_0_1_thunk = {
71 &Create,
72 &Get,
73 &Set,
74 &Delete,
75 &HasKey,
76 &GetKeys
77 };
78
79 } // namespace
80
81 const PPB_VarDictionary_Dev_0_1* GetPPB_VarDictionary_Dev_0_1_Thunk() {
82 return &g_ppb_vardictionary_0_1_thunk;
83 }
84
85 } // namespace thunk
86 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698