summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-18 20:42:50 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-18 20:42:50 +0000
commitd9e5f412f3f2ad4c04ab4cc29ebfbd7b139c33f0 (patch)
treece3941869e2e4e6ed9fba66eb87216d6dcb33095 /ppapi/thunk
parent3f4f7cbf4db193e77b538b22375339b19ca8f311 (diff)
downloadchromium_src-d9e5f412f3f2ad4c04ab4cc29ebfbd7b139c33f0.zip
chromium_src-d9e5f412f3f2ad4c04ab4cc29ebfbd7b139c33f0.tar.gz
chromium_src-d9e5f412f3f2ad4c04ab4cc29ebfbd7b139c33f0.tar.bz2
Add PPB_VarDictionary_Dev support - part 1.
It includes: - C/C++ interface implementation. - Conversions between PP_Var and base::Value. It dones't include: - Serialization code for IPC. BUG=None TEST=a new unittest Review URL: https://codereview.chromium.org/12387073 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188805 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r--ppapi/thunk/interfaces_ppb_public_dev.h2
-rw-r--r--ppapi/thunk/ppb_var_dictionary_thunk.cc86
2 files changed, 88 insertions, 0 deletions
diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h
index d0570d9..27f3b9c 100644
--- a/ppapi/thunk/interfaces_ppb_public_dev.h
+++ b/ppapi/thunk/interfaces_ppb_public_dev.h
@@ -30,6 +30,8 @@ PROXIED_IFACE(PPB_Instance, PPB_TEXTINPUT_DEV_INTERFACE_0_2,
PPB_TextInput_Dev_0_2)
PROXIED_IFACE(NoAPIName, PPB_TRUETYPEFONT_DEV_INTERFACE_0_1,
PPB_TrueTypeFont_Dev_0_1)
+PROXIED_IFACE(NoAPIName, PPB_VAR_DICTIONARY_DEV_INTERFACE_0_1,
+ PPB_VarDictionary_Dev_0_1)
PROXIED_IFACE(NoAPIName, PPB_VIEW_DEV_INTERFACE_0_1,
PPB_View_Dev_0_1)
UNPROXIED_IFACE(PPB_Instance, PPB_ZOOM_DEV_INTERFACE_0_2, PPB_Zoom_Dev_0_2)
diff --git a/ppapi/thunk/ppb_var_dictionary_thunk.cc b/ppapi/thunk/ppb_var_dictionary_thunk.cc
new file mode 100644
index 0000000..25a8224
--- /dev/null
+++ b/ppapi/thunk/ppb_var_dictionary_thunk.cc
@@ -0,0 +1,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/dev/ppb_var_dictionary_dev.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_Dev_0_1 g_ppb_vardictionary_0_1_thunk = {
+ &Create,
+ &Get,
+ &Set,
+ &Delete,
+ &HasKey,
+ &GetKeys
+};
+
+} // namespace
+
+const PPB_VarDictionary_Dev_0_1* GetPPB_VarDictionary_Dev_0_1_Thunk() {
+ return &g_ppb_vardictionary_0_1_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi