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

Unified 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: changes in response to David's suggestions 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/thunk/ppb_var_dictionary_thunk.cc
diff --git a/ppapi/thunk/ppb_var_dictionary_thunk.cc b/ppapi/thunk/ppb_var_dictionary_thunk.cc
new file mode 100644
index 0000000000000000000000000000000000000000..25a82249f2926b7f1999730a930cc7cab0a01671
--- /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

Powered by Google App Engine
This is Rietveld 408576698