diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 01:10:08 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 01:10:08 +0000 |
commit | d06ae7f5db8269e16b89635c905a84d66695476b (patch) | |
tree | bc9c0e4f0c1eed6ededca3045f93f83b11c97de0 /ppapi/cpp/output_traits.h | |
parent | ce542d57833d7d579c924d7145cfc24ad013828d (diff) | |
download | chromium_src-d06ae7f5db8269e16b89635c905a84d66695476b.zip chromium_src-d06ae7f5db8269e16b89635c905a84d66695476b.tar.gz chromium_src-d06ae7f5db8269e16b89635c905a84d66695476b.tar.bz2 |
PPAPI: Initialize CompletionCallbackWithOutput storage
BUG=250046
Review URL: https://chromiumcodereview.appspot.com/18611004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210999 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp/output_traits.h')
-rw-r--r-- | ppapi/cpp/output_traits.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ppapi/cpp/output_traits.h b/ppapi/cpp/output_traits.h index 1779e7a..37a8a65 100644 --- a/ppapi/cpp/output_traits.h +++ b/ppapi/cpp/output_traits.h @@ -85,6 +85,10 @@ struct GenericCallbackOutputTraits { // callbacks. This doesn't actually need to do anything in this case, // it's needed for some of more complex template specializations below. static inline T& StorageToPluginArg(StorageType& t) { return t; } + + // Initializes the "storage type" to a default value, if necessary. Here, + // we do nothing, assuming that the default constructor for T suffices. + static inline void Initialize(StorageType* /* t */) {} }; // Output traits for all resource types. It is implemented to pass a @@ -113,6 +117,10 @@ struct ResourceCallbackOutputTraits { static inline T StorageToPluginArg(StorageType& t) { return T(PASS_REF, t); } + + static inline void Initialize(StorageType* t) { + *t = 0; + } }; // The general templatized base class for all CallbackOutputTraits. This class @@ -147,6 +155,10 @@ struct CallbackOutputTraits<Var> { static inline pp::Var StorageToPluginArg(StorageType& t) { return Var(PASS_REF, t); } + + static inline void Initialize(StorageType* t) { + *t = PP_MakeUndefined(); + } }; // Array output parameters ----------------------------------------------------- @@ -175,6 +187,8 @@ struct GenericVectorCallbackOutputTraits { static inline std::vector<T>& StorageToPluginArg(StorageType& t) { return t.output(); } + + static inline void Initialize(StorageType* /* t */) {} }; // Output traits for all vectors of resource types. It is implemented to pass @@ -196,6 +210,8 @@ struct ResourceVectorCallbackOutputTraits { static inline std::vector<T>& StorageToPluginArg(StorageType& t) { return t.output(); } + + static inline void Initialize(StorageType* /* t */) {} }; // Specialization of CallbackOutputTraits for vectors. This struct covers both @@ -233,6 +249,8 @@ struct CallbackOutputTraits< std::vector<pp::Var> > { static inline std::vector<pp::Var>& StorageToPluginArg(StorageType& t) { return t.output(); } + + static inline void Initialize(StorageType* /* t */) {} }; } // namespace internal |