summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-11 01:10:08 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-11 01:10:08 +0000
commitd06ae7f5db8269e16b89635c905a84d66695476b (patch)
treebc9c0e4f0c1eed6ededca3045f93f83b11c97de0 /ppapi/cpp
parentce542d57833d7d579c924d7145cfc24ad013828d (diff)
downloadchromium_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')
-rw-r--r--ppapi/cpp/dev/truetype_font_dev.h8
-rw-r--r--ppapi/cpp/directory_entry.h2
-rw-r--r--ppapi/cpp/extensions/ext_output_traits.h4
-rw-r--r--ppapi/cpp/output_traits.h18
-rw-r--r--ppapi/cpp/private/pass_file_handle.h6
-rw-r--r--ppapi/cpp/private/video_frame_private.h7
6 files changed, 45 insertions, 0 deletions
diff --git a/ppapi/cpp/dev/truetype_font_dev.h b/ppapi/cpp/dev/truetype_font_dev.h
index cdaeade..bd554f7 100644
--- a/ppapi/cpp/dev/truetype_font_dev.h
+++ b/ppapi/cpp/dev/truetype_font_dev.h
@@ -208,6 +208,12 @@ struct CallbackOutputTraits<TrueTypeFontDesc_Dev> {
static inline TrueTypeFontDesc_Dev StorageToPluginArg(StorageType& t) {
return TrueTypeFontDesc_Dev(PASS_REF, t);
}
+
+ static inline void Initialize(StorageType* t) {
+ // Use the same defaults as TrueTypeFontDesc_Dev does.
+ TrueTypeFontDesc_Dev dummy;
+ *t = dummy.pp_desc();
+ }
};
class TrueTypeFontDescArrayOutputAdapterWithStorage
@@ -255,6 +261,8 @@ struct CallbackOutputTraits< std::vector<TrueTypeFontDesc_Dev> > {
StorageType& t) {
return t.output();
}
+
+ static inline void Initialize(StorageType* /* t */) {}
};
} // namespace internal
diff --git a/ppapi/cpp/directory_entry.h b/ppapi/cpp/directory_entry.h
index 81be79e..bf3d845 100644
--- a/ppapi/cpp/directory_entry.h
+++ b/ppapi/cpp/directory_entry.h
@@ -119,6 +119,8 @@ struct CallbackOutputTraits< std::vector<DirectoryEntry> > {
StorageType& t) {
return t.output();
}
+
+ static inline void Initialize(StorageType* /* t */) {}
};
} // namespace internal
diff --git a/ppapi/cpp/extensions/ext_output_traits.h b/ppapi/cpp/extensions/ext_output_traits.h
index 08dc744c..ed57be1 100644
--- a/ppapi/cpp/extensions/ext_output_traits.h
+++ b/ppapi/cpp/extensions/ext_output_traits.h
@@ -68,6 +68,8 @@ struct ExtCallbackOutputTraits {
static inline T& StorageToPluginArg(StorageType& t) {
return t.output();
}
+
+ static inline void Initialize(StorageType* /* t */) {}
};
// This class provides storage for a PP_Var and a vector of objects which are
@@ -129,6 +131,8 @@ struct ExtCallbackOutputTraits< std::vector<T> > {
static inline std::vector<T>& StorageToPluginArg(StorageType& t) {
return t.output();
}
+
+ static inline void Initialize(StorageType* /* t */) {}
};
} // namespace internal
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
diff --git a/ppapi/cpp/private/pass_file_handle.h b/ppapi/cpp/private/pass_file_handle.h
index 53f32dd..c25353b 100644
--- a/ppapi/cpp/private/pass_file_handle.h
+++ b/ppapi/cpp/private/pass_file_handle.h
@@ -5,6 +5,8 @@
#ifndef PPAPI_CPP_PRIVATE_PASS_FILE_HANDLE_H_
#define PPAPI_CPP_PRIVATE_PASS_FILE_HANDLE_H_
+#include <string.h>
+
#include "ppapi/c/private/pp_file_handle.h"
#include "ppapi/cpp/output_traits.h"
@@ -67,6 +69,10 @@ struct CallbackOutputTraits<PassFileHandle> {
static inline PassFileHandle StorageToPluginArg(StorageType& t) {
return PassFileHandle(t);
}
+
+ static inline void Initialize(StorageType* t) {
+ memset(t, 0, sizeof(*t));
+ }
};
} // namespace internal
diff --git a/ppapi/cpp/private/video_frame_private.h b/ppapi/cpp/private/video_frame_private.h
index fed9d1d..7413876 100644
--- a/ppapi/cpp/private/video_frame_private.h
+++ b/ppapi/cpp/private/video_frame_private.h
@@ -5,6 +5,8 @@
#ifndef PPAPI_CPP_PRIVATE_VIDEO_FRAME_PRIVATE_H_
#define PPAPI_CPP_PRIVATE_VIDEO_FRAME_PRIVATE_H_
+#include <string.h>
+
#include "ppapi/c/pp_time.h"
#include "ppapi/c/private/pp_video_frame_private.h"
#include "ppapi/cpp/completion_callback.h"
@@ -87,6 +89,11 @@ struct CallbackOutputTraits<pp::VideoFrame_Private> {
static inline pp::VideoFrame_Private StorageToPluginArg(StorageType& t) {
return pp::VideoFrame_Private(PASS_REF, t);
}
+
+ static inline void Initialize(StorageType* t) {
+ VideoFrame_Private dummy;
+ *t = dummy.pp_video_frame();
+ }
};
} // namespace internal