summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/completion_callback.h
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-30 21:54:43 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-30 21:54:43 +0000
commit09bd7bc27cf7544bdfb58fe0e21465b6485d599e (patch)
treeae66b0506d572fe287577288292cb3ae43ae68fd /ppapi/cpp/completion_callback.h
parent7ed04df055beabf2300c1163be8e59812ecfb7bf (diff)
downloadchromium_src-09bd7bc27cf7544bdfb58fe0e21465b6485d599e.zip
chromium_src-09bd7bc27cf7544bdfb58fe0e21465b6485d599e.tar.gz
chromium_src-09bd7bc27cf7544bdfb58fe0e21465b6485d599e.tar.bz2
Remove PPB_Ext_Socket_Dev.
BUG=366304,244653,312916,314899 TEST=None Review URL: https://codereview.chromium.org/252923005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267348 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp/completion_callback.h')
-rw-r--r--ppapi/cpp/completion_callback.h170
1 files changed, 31 insertions, 139 deletions
diff --git a/ppapi/cpp/completion_callback.h b/ppapi/cpp/completion_callback.h
index 14d6784..2062180 100644
--- a/ppapi/cpp/completion_callback.h
+++ b/ppapi/cpp/completion_callback.h
@@ -7,7 +7,6 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/cpp/extensions/ext_output_traits.h"
#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/output_traits.h"
@@ -168,50 +167,6 @@ class CompletionCallback {
PP_CompletionCallback cc_;
};
-namespace internal {
-
-/// The base class of [Ext]CompletionCallbackWithOutput.
-///
-/// The template parameter Traits determines the storage type
-/// (OutputStorageType), the output parameter type used by the browser
-/// (APIArgType), and how to map OutputStorageType to APIArgType.
-template <typename T, typename Traits>
-class CompletionCallbackWithOutputBase : public CompletionCallback {
- public:
- typedef typename Traits::StorageType OutputStorageType;
- typedef typename Traits::APIArgType APIArgType;
- typedef Traits TraitsType;
-
- explicit CompletionCallbackWithOutputBase(OutputStorageType* output)
- : CompletionCallback(),
- output_(output) {
- }
-
- CompletionCallbackWithOutputBase(PP_CompletionCallback_Func func,
- void* user_data,
- OutputStorageType* output)
- : CompletionCallback(func, user_data),
- output_(output) {
- }
-
- CompletionCallbackWithOutputBase(PP_CompletionCallback_Func func,
- void* user_data,
- int32_t flags,
- OutputStorageType* output)
- : CompletionCallback(func, user_data, flags),
- output_(output) {
- }
-
- APIArgType output() const {
- return Traits::StorageToAPIArg(*output_);
- }
-
- private:
- OutputStorageType* output_;
-};
-
-} // namespace internal
-
/// A CompletionCallbackWithOutput defines a completion callback that
/// additionally stores a pointer to some output data. Some C++ wrappers
/// take a CompletionCallbackWithOutput when the browser is returning a
@@ -228,37 +183,36 @@ class CompletionCallbackWithOutputBase : public CompletionCallback {
/// it just stores a pointer to it. C++ wrapper objects that accept a
/// CompletionCallbackWithOutput will retrieve this pointer and pass it to
/// the browser as the output parameter.
-template <typename T>
-class CompletionCallbackWithOutput
- : public internal::CompletionCallbackWithOutputBase<
- T, internal::CallbackOutputTraits<T> > {
+template<typename T>
+class CompletionCallbackWithOutput : public CompletionCallback {
public:
- typedef internal::CompletionCallbackWithOutputBase<
- T, internal::CallbackOutputTraits<T> > BaseType;
+ /// The type that will actually be stored in the completion callback. In the
+ /// common case, this will be equal to the template parameter (for example,
+ /// CompletionCallbackWithOutput<int> would obviously take an int*. However,
+ /// resources are passed as PP_Resource, vars as PP_Var, and arrays as our
+ /// special ArrayOutputAdapter object. The CallbackOutputTraits defines
+ /// specializations for all of these cases.
+ typedef typename internal::CallbackOutputTraits<T>::StorageType
+ OutputStorageType;
+ typedef typename internal::CallbackOutputTraits<T>::APIArgType
+ APIArgType;
/// The default constructor will create a blocking
- /// <code>CompletionCallbackWithOutput</code> that references the given output
+ /// <code>CompletionCallback</code> that references the given output
/// data.
///
/// @param[in] output A pointer to the data associated with the callback. The
/// caller must ensure that this pointer outlives the completion callback.
- /// In the common case, <code>OutputStorageType</code> will be equal to the
- /// template parameter T (for example,
- /// <code>CompletionCallbackWithOutput<int></code> would obviously take an
- /// int*. However, resources are passed as PP_Resource, vars as PP_Var, and
- /// arrays as our special ArrayOutputAdapter object.
- /// <code>internal::CallbackOutputTraits</code> defines specializations for
- /// all of these cases.
///
/// <strong>Note:</strong> Blocking completion callbacks are only allowed from
- /// background threads.
- explicit CompletionCallbackWithOutput(
- typename BaseType::OutputStorageType* output)
- : BaseType(output) {
+ /// from background threads.
+ CompletionCallbackWithOutput(OutputStorageType* output)
+ : CompletionCallback(),
+ output_(output) {
}
- /// A constructor for creating a <code>CompletionCallbackWithOutput</code>
- /// that references the given output data.
+ /// A constructor for creating a <code>CompletionCallback</code> that
+ /// references the given output data.
///
/// @param[in] func The function to be called on completion.
/// @param[in] user_data The user data to be passed to the callback function.
@@ -268,12 +222,13 @@ class CompletionCallbackWithOutput
/// caller must ensure that this pointer outlives the completion callback.
CompletionCallbackWithOutput(PP_CompletionCallback_Func func,
void* user_data,
- typename BaseType::OutputStorageType* output)
- : BaseType(func, user_data, output) {
+ OutputStorageType* output)
+ : CompletionCallback(func, user_data),
+ output_(output) {
}
- /// A constructor for creating a <code>CompletionCallbackWithOutput</code>
- /// that references the given output data.
+ /// A constructor for creating a <code>CompletionCallback</code> that
+ /// references the given output data.
///
/// @param[in] func The function to be called on completion.
///
@@ -290,82 +245,19 @@ class CompletionCallbackWithOutput
CompletionCallbackWithOutput(PP_CompletionCallback_Func func,
void* user_data,
int32_t flags,
- typename BaseType::OutputStorageType* output)
- : BaseType(func, user_data, flags, output) {
- }
-};
-
-namespace ext {
-
-/// ExtCompletionCallbackWithOutput is similar to CompletionCallbackWithOutput,
-/// but used by APIs within the pp::ext namespace. Usually it is used with the
-/// CompletionCallbackFactory's NewExtCallbackWithOutput.
-template <typename T>
-class ExtCompletionCallbackWithOutput
- : public ::pp::internal::CompletionCallbackWithOutputBase<
- T, internal::ExtCallbackOutputTraits<T> > {
- public:
- typedef ::pp::internal::CompletionCallbackWithOutputBase<
- T, internal::ExtCallbackOutputTraits<T> > BaseType;
-
- /// The default constructor will create a blocking
- /// <code>ExtCompletionCallbackWithOutput</code> that references the given
- /// output data.
- ///
- /// @param[in] output A pointer to the data associated with the callback. The
- /// caller must ensure that this pointer outlives the completion callback.
- /// <code>OutputStorageType</code> is either
- /// <code>ext::internal::ArrayVarOutputAdapterWithStorage<U></code> (if the
- /// template parameter T is of the form std::vector<U>) or
- /// <code>ext::internal::VarOutputAdapterWithStorage<T></code> (otherwise).
- ///
- /// <strong>Note:</strong> Blocking completion callbacks are only allowed from
- /// background threads.
- explicit ExtCompletionCallbackWithOutput(
- typename BaseType::OutputStorageType* output)
- : BaseType(output) {
+ OutputStorageType* output)
+ : CompletionCallback(func, user_data, flags),
+ output_(output) {
}
- /// A constructor for creating an <code>ExtCompletionCallbackWithOutput</code>
- /// that references the given output data.
- ///
- /// @param[in] func The function to be called on completion.
- /// @param[in] user_data The user data to be passed to the callback function.
- /// This is optional and is typically used to help track state in case of
- /// multiple pending callbacks.
- /// @param[in] output A pointer to the data associated with the callback. The
- /// caller must ensure that this pointer outlives the completion callback.
- ExtCompletionCallbackWithOutput(PP_CompletionCallback_Func func,
- void* user_data,
- typename BaseType::OutputStorageType* output)
- : BaseType(func, user_data, output) {
+ APIArgType output() const {
+ return internal::CallbackOutputTraits<T>::StorageToAPIArg(*output_);
}
- /// A constructor for creating an <code>ExtCompletionCallbackWithOutput</code>
- /// that references the given output data.
- ///
- /// @param[in] func The function to be called on completion.
- ///
- /// @param[in] user_data The user data to be passed to the callback function.
- /// This is optional and is typically used to help track state in case of
- /// multiple pending callbacks.
- ///
- /// @param[in] flags Bit field combination of
- /// <code>PP_CompletionCallback_Flag</code> flags used to control how
- /// non-NULL callbacks are scheduled by asynchronous methods.
- ///
- /// @param[in] output A pointer to the data associated with the callback. The
- /// caller must ensure that this pointer outlives the completion callback.
- ExtCompletionCallbackWithOutput(PP_CompletionCallback_Func func,
- void* user_data,
- int32_t flags,
- typename BaseType::OutputStorageType* output)
- : BaseType(func, user_data, flags, output) {
- }
+ private:
+ OutputStorageType* output_;
};
-} // namespace ext
-
/// BlockUntilComplete() is used in place of an actual completion callback
/// to request blocking behavior. If specified, the calling thread will block
/// until the function completes. Blocking completion callbacks are only