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

Unified Diff: ppapi/thunk/ppb_var_array_thunk.cc

Issue 12388083: Add PPB_VarArray_Dev support - part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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
« no previous file with comments | « ppapi/thunk/interfaces_ppb_public_dev.h ('k') | webkit/plugins/ppapi/plugin_module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/thunk/ppb_var_array_thunk.cc
diff --git a/ppapi/thunk/ppb_var_array_thunk.cc b/ppapi/thunk/ppb_var_array_thunk.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7321424d2994f7aa79faa70224eed8214aa63ae3
--- /dev/null
+++ b/ppapi/thunk/ppb_var_array_thunk.cc
@@ -0,0 +1,74 @@
+// 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_array_dev.h"
+#include "ppapi/shared_impl/array_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.
+ ArrayVar* var = new ArrayVar();
+ return var->GetPPVar();
+}
+
+PP_Var Get(PP_Var array, uint32_t index) {
+ ProxyAutoLock lock;
+
+ ArrayVar* array_var = ArrayVar::FromPPVar(array);
+ if (!array_var)
+ return PP_MakeUndefined();
+ return array_var->Get(index);
+}
+
+PP_Bool Set(PP_Var array, uint32_t index, PP_Var value) {
+ ProxyAutoLock lock;
+
+ ArrayVar* array_var = ArrayVar::FromPPVar(array);
+ if (!array_var)
+ return PP_FALSE;
+ return array_var->Set(index, value);
+}
+
+uint32_t GetLength(PP_Var array) {
+ ProxyAutoLock lock;
+
+ ArrayVar* array_var = ArrayVar::FromPPVar(array);
+ if (!array_var)
+ return 0;
+ return array_var->GetLength();
+}
+
+PP_Bool SetLength(PP_Var array, uint32_t length) {
+ ProxyAutoLock lock;
+
+ ArrayVar* array_var = ArrayVar::FromPPVar(array);
+ if (!array_var)
+ return PP_FALSE;
+ return array_var->SetLength(length);
+}
+
+const PPB_VarArray_Dev_0_1 g_ppb_vararray_0_1_thunk = {
+ &Create,
+ &Get,
+ &Set,
+ &GetLength,
+ &SetLength
+};
+
+} // namespace
+
+const PPB_VarArray_Dev_0_1* GetPPB_VarArray_Dev_0_1_Thunk() {
+ return &g_ppb_vararray_0_1_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi
« no previous file with comments | « ppapi/thunk/interfaces_ppb_public_dev.h ('k') | webkit/plugins/ppapi/plugin_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698