diff options
-rw-r--r-- | ppapi/cpp/dev/truetype_font_dev.h | 8 | ||||
-rw-r--r-- | ppapi/cpp/directory_entry.h | 2 | ||||
-rw-r--r-- | ppapi/cpp/extensions/ext_output_traits.h | 4 | ||||
-rw-r--r-- | ppapi/cpp/output_traits.h | 18 | ||||
-rw-r--r-- | ppapi/cpp/private/pass_file_handle.h | 6 | ||||
-rw-r--r-- | ppapi/cpp/private/video_frame_private.h | 7 | ||||
-rw-r--r-- | ppapi/tests/test_network_proxy.cc | 6 | ||||
-rw-r--r-- | ppapi/tests/test_utils.h | 19 | ||||
-rw-r--r-- | ppapi/utility/completion_callback_factory.h | 8 |
9 files changed, 69 insertions, 9 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 diff --git a/ppapi/tests/test_network_proxy.cc b/ppapi/tests/test_network_proxy.cc index 62a4872..24ec9f1 100644 --- a/ppapi/tests/test_network_proxy.cc +++ b/ppapi/tests/test_network_proxy.cc @@ -60,8 +60,7 @@ std::string TestNetworkProxy::TestGetProxyForURL() { callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); - // TODO(dmichael): Add this check below when crbug.com/250046 is fixed. - // ASSERT_TRUE(callback.output().is_undefined()); + ASSERT_TRUE(callback.output().is_undefined()); callback.WaitForResult( pp::NetworkProxy::GetProxyForURL(instance_, @@ -69,8 +68,7 @@ std::string TestNetworkProxy::TestGetProxyForURL() { callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); - // TODO(dmichael): Add this check below when crbug.com/250046 is fixed. - // ASSERT_TRUE(callback.output().is_undefined()); + ASSERT_TRUE(callback.output().is_undefined()); PASS(); } diff --git a/ppapi/tests/test_utils.h b/ppapi/tests/test_utils.h index 8cd32d5..357a1c6 100644 --- a/ppapi/tests/test_utils.h +++ b/ppapi/tests/test_utils.h @@ -188,16 +188,22 @@ template <typename OutputT, typename CallbackT> class TestCompletionCallbackWithOutputBase { public: explicit TestCompletionCallbackWithOutputBase(PP_Instance instance) - : callback_(instance) { + : callback_(instance), + output_storage_() { + CallbackT::TraitsType::Initialize(&output_storage_); } TestCompletionCallbackWithOutputBase(PP_Instance instance, bool force_async) - : callback_(instance, force_async) { + : callback_(instance, force_async), + output_storage_() { + CallbackT::TraitsType::Initialize(&output_storage_); } TestCompletionCallbackWithOutputBase(PP_Instance instance, CallbackType callback_type) - : callback_(instance, callback_type) { + : callback_(instance, callback_type), + output_storage_() { + CallbackT::TraitsType::Initialize(&output_storage_); } CallbackT GetCallback(); @@ -217,7 +223,10 @@ class TestCompletionCallbackWithOutputBase { bool failed() { return callback_.failed(); } const std::string& errors() { return callback_.errors(); } int32_t result() const { return callback_.result(); } - void Reset() { return callback_.Reset(); } + void Reset() { + CallbackT::TraitsType::Initialize(&output_storage_); + return callback_.Reset(); + } private: TestCompletionCallback callback_; @@ -227,7 +236,7 @@ class TestCompletionCallbackWithOutputBase { template <typename OutputT, typename CallbackT> CallbackT TestCompletionCallbackWithOutputBase<OutputT, CallbackT>::GetCallback() { - callback_.Reset(); + this->Reset(); if (callback_.callback_type() == PP_BLOCKING) { CallbackT cc(&output_storage_); return cc; diff --git a/ppapi/utility/completion_callback_factory.h b/ppapi/utility/completion_callback_factory.h index 37d787e..3af860a 100644 --- a/ppapi/utility/completion_callback_factory.h +++ b/ppapi/utility/completion_callback_factory.h @@ -728,10 +728,12 @@ class CompletionCallbackFactory { DispatcherWithOutput0() : method_(NULL), output_() { + Traits::Initialize(&output_); } DispatcherWithOutput0(Method method) : method_(method), output_() { + Traits::Initialize(&output_); } void operator()(T* object, int32_t result) { // We must call Traits::StorageToPluginArg() even if we don't need to call @@ -779,11 +781,13 @@ class CompletionCallbackFactory { : method_(NULL), a_(), output_() { + Traits::Initialize(&output_); } DispatcherWithOutput1(Method method, const A& a) : method_(method), a_(a), output_() { + Traits::Initialize(&output_); } void operator()(T* object, int32_t result) { // We must call Traits::StorageToPluginArg() even if we don't need to call @@ -840,12 +844,14 @@ class CompletionCallbackFactory { a_(), b_(), output_() { + Traits::Initialize(&output_); } DispatcherWithOutput2(Method method, const A& a, const B& b) : method_(method), a_(a), b_(b), output_() { + Traits::Initialize(&output_); } void operator()(T* object, int32_t result) { // We must call Traits::StorageToPluginArg() even if we don't need to call @@ -908,6 +914,7 @@ class CompletionCallbackFactory { b_(), c_(), output_() { + Traits::Initialize(&output_); } DispatcherWithOutput3(Method method, const A& a, const B& b, const C& c) : method_(method), @@ -915,6 +922,7 @@ class CompletionCallbackFactory { b_(b), c_(c), output_() { + Traits::Initialize(&output_); } void operator()(T* object, int32_t result) { // We must call Traits::StorageToPluginArg() even if we don't need to call |