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

Unified Diff: ppapi/shared_impl/scoped_pp_var.cc

Issue 400823004: gin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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/shared_impl/scoped_pp_var.h ('k') | ppapi/shared_impl/var.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/scoped_pp_var.cc
diff --git a/ppapi/shared_impl/scoped_pp_var.cc b/ppapi/shared_impl/scoped_pp_var.cc
index f612aa1a2ac765dd0652b53b92c6d86b88b9d548..dc6a178a5ec688a57ddc88b5d9790b73e3f91dcc 100644
--- a/ppapi/shared_impl/scoped_pp_var.cc
+++ b/ppapi/shared_impl/scoped_pp_var.cc
@@ -4,8 +4,10 @@
#include "ppapi/shared_impl/scoped_pp_var.h"
+#include "ppapi/c/dev/ppb_memory_dev.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/var_tracker.h"
+#include "ppapi/thunk/thunk.h"
namespace ppapi {
@@ -46,4 +48,42 @@ PP_Var ScopedPPVar::Release() {
return result;
}
+ScopedPPVarArray::ScopedPPVarArray(const PassPPBMemoryAllocatedRef&,
+ PP_Var* array,
+ size_t size)
+ : array_(array),
+ size_(size) {}
+
+ScopedPPVarArray::ScopedPPVarArray(size_t size)
+ : size_(size) {
+ if (size > 0) {
+ array_ = static_cast<PP_Var*>(
+ thunk::GetPPB_Memory_Dev_0_1_Thunk()->MemAlloc(sizeof(PP_Var) * size));
+ }
+ for (size_t i = 0; i < size_; ++i)
+ array_[i] = PP_MakeUndefined();
+}
+
+ScopedPPVarArray::~ScopedPPVarArray() {
+ for (size_t i = 0; i < size_; ++i)
+ CallRelease(array_[i]);
+ if (size_ > 0)
+ thunk::GetPPB_Memory_Dev_0_1_Thunk()->MemFree(array_);
+
+}
+
+PP_Var* ScopedPPVarArray::Release(size_t* size) {
+ PP_Var* result = array_;
+ *size = size_;
+ array_ = NULL;
+ size_ = 0;
+ return result;
+}
+
+void ScopedPPVarArray::Set(size_t index, PP_Var var) {
+ DCHECK(index < size_);
+ CallRelease(array_[index]);
+ array_[index] = var;
+}
+
} // namespace ppapi
« no previous file with comments | « ppapi/shared_impl/scoped_pp_var.h ('k') | ppapi/shared_impl/var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698