| 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_
|
|
|