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

Unified Diff: ppapi/shared_impl/scoped_pp_var.h

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/proxy/ppp_instance_private_proxy_unittest.cc ('k') | ppapi/shared_impl/scoped_pp_var.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/scoped_pp_var.h
diff --git a/ppapi/shared_impl/scoped_pp_var.h b/ppapi/shared_impl/scoped_pp_var.h
index 564401d5d4be8d43555bdd97bb4fec00fdfe88ad..e53032bb2e0655d528a25f10a62e190625c900de 100644
--- a/ppapi/shared_impl/scoped_pp_var.h
+++ b/ppapi/shared_impl/scoped_pp_var.h
@@ -5,6 +5,9 @@
#ifndef PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_
#define PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_
+#include <stdlib.h>
+
+#include "base/macros.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/shared_impl/ppapi_shared_export.h"
@@ -42,6 +45,40 @@ class PPAPI_SHARED_EXPORT ScopedPPVar {
PP_Var var_;
};
+// An array of PP_Vars which will be deallocated and have their references
+// decremented when they go out of scope.
+class ScopedPPVarArray {
+ public:
+ struct PassPPBMemoryAllocatedRef {};
+
+ // Assumes responsibility for one ref of each of the vars in the array as
+ // well as the array memory allocated by PPB_Memory_Dev.
+ // TODO(raymes): Add compatibility for arrays allocated with C++ "new".
+ ScopedPPVarArray(const PassPPBMemoryAllocatedRef&,
+ PP_Var* array,
+ size_t size);
+
+ explicit ScopedPPVarArray(size_t size);
+ ~ScopedPPVarArray();
+
+ PP_Var* Release(size_t* size);
+
+ PP_Var* get() { return array_; }
+ size_t size() { return size_; }
+
+ // Assumes responsibility for one ref. The existing var at the index will be
+ // released.
+ void Set(size_t index, PP_Var var);
+ const PP_Var& operator[](size_t index) { return array_[index]; }
+
+ private:
+ // TODO(raymes): Consider supporting copy/assign.
+ DISALLOW_COPY_AND_ASSIGN(ScopedPPVarArray);
+
+ PP_Var* array_;
+ size_t size_;
+};
+
} // namespace ppapi
#endif // PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_
« no previous file with comments | « ppapi/proxy/ppp_instance_private_proxy_unittest.cc ('k') | ppapi/shared_impl/scoped_pp_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698