summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-04 04:47:25 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-04 04:47:25 +0000
commit6ac20de010f52e367d184f7565f8193cbc901101 (patch)
tree1197bda8b61d5196792ecd5c2e7d0f8bfa1c6760 /ppapi
parentcae9563774d7ad6b230118f52e3a09a2ef6548a9 (diff)
downloadchromium_src-6ac20de010f52e367d184f7565f8193cbc901101.zip
chromium_src-6ac20de010f52e367d184f7565f8193cbc901101.tar.gz
chromium_src-6ac20de010f52e367d184f7565f8193cbc901101.tar.bz2
Revert 116281 - Move paint aggregator and the completion callback factory.
Move paint aggregator and the completion callback factory to the ppapi/helpers directory since they're not strictly wrappers. Review URL: http://codereview.chromium.org/9030001 TBR=brettw@chromium.org Review URL: http://codereview.chromium.org/9086003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116284 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/cpp/completion_callback.h551
-rw-r--r--ppapi/cpp/non_thread_safe_ref_count.h (renamed from ppapi/utility/non_thread_safe_ref_count.h)6
-rw-r--r--ppapi/cpp/paint_aggregator.cc (renamed from ppapi/utility/graphics/paint_aggregator.cc)2
-rw-r--r--ppapi/cpp/paint_aggregator.h (renamed from ppapi/utility/graphics/paint_aggregator.h)6
-rw-r--r--ppapi/cpp/paint_manager.cc (renamed from ppapi/utility/graphics/paint_manager.cc)2
-rw-r--r--ppapi/cpp/paint_manager.h (renamed from ppapi/utility/graphics/paint_manager.h)10
-rw-r--r--ppapi/example/example.cc1
-rw-r--r--ppapi/examples/2d/paint_manager_example.cc2
-rw-r--r--ppapi/examples/2d/scroll.cc4
-rw-r--r--ppapi/examples/audio_input/audio_input.cc2
-rw-r--r--ppapi/examples/file_chooser/file_chooser.cc1
-rw-r--r--ppapi/examples/gles2/gles2.cc1
-rw-r--r--ppapi/examples/mouse_lock/mouse_lock.cc2
-rw-r--r--ppapi/examples/url_loader/streaming.cc2
-rw-r--r--ppapi/examples/video_capture/video_capture.cc1
-rw-r--r--ppapi/native_client/src/trusted/plugin/file_downloader.h2
-rw-r--r--ppapi/native_client/src/trusted/plugin/pnacl_resources.h3
-rw-r--r--ppapi/ppapi_sources.gypi13
-rw-r--r--ppapi/proxy/ppb_audio_input_proxy.h2
-rw-r--r--ppapi/proxy/ppb_audio_proxy.h2
-rw-r--r--ppapi/proxy/ppb_broker_proxy.h2
-rw-r--r--ppapi/proxy/ppb_file_chooser_proxy.h2
-rw-r--r--ppapi/proxy/ppb_file_io_proxy.h1
-rw-r--r--ppapi/proxy/ppb_file_ref_proxy.h2
-rw-r--r--ppapi/proxy/ppb_file_system_proxy.h2
-rw-r--r--ppapi/proxy/ppb_flash_menu_proxy.h1
-rw-r--r--ppapi/proxy/ppb_flash_net_connector_proxy.h2
-rw-r--r--ppapi/proxy/ppb_graphics_2d_proxy.h2
-rw-r--r--ppapi/proxy/ppb_graphics_3d_proxy.h2
-rw-r--r--ppapi/proxy/ppb_instance_proxy.h2
-rw-r--r--ppapi/proxy/ppb_url_loader_proxy.h2
-rw-r--r--ppapi/proxy/ppb_video_decoder_proxy.h2
-rw-r--r--ppapi/tests/DEPS1
-rw-r--r--ppapi/tests/all_cpp_includes.h6
-rw-r--r--ppapi/tests/test_flash.h2
-rw-r--r--ppapi/tests/test_paint_aggregator.cc2
-rw-r--r--ppapi/tests/test_transport.cc2
-rw-r--r--ppapi/tests/testing_instance.h2
-rw-r--r--ppapi/utility/DEPS14
-rw-r--r--ppapi/utility/README.txt2
-rw-r--r--ppapi/utility/completion_callback_factory.h564
41 files changed, 596 insertions, 636 deletions
diff --git a/ppapi/cpp/completion_callback.h b/ppapi/cpp/completion_callback.h
index b4564e1..2e5f38b 100644
--- a/ppapi/cpp/completion_callback.h
+++ b/ppapi/cpp/completion_callback.h
@@ -8,7 +8,7 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/logging.h"
-#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/non_thread_safe_ref_count.h"
/// @file
/// This file defines the API to create and run a callback.
@@ -156,6 +156,555 @@ class CompletionCallback {
/// @return A <code>CompletionCallback</code> corresponding to a NULL callback.
CompletionCallback BlockUntilComplete();
+/// CompletionCallbackFactory<T> may be used to create CompletionCallback
+/// objects that are bound to member functions.
+///
+/// If a factory is destroyed, then any pending callbacks will be cancelled
+/// preventing any bound member functions from being called. The CancelAll()
+/// method allows pending callbacks to be cancelled without destroying the
+/// factory.
+///
+/// <strong>Note: </strong><code>CompletionCallbackFactory<T></code> isn't
+/// thread safe, but you can make it more thread-friendly by passing a
+/// thread-safe refcounting class as the second template element. However, it
+/// only guarantees safety for creating a callback from another thread, the
+/// callback itself needs to execute on the same thread as the thread that
+/// creates/destroys the factory. With this restriction, it is safe to create
+/// the <code>CompletionCallbackFactory</code> on the main thread, create
+/// callbacks from any thread and pass them to CallOnMainThread().
+///
+/// <strong>Example: </strong>
+///
+/// @code
+///
+/// class MyHandler {
+/// public:
+/// // If an compiler warns on following using |this| in the initializer
+/// // list, use PP_ALLOW_THIS_IN_INITIALIZER_LIST macro.
+/// MyHandler() : factory_(this), offset_(0) {
+/// }
+///
+/// void ProcessFile(const FileRef& file) {
+/// CompletionCallback cc = factory_.NewRequiredCallback(
+/// &MyHandler::DidOpen);
+/// int32_t rv = fio_.Open(file, PP_FileOpenFlag_Read, cc);
+/// CHECK(rv == PP_OK_COMPLETIONPENDING);
+/// }
+///
+/// private:
+/// CompletionCallback NewCallback() {
+/// return factory_.NewCallback(&MyHandler::DidCompleteIO);
+/// }
+///
+/// void DidOpen(int32_t result) {
+/// if (result == PP_OK) {
+/// // The file is open, and we can begin reading.
+/// offset_ = 0;
+/// ReadMore();
+/// } else {
+/// // Failed to open the file with error given by 'result'.
+/// }
+/// }
+///
+/// void DidRead(int32_t result) {
+/// if (result > 0) {
+/// // buf_ now contains 'result' number of bytes from the file.
+/// ProcessBytes(buf_, result);
+/// offset_ += result;
+/// ReadMore();
+/// } else {
+/// // Done reading (possibly with an error given by 'result').
+/// }
+/// }
+///
+/// void ReadMore() {
+/// CompletionCallback cc =
+/// factory_.NewOptionalCallback(&MyHandler::DidRead);
+/// int32_t rv = fio_.Read(offset_, buf_, sizeof(buf_),
+/// cc.pp_completion_callback());
+/// if (rv != PP_OK_COMPLETIONPENDING)
+/// cc.Run(rv);
+/// }
+///
+/// void ProcessBytes(const char* bytes, int32_t length) {
+/// // Do work ...
+/// }
+///
+/// pp::CompletionCallbackFactory<MyHandler> factory_;
+/// pp::FileIO fio_;
+/// char buf_[4096];
+/// int64_t offset_;
+/// };
+///
+/// @endcode
+///
+template <typename T, typename RefCount = NonThreadSafeRefCount>
+class CompletionCallbackFactory {
+ public:
+
+ /// This constructor creates a <code>CompletionCallbackFactory</code>
+ /// bound to an object. If the constructor is called without an argument,
+ /// the default value of <code>NULL</code> is used. The user then must call
+ /// Initialize() to initialize the object.
+ ///
+ /// param[in] object Optional parameter. An object whose member functions
+ /// are to be bound to CompletionCallbacks created by this
+ /// <code>CompletionCallbackFactory</code>. The default value of this
+ /// parameter is <code>NULL</code>.
+ explicit CompletionCallbackFactory(T* object = NULL)
+ : object_(object) {
+ InitBackPointer();
+ }
+
+ /// Destructor.
+ ~CompletionCallbackFactory() {
+ ResetBackPointer();
+ }
+
+ /// CancelAll() cancels all <code>CompletionCallbacks</code> allocated from
+ /// this factory.
+ void CancelAll() {
+ ResetBackPointer();
+ InitBackPointer();
+ }
+ /// Initialize() binds the <code>CallbackFactory</code> to a particular
+ /// object. Use this when the object is not available at
+ /// <code>CallbackFactory</code> creation, and the <code>NULL</code> default
+ /// is passed to the constructor. The object may only be initialized once,
+ /// either by the constructor, or by a call to Initialize().
+ ///
+ /// @param[in] object The object whose member functions are to be bound to
+ /// the <code>CompletionCallback</code> created by this
+ /// <code>CompletionCallbackFactory</code>.
+ void Initialize(T* object) {
+ PP_DCHECK(object);
+ PP_DCHECK(!object_); // May only initialize once!
+ object_ = object;
+ }
+
+ /// GetObject() returns the object that was passed at initialization to
+ /// Intialize().
+ ///
+ /// @return the object passed to the constructor or Intialize().
+ T* GetObject() {
+ return object_;
+ }
+
+ /// NewCallback allocates a new, single-use <code>CompletionCallback</code>.
+ /// The <code>CompletionCallback</code> must be run in order for the memory
+ /// allocated by the methods to be freed.
+ /// NewCallback() is equivalent to NewRequiredCallback() below.
+ ///
+ /// @param[in] method The method to be invoked upon completion of the
+ /// operation.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method>
+ CompletionCallback NewCallback(Method method) {
+ PP_DCHECK(object_);
+ return NewCallbackHelper(Dispatcher0<Method>(method));
+ }
+
+ /// NewRequiredCallback() allocates a new, single-use
+ /// <code>CompletionCallback</code> that will always run. The
+ /// <code>CompletionCallback</code> must be run in order for the memory
+ /// allocated by the methods to be freed.
+ ///
+ /// @param[in] method The method to be invoked upon completion of the
+ /// operation.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method>
+ CompletionCallback NewRequiredCallback(Method method) {
+ CompletionCallback cc = NewCallback(method);
+ cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
+ /// NewOptionalCallback() allocates a new, single-use
+ /// <code>CompletionCallback</code> that might not run if the method
+ /// taking it can complete synchronously. Thus, if after passing the
+ /// CompletionCallback to a Pepper method, the method does not return
+ /// PP_OK_COMPLETIONPENDING, then you should manually call the
+ /// CompletionCallback's Run method, or memory will be leaked.
+ ///
+ /// @param[in] method The method to be invoked upon completion of the
+ /// operation.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method>
+ CompletionCallback NewOptionalCallback(Method method) {
+ CompletionCallback cc = NewCallback(method);
+ cc.set_flags(cc.flags() | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
+ /// NewCallback() allocates a new, single-use <code>CompletionCallback</code>.
+ /// The <code>CompletionCallback</code> must be run in order for the memory
+ /// allocated by the methods to be freed.
+ /// NewCallback() is equivalent to NewRequiredCallback() below.
+ ///
+ /// @param[in] method The method to be invoked upon completion of the
+ /// operation. Method should be of type:
+ /// <code>void (T::*)(int32_t result, const A& a)</code>
+ ///
+ /// @param[in] a Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method, typename A>
+ CompletionCallback NewCallback(Method method, const A& a) {
+ PP_DCHECK(object_);
+ return NewCallbackHelper(Dispatcher1<Method, A>(method, a));
+ }
+
+ /// NewRequiredCallback() allocates a new, single-use
+ /// <code>CompletionCallback</code> that will always run. The
+ /// <code>CompletionCallback</code> must be run in order for the memory
+ /// allocated by the methods to be freed.
+ ///
+ /// @param[in] method The method to be invoked upon completion of the
+ /// operation. Method should be of type:
+ /// <code>void (T::*)(int32_t result, const A& a)</code>
+ ///
+ /// @param[in] a Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method, typename A>
+ CompletionCallback NewRequiredCallback(Method method, const A& a) {
+ CompletionCallback cc = NewCallback(method, a);
+ cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
+ /// NewOptionalCallback() allocates a new, single-use
+ /// <code>CompletionCallback</code> that might not run if the method
+ /// taking it can complete synchronously. Thus, if after passing the
+ /// CompletionCallback to a Pepper method, the method does not return
+ /// PP_OK_COMPLETIONPENDING, then you should manually call the
+ /// CompletionCallback's Run method, or memory will be leaked.
+ ///
+ /// @param[in] method The method to be invoked upon completion of the
+ /// operation. Method should be of type:
+ /// <code>void (T::*)(int32_t result, const A& a)</code>
+ ///
+ /// @param[in] a Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method, typename A>
+ CompletionCallback NewOptionalCallback(Method method, const A& a) {
+ CompletionCallback cc = NewCallback(method, a);
+ cc.set_flags(cc.flags() | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
+ /// NewCallback() allocates a new, single-use
+ /// <code>CompletionCallback</code>.
+ /// The <code>CompletionCallback</code> must be run in order for the memory
+ /// allocated by the methods to be freed.
+ /// NewCallback() is equivalent to NewRequiredCallback() below.
+ ///
+ /// @param method The method taking the callback. Method should be of type:
+ /// <code>void (T::*)(int32_t result, const A& a, const B& b)</code>
+ ///
+ /// @param[in] a Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @param[in] b Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method, typename A, typename B>
+ CompletionCallback NewCallback(Method method, const A& a, const B& b) {
+ PP_DCHECK(object_);
+ return NewCallbackHelper(Dispatcher2<Method, A, B>(method, a, b));
+ }
+
+ /// NewRequiredCallback() allocates a new, single-use
+ /// <code>CompletionCallback</code> that will always run. The
+ /// <code>CompletionCallback</code> must be run in order for the memory
+ /// allocated by the methods to be freed.
+ ///
+ /// @param method The method taking the callback. Method should be of type:
+ /// <code>void (T::*)(int32_t result, const A& a, const B& b)</code>
+ ///
+ /// @param[in] a Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @param[in] b Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method, typename A, typename B>
+ CompletionCallback NewRequiredCallback(Method method, const A& a,
+ const B& b) {
+ CompletionCallback cc = NewCallback(method, a, b);
+ cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
+ /// NewOptionalCallback() allocates a new, single-use
+ /// <code>CompletionCallback</code> that might not run if the method
+ /// taking it can complete synchronously. Thus, if after passing the
+ /// CompletionCallback to a Pepper method, the method does not return
+ /// PP_OK_COMPLETIONPENDING, then you should manually call the
+ /// CompletionCallback's Run method, or memory will be leaked.
+ ///
+ /// @param[in] method The method taking the callback. Method should be of
+ /// type:
+ /// <code>void (T::*)(int32_t result, const A& a, const B& b)</code>
+ ///
+ /// @param[in] a Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @param[in] b Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method, typename A, typename B>
+ CompletionCallback NewOptionalCallback(Method method, const A& a,
+ const B& b) {
+ CompletionCallback cc = NewCallback(method, a, b);
+ cc.set_flags(cc.flags() | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
+ /// NewCallback() allocates a new, single-use
+ /// <code>CompletionCallback</code>.
+ /// The <code>CompletionCallback</code> must be run in order for the memory
+ /// allocated by the methods to be freed.
+ /// NewCallback() is equivalent to NewRequiredCallback() below.
+ ///
+ /// @param method The method taking the callback. Method should be of type:
+ /// <code>
+ /// void (T::*)(int32_t result, const A& a, const B& b, const C& c)
+ /// </code>
+ ///
+ /// @param[in] a Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @param[in] b Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @param[in] c Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method, typename A, typename B, typename C>
+ CompletionCallback NewCallback(Method method, const A& a, const B& b,
+ const C& c) {
+ PP_DCHECK(object_);
+ return NewCallbackHelper(Dispatcher3<Method, A, B, C>(method, a, b, c));
+ }
+
+ /// NewRequiredCallback() allocates a new, single-use
+ /// <code>CompletionCallback</code> that will always run. The
+ /// <code>CompletionCallback</code> must be run in order for the memory
+ /// allocated by the methods to be freed.
+ ///
+ /// @param method The method taking the callback. Method should be of type:
+ /// <code>
+ /// void (T::*)(int32_t result, const A& a, const B& b, const C& c)
+ /// </code>
+ ///
+ /// @param[in] a Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @param[in] b Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @param[in] c Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method, typename A, typename B, typename C>
+ CompletionCallback NewRequiredCallback(Method method, const A& a,
+ const B& b, const C& c) {
+ CompletionCallback cc = NewCallback(method, a, b, c);
+ cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
+ /// NewOptionalCallback() allocates a new, single-use
+ /// <code>CompletionCallback</code> that might not run if the method
+ /// taking it can complete synchronously. Thus, if after passing the
+ /// CompletionCallback to a Pepper method, the method does not return
+ /// PP_OK_COMPLETIONPENDING, then you should manually call the
+ /// CompletionCallback's Run method, or memory will be leaked.
+ ///
+ /// @param[in] method The method taking the callback. Method should be of
+ /// type:
+ /// <code>
+ /// void (T::*)(int32_t result, const A& a, const B& b, const C& c)
+ /// </code>
+ ///
+ /// @param[in] a Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @param[in] b Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @param[in] c Passed to <code>method</code> when the completion callback
+ /// runs.
+ ///
+ /// @return A <code>CompletionCallback</code>.
+ template <typename Method, typename A, typename B, typename C>
+ CompletionCallback NewOptionalCallback(Method method, const A& a,
+ const B& b, const C& c) {
+ CompletionCallback cc = NewCallback(method, a, b, c);
+ cc.set_flags(cc.flags() | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
+ private:
+ class BackPointer {
+ public:
+ typedef CompletionCallbackFactory<T, RefCount> FactoryType;
+
+ BackPointer(FactoryType* factory)
+ : factory_(factory) {
+ }
+
+ void AddRef() {
+ ref_.AddRef();
+ }
+
+ void Release() {
+ if (ref_.Release() == 0)
+ delete this;
+ }
+
+ void DropFactory() {
+ factory_ = NULL;
+ }
+
+ T* GetObject() {
+ return factory_ ? factory_->GetObject() : NULL;
+ }
+
+ private:
+ RefCount ref_;
+ FactoryType* factory_;
+ };
+
+ template <typename Dispatcher>
+ class CallbackData {
+ public:
+ CallbackData(BackPointer* back_pointer, const Dispatcher& dispatcher)
+ : back_pointer_(back_pointer),
+ dispatcher_(dispatcher) {
+ back_pointer_->AddRef();
+ }
+
+ ~CallbackData() {
+ back_pointer_->Release();
+ }
+
+ static void Thunk(void* user_data, int32_t result) {
+ Self* self = static_cast<Self*>(user_data);
+ T* object = self->back_pointer_->GetObject();
+ if (object)
+ self->dispatcher_(object, result);
+ delete self;
+ }
+
+ private:
+ typedef CallbackData<Dispatcher> Self;
+ BackPointer* back_pointer_;
+ Dispatcher dispatcher_;
+ };
+
+ template <typename Method>
+ class Dispatcher0 {
+ public:
+ Dispatcher0(Method method) : method_(method) {
+ }
+ void operator()(T* object, int32_t result) {
+ (object->*method_)(result);
+ }
+ private:
+ Method method_;
+ };
+
+ template <typename Method, typename A>
+ class Dispatcher1 {
+ public:
+ Dispatcher1(Method method, const A& a)
+ : method_(method),
+ a_(a) {
+ }
+ void operator()(T* object, int32_t result) {
+ (object->*method_)(result, a_);
+ }
+ private:
+ Method method_;
+ A a_;
+ };
+
+ template <typename Method, typename A, typename B>
+ class Dispatcher2 {
+ public:
+ Dispatcher2(Method method, const A& a, const B& b)
+ : method_(method),
+ a_(a),
+ b_(b) {
+ }
+ void operator()(T* object, int32_t result) {
+ (object->*method_)(result, a_, b_);
+ }
+ private:
+ Method method_;
+ A a_;
+ B b_;
+ };
+
+ template <typename Method, typename A, typename B, typename C>
+ class Dispatcher3 {
+ public:
+ Dispatcher3(Method method, const A& a, const B& b, const C& c)
+ : method_(method),
+ a_(a),
+ b_(b),
+ c_(c) {
+ }
+ void operator()(T* object, int32_t result) {
+ (object->*method_)(result, a_, b_, c_);
+ }
+ private:
+ Method method_;
+ A a_;
+ B b_;
+ C c_;
+ };
+
+ void InitBackPointer() {
+ back_pointer_ = new BackPointer(this);
+ back_pointer_->AddRef();
+ }
+
+ void ResetBackPointer() {
+ back_pointer_->DropFactory();
+ back_pointer_->Release();
+ }
+
+ template <typename Dispatcher>
+ CompletionCallback NewCallbackHelper(const Dispatcher& dispatcher) {
+ PP_DCHECK(object_); // Expects a non-null object!
+ return CompletionCallback(
+ &CallbackData<Dispatcher>::Thunk,
+ new CallbackData<Dispatcher>(back_pointer_, dispatcher));
+ }
+
+ // Disallowed:
+ CompletionCallbackFactory(const CompletionCallbackFactory&);
+ CompletionCallbackFactory& operator=(const CompletionCallbackFactory&);
+
+ T* object_;
+ BackPointer* back_pointer_;
+};
+
} // namespace pp
#endif // PPAPI_CPP_COMPLETION_CALLBACK_H_
diff --git a/ppapi/utility/non_thread_safe_ref_count.h b/ppapi/cpp/non_thread_safe_ref_count.h
index db00b7d..0844eb7 100644
--- a/ppapi/utility/non_thread_safe_ref_count.h
+++ b/ppapi/cpp/non_thread_safe_ref_count.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef PPAPI_UTILITY_NON_THREAD_SAFE_REF_COUNT_H_
-#define PPAPI_UTILITY_NON_THREAD_SAFE_REF_COUNT_H_
+#ifndef PPAPI_CPP_NON_THREAD_SAFE_REF_COUNT_H_
+#define PPAPI_CPP_NON_THREAD_SAFE_REF_COUNT_H_
#include "ppapi/cpp/core.h"
#include "ppapi/cpp/logging.h"
@@ -57,4 +57,4 @@ class NonThreadSafeRefCount {
} // namespace pp
-#endif // PPAPI_UTILITY_NON_THREAD_SAFE_REF_COUNT_H_
+#endif // PPAPI_CPP_NON_THREAD_SAFE_REF_COUNT_H_
diff --git a/ppapi/utility/graphics/paint_aggregator.cc b/ppapi/cpp/paint_aggregator.cc
index d4fc721..d0ab03e 100644
--- a/ppapi/utility/graphics/paint_aggregator.cc
+++ b/ppapi/cpp/paint_aggregator.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ppapi/utility/graphics/paint_aggregator.h"
+#include "ppapi/cpp/paint_aggregator.h"
#include <algorithm>
diff --git a/ppapi/utility/graphics/paint_aggregator.h b/ppapi/cpp/paint_aggregator.h
index 74e24da..db1e04c 100644
--- a/ppapi/utility/graphics/paint_aggregator.h
+++ b/ppapi/cpp/paint_aggregator.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef PPAPI_UTILITY_GRAPHICS_PAINT_AGGREGATOR_H_
-#define PPAPI_UTILITY_GRAPHICS_PAINT_AGGREGATOR_H_
+#ifndef PPAPI_CPP_PAINT_AGGREGATOR_H_
+#define PPAPI_CPP_PAINT_AGGREGATOR_H_
#include <stddef.h>
#include <vector>
@@ -171,4 +171,4 @@ class PaintAggregator {
} // namespace pp
-#endif // PPAPI_UTILITY_PAINT_AGGREGATOR_H_
+#endif // PPAPI_CPP_PAINT_AGGREGATOR_H_
diff --git a/ppapi/utility/graphics/paint_manager.cc b/ppapi/cpp/paint_manager.cc
index 1141ac6..23f66d5 100644
--- a/ppapi/utility/graphics/paint_manager.cc
+++ b/ppapi/cpp/paint_manager.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ppapi/utility/graphics/paint_manager.h"
+#include "ppapi/cpp/paint_manager.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/instance.h"
diff --git a/ppapi/utility/graphics/paint_manager.h b/ppapi/cpp/paint_manager.h
index c3787e8..fbddd9f 100644
--- a/ppapi/utility/graphics/paint_manager.h
+++ b/ppapi/cpp/paint_manager.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef PPAPI_UTILITY_GRAPHICS_PAINT_MANAGER_H_
-#define PPAPI_UTILITY_GRAPHICS_PAINT_MANAGER_H_
+#ifndef PPAPI_CPP_PAINT_MANAGER_H_
+#define PPAPI_CPP_PAINT_MANAGER_H_
#include <vector>
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/graphics_2d.h"
-#include "ppapi/utility/completion_callback_factory.h"
-#include "ppapi/utility/graphics/paint_aggregator.h"
+#include "ppapi/cpp/paint_aggregator.h"
/// @file
/// This file defines the API to convert the "plugin push" model of painting
@@ -294,4 +294,4 @@ class PaintManager {
} // namespace pp
-#endif // PPAPI_UTILITY_GRAPHICS_PAINT_MANAGER_H_
+#endif // PPAPI_CPP_PAINT_MANAGER_H_
diff --git a/ppapi/example/example.cc b/ppapi/example/example.cc
index 6ba7983..72ca3ac 100644
--- a/ppapi/example/example.cc
+++ b/ppapi/example/example.cc
@@ -32,7 +32,6 @@
#include "ppapi/cpp/url_request_info.h"
#include "ppapi/cpp/var.h"
#include "ppapi/cpp/view.h"
-#include "ppapi/utility/completion_callback_factory.h"
static const int kStepsPerCircle = 800;
diff --git a/ppapi/examples/2d/paint_manager_example.cc b/ppapi/examples/2d/paint_manager_example.cc
index d3530cb..fdf5a8b 100644
--- a/ppapi/examples/2d/paint_manager_example.cc
+++ b/ppapi/examples/2d/paint_manager_example.cc
@@ -8,8 +8,8 @@
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/paint_manager.h"
#include "ppapi/cpp/size.h"
-#include "ppapi/utility/graphics/paint_manager.h"
// Number of pixels to each side of the center of the square that we draw.
static const int kSquareRadius = 2;
diff --git a/ppapi/examples/2d/scroll.cc b/ppapi/examples/2d/scroll.cc
index 5dffa57..f8c365a 100644
--- a/ppapi/examples/2d/scroll.cc
+++ b/ppapi/examples/2d/scroll.cc
@@ -4,14 +4,14 @@
#include <math.h>
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/paint_manager.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/var.h"
-#include "ppapi/utility/completion_callback_factory.h"
-#include "ppapi/utility/graphics/paint_manager.h"
static const int kSquareSpacing = 98;
static const int kSquareSize = 5;
diff --git a/ppapi/examples/audio_input/audio_input.cc b/ppapi/examples/audio_input/audio_input.cc
index 74bc08e..13b1237 100644
--- a/ppapi/examples/audio_input/audio_input.cc
+++ b/ppapi/examples/audio_input/audio_input.cc
@@ -8,6 +8,7 @@
#include <limits>
#include "ppapi/cpp/audio_config.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/audio_input_dev.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/image_data.h"
@@ -16,7 +17,6 @@
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/size.h"
-#include "ppapi/utility/completion_callback_factory.h"
class MyInstance : public pp::Instance {
public:
diff --git a/ppapi/examples/file_chooser/file_chooser.cc b/ppapi/examples/file_chooser/file_chooser.cc
index 136ff31..8c2e675 100644
--- a/ppapi/examples/file_chooser/file_chooser.cc
+++ b/ppapi/examples/file_chooser/file_chooser.cc
@@ -11,7 +11,6 @@
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/private/instance_private.h"
#include "ppapi/cpp/private/var_private.h"
-#include "ppapi/utility/completion_callback_factory.h"
class MyInstance : public pp::InstancePrivate {
public:
diff --git a/ppapi/examples/gles2/gles2.cc b/ppapi/examples/gles2/gles2.cc
index 0de2eda..220a6f4 100644
--- a/ppapi/examples/gles2/gles2.cc
+++ b/ppapi/examples/gles2/gles2.cc
@@ -24,7 +24,6 @@
#include "ppapi/cpp/var.h"
#include "ppapi/examples/gles2/testdata.h"
#include "ppapi/lib/gl/include/GLES2/gl2.h"
-#include "ppapi/utility/completion_callback_factory.h"
// Use assert as a poor-man's CHECK, even in non-debug mode.
// Since <assert.h> redefines assert on every inclusion (it doesn't use
diff --git a/ppapi/examples/mouse_lock/mouse_lock.cc b/ppapi/examples/mouse_lock/mouse_lock.cc
index 6a934ba..68aa4ac 100644
--- a/ppapi/examples/mouse_lock/mouse_lock.cc
+++ b/ppapi/examples/mouse_lock/mouse_lock.cc
@@ -8,6 +8,7 @@
#include "ppapi/c/dev/ppb_console_dev.h"
#include "ppapi/c/ppb_input_event.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/input_event.h"
@@ -17,7 +18,6 @@
#include "ppapi/cpp/mouse_lock.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/var.h"
-#include "ppapi/utility/completion_callback_factory.h"
class MyInstance : public pp::Instance, public pp::MouseLock {
public:
diff --git a/ppapi/examples/url_loader/streaming.cc b/ppapi/examples/url_loader/streaming.cc
index b7186ae..b6df6cb 100644
--- a/ppapi/examples/url_loader/streaming.cc
+++ b/ppapi/examples/url_loader/streaming.cc
@@ -11,12 +11,12 @@
// URLLoader.FinishSthreamingToFile once the "Open" callback is complete, and
// then call URLResponseInfo.GetBodyAsFileRef once the file stream is complete.
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/url_loader.h"
#include "ppapi/cpp/url_request_info.h"
#include "ppapi/cpp/url_response_info.h"
-#include "ppapi/utility/completion_callback_factory.h"
// Buffer size for reading network data.
const int kBufSize = 1024;
diff --git a/ppapi/examples/video_capture/video_capture.cc b/ppapi/examples/video_capture/video_capture.cc
index 63e2cb8..5d474bd 100644
--- a/ppapi/examples/video_capture/video_capture.cc
+++ b/ppapi/examples/video_capture/video_capture.cc
@@ -20,7 +20,6 @@
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/lib/gl/include/GLES2/gl2.h"
-#include "ppapi/utility/completion_callback_factory.h"
// Assert |context_| isn't holding any GL Errors. Done as a macro instead of a
// function to preserve line number information in the failure message.
diff --git a/ppapi/native_client/src/trusted/plugin/file_downloader.h b/ppapi/native_client/src/trusted/plugin/file_downloader.h
index 399db7a..a913527 100644
--- a/ppapi/native_client/src/trusted/plugin/file_downloader.h
+++ b/ppapi/native_client/src/trusted/plugin/file_downloader.h
@@ -11,10 +11,10 @@
#include "native_client/src/include/nacl_string.h"
#include "ppapi/c/trusted/ppb_file_io_trusted.h"
#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/file_io.h"
#include "ppapi/cpp/url_loader.h"
#include "ppapi/cpp/instance.h"
-#include "ppapi/utility/completion_callback_factory.h"
namespace plugin {
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_resources.h b/ppapi/native_client/src/trusted/plugin/pnacl_resources.h
index 2d8b356..f6d35a7 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_resources.h
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_resources.h
@@ -14,7 +14,8 @@
#include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
#include "native_client/src/trusted/plugin/delayed_callback.h"
#include "native_client/src/trusted/plugin/plugin_error.h"
-#include "ppapi/utility/completion_callback_factory.h"
+
+#include "ppapi/cpp/completion_callback.h"
namespace plugin {
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index 69ed449..84b354d 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -151,6 +151,11 @@
'cpp/module_impl.h',
'cpp/mouse_lock.cc',
'cpp/mouse_lock.h',
+ 'cpp/non_thread_safe_ref_count.h',
+ 'cpp/paint_aggregator.cc',
+ 'cpp/paint_aggregator.h',
+ 'cpp/paint_manager.cc',
+ 'cpp/paint_manager.h',
'cpp/point.h',
'cpp/rect.cc',
'cpp/rect.h',
@@ -247,14 +252,6 @@
'cpp/trusted/file_chooser_trusted.h',
'cpp/trusted/file_io_trusted.cc',
'cpp/trusted/file_io_trusted.h',
-
- # Utility sources.
- 'utility/completion_callback_factory.h',
- 'utility/non_thread_safe_ref_count.h',
- 'utility/graphics/paint_aggregator.cc',
- 'utility/graphics/paint_aggregator.h',
- 'utility/graphics/paint_manager.cc',
- 'utility/graphics/paint_manager.h',
],
#
# Common Testing source for trusted and untrusted (NaCl) pugins.
diff --git a/ppapi/proxy/ppb_audio_input_proxy.h b/ppapi/proxy/ppb_audio_input_proxy.h
index 5fb6637..6244e55 100644
--- a/ppapi/proxy/ppb_audio_input_proxy.h
+++ b/ppapi/proxy/ppb_audio_input_proxy.h
@@ -13,9 +13,9 @@
#include "ipc/ipc_platform_file.h"
#include "ppapi/c/dev/ppb_audio_input_dev.h"
#include "ppapi/c/ppb_audio_config.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
-#include "ppapi/utility/completion_callback_factory.h"
struct PPB_AudioInput_Dev;
diff --git a/ppapi/proxy/ppb_audio_proxy.h b/ppapi/proxy/ppb_audio_proxy.h
index 590f7e7..feee8dc 100644
--- a/ppapi/proxy/ppb_audio_proxy.h
+++ b/ppapi/proxy/ppb_audio_proxy.h
@@ -16,9 +16,9 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/ppb_audio.h"
#include "ppapi/c/ppb_audio_config.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
-#include "ppapi/utility/completion_callback_factory.h"
struct PPB_Audio;
diff --git a/ppapi/proxy/ppb_broker_proxy.h b/ppapi/proxy/ppb_broker_proxy.h
index a04903c7..d2f039a 100644
--- a/ppapi/proxy/ppb_broker_proxy.h
+++ b/ppapi/proxy/ppb_broker_proxy.h
@@ -8,9 +8,9 @@
#include "base/sync_socket.h"
#include "ipc/ipc_platform_file.h"
#include "ppapi/c/pp_instance.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
-#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
diff --git a/ppapi/proxy/ppb_file_chooser_proxy.h b/ppapi/proxy/ppb_file_chooser_proxy.h
index da45a2c..887a32b 100644
--- a/ppapi/proxy/ppb_file_chooser_proxy.h
+++ b/ppapi/proxy/ppb_file_chooser_proxy.h
@@ -10,10 +10,10 @@
#include "base/basictypes.h"
#include "ppapi/c/pp_instance.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
#include "ppapi/thunk/ppb_file_chooser_api.h"
-#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
diff --git a/ppapi/proxy/ppb_file_io_proxy.h b/ppapi/proxy/ppb_file_io_proxy.h
index 86d822c..fbc8a16 100644
--- a/ppapi/proxy/ppb_file_io_proxy.h
+++ b/ppapi/proxy/ppb_file_io_proxy.h
@@ -11,7 +11,6 @@
#include "ppapi/c/pp_file_info.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
-#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
diff --git a/ppapi/proxy/ppb_file_ref_proxy.h b/ppapi/proxy/ppb_file_ref_proxy.h
index d15536e..c0fa23c 100644
--- a/ppapi/proxy/ppb_file_ref_proxy.h
+++ b/ppapi/proxy/ppb_file_ref_proxy.h
@@ -11,9 +11,9 @@
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_time.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
-#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
diff --git a/ppapi/proxy/ppb_file_system_proxy.h b/ppapi/proxy/ppb_file_system_proxy.h
index 86eb48e..a07b824 100644
--- a/ppapi/proxy/ppb_file_system_proxy.h
+++ b/ppapi/proxy/ppb_file_system_proxy.h
@@ -12,9 +12,9 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_time.h"
#include "ppapi/c/ppb_file_system.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
-#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
diff --git a/ppapi/proxy/ppb_flash_menu_proxy.h b/ppapi/proxy/ppb_flash_menu_proxy.h
index f0b132e..7e72fde 100644
--- a/ppapi/proxy/ppb_flash_menu_proxy.h
+++ b/ppapi/proxy/ppb_flash_menu_proxy.h
@@ -7,7 +7,6 @@
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
-#include "ppapi/utility/completion_callback_factory.h"
struct PP_Flash_Menu;
struct PP_Point;
diff --git a/ppapi/proxy/ppb_flash_net_connector_proxy.h b/ppapi/proxy/ppb_flash_net_connector_proxy.h
index 8d290a1..0f24466 100644
--- a/ppapi/proxy/ppb_flash_net_connector_proxy.h
+++ b/ppapi/proxy/ppb_flash_net_connector_proxy.h
@@ -8,9 +8,9 @@
#include "base/platform_file.h"
#include "ipc/ipc_platform_file.h"
#include "ppapi/c/pp_instance.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
-#include "ppapi/utility/completion_callback_factory.h"
struct PPB_Flash_NetConnector;
diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.h b/ppapi/proxy/ppb_graphics_2d_proxy.h
index a8227f0..2897595 100644
--- a/ppapi/proxy/ppb_graphics_2d_proxy.h
+++ b/ppapi/proxy/ppb_graphics_2d_proxy.h
@@ -12,10 +12,10 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_size.h"
#include "ppapi/c/pp_var.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
#include "ppapi/shared_impl/host_resource.h"
-#include "ppapi/utility/completion_callback_factory.h"
struct PPB_Graphics2D;
struct PP_Point;
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h
index b8c8d09..5a6c334 100644
--- a/ppapi/proxy/ppb_graphics_3d_proxy.h
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.h
@@ -11,11 +11,11 @@
#include "gpu/command_buffer/common/command_buffer.h"
#include "ppapi/c/pp_graphics_3d.h"
#include "ppapi/c/pp_instance.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
#include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
#include "ppapi/shared_impl/resource.h"
-#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h
index a88bd6f..de10f80 100644
--- a/ppapi/proxy/ppb_instance_proxy.h
+++ b/ppapi/proxy/ppb_instance_proxy.h
@@ -8,13 +8,13 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
#include "ppapi/shared_impl/function_group_base.h"
#include "ppapi/shared_impl/host_resource.h"
#include "ppapi/shared_impl/ppb_instance_shared.h"
#include "ppapi/thunk/ppb_instance_api.h"
-#include "ppapi/utility/completion_callback_factory.h"
// Windows headers interfere with this file.
#ifdef PostMessage
diff --git a/ppapi/proxy/ppb_url_loader_proxy.h b/ppapi/proxy/ppb_url_loader_proxy.h
index da35350..e13b1a3 100644
--- a/ppapi/proxy/ppb_url_loader_proxy.h
+++ b/ppapi/proxy/ppb_url_loader_proxy.h
@@ -11,10 +11,10 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_size.h"
#include "ppapi/c/pp_var.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
#include "ppapi/shared_impl/host_resource.h"
-#include "ppapi/utility/completion_callback_factory.h"
struct PPB_URLLoader;
struct PPB_URLLoaderTrusted;
diff --git a/ppapi/proxy/ppb_video_decoder_proxy.h b/ppapi/proxy/ppb_video_decoder_proxy.h
index 7461a1f..1185d16 100644
--- a/ppapi/proxy/ppb_video_decoder_proxy.h
+++ b/ppapi/proxy/ppb_video_decoder_proxy.h
@@ -6,11 +6,11 @@
#define PPAPI_PROXY_PPB_VIDEO_DECODER_PROXY_H_
#include "ppapi/c/pp_instance.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
#include "ppapi/shared_impl/ppb_video_decoder_shared.h"
#include "ppapi/thunk/ppb_video_decoder_api.h"
-#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
namespace proxy {
diff --git a/ppapi/tests/DEPS b/ppapi/tests/DEPS
index e901f41..d679198 100644
--- a/ppapi/tests/DEPS
+++ b/ppapi/tests/DEPS
@@ -10,7 +10,6 @@ include_rules = [
"+ppapi/c",
"+ppapi/cpp",
"+ppapi/tests",
- "+ppapi/utility",
]
# checkdeps.py shouldn't check include paths for files in clang, which aren't
# part of the chrome build.
diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h
index 8ba62a1..ff408b0 100644
--- a/ppapi/tests/all_cpp_includes.h
+++ b/ppapi/tests/all_cpp_includes.h
@@ -47,6 +47,9 @@
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
#include "ppapi/cpp/mouse_lock.h"
+#include "ppapi/cpp/non_thread_safe_ref_count.h"
+#include "ppapi/cpp/paint_aggregator.h"
+#include "ppapi/cpp/paint_manager.h"
#include "ppapi/cpp/private/flash_fullscreen.h"
#include "ppapi/cpp/private/instance_private.h"
#include "ppapi/cpp/point.h"
@@ -57,8 +60,5 @@
#include "ppapi/cpp/url_request_info.h"
#include "ppapi/cpp/url_response_info.h"
#include "ppapi/cpp/var.h"
-#include "ppapi/utility/graphics/paint_aggregator.h"
-#include "ppapi/utility/graphics/paint_manager.h"
-#include "ppapi/utility/non_thread_safe_ref_count.h"
#endif // PPAPI_TESTS_ALL_CPP_INCLUDES_H_
diff --git a/ppapi/tests/test_flash.h b/ppapi/tests/test_flash.h
index 7275ff5..5dfed88 100644
--- a/ppapi/tests/test_flash.h
+++ b/ppapi/tests/test_flash.h
@@ -7,9 +7,9 @@
#include <string>
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/tests/test_case.h"
-#include "ppapi/utility/completion_callback_factory.h"
struct PPB_Flash;
diff --git a/ppapi/tests/test_paint_aggregator.cc b/ppapi/tests/test_paint_aggregator.cc
index a04cff8..77e2174 100644
--- a/ppapi/tests/test_paint_aggregator.cc
+++ b/ppapi/tests/test_paint_aggregator.cc
@@ -4,8 +4,8 @@
#include "ppapi/tests/test_paint_aggregator.h"
+#include "ppapi/cpp/paint_aggregator.h"
#include "ppapi/tests/testing_instance.h"
-#include "ppapi/utility/graphics/paint_aggregator.h"
REGISTER_TEST_CASE(PaintAggregator);
diff --git a/ppapi/tests/test_transport.cc b/ppapi/tests/test_transport.cc
index 7970050..52d072e 100644
--- a/ppapi/tests/test_transport.cc
+++ b/ppapi/tests/test_transport.cc
@@ -13,13 +13,13 @@
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/pp_macros.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/transport_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/var.h"
#include "ppapi/tests/test_utils.h"
#include "ppapi/tests/testing_instance.h"
-#include "ppapi/utility/completion_callback_factory.h"
REGISTER_TEST_CASE(Transport);
diff --git a/ppapi/tests/testing_instance.h b/ppapi/tests/testing_instance.h
index a112c41..397c1c7 100644
--- a/ppapi/tests/testing_instance.h
+++ b/ppapi/tests/testing_instance.h
@@ -7,7 +7,7 @@
#include <string>
-#include "ppapi/utility/completion_callback_factory.h"
+#include "ppapi/cpp/completion_callback.h"
#if defined(__native_client__)
#include "ppapi/cpp/instance.h"
diff --git a/ppapi/utility/DEPS b/ppapi/utility/DEPS
deleted file mode 100644
index 2983acb..0000000
--- a/ppapi/utility/DEPS
+++ /dev/null
@@ -1,14 +0,0 @@
-# ppapi/cpp should not be dependent on other parts of chromium; it should stay
-# browser-neutral as much as possible.
-include_rules = [
- "-base",
- "-build",
- "-ipc",
- "-ppapi",
- "+ppapi/c",
- "-ppapi/c/private",
- "-ppapi/c/trusted",
- "+ppapi/cpp",
- "-ppapi/cpp/private",
- "-ppapi/cpp/trusted",
-]
diff --git a/ppapi/utility/README.txt b/ppapi/utility/README.txt
deleted file mode 100644
index 5b72c93..0000000
--- a/ppapi/utility/README.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-The classes in ppapi/utility are helper classes that provide higher-level
-features on top of the C++ wrappers. Using these classes is optional.
diff --git a/ppapi/utility/completion_callback_factory.h b/ppapi/utility/completion_callback_factory.h
deleted file mode 100644
index b656024..0000000
--- a/ppapi/utility/completion_callback_factory.h
+++ /dev/null
@@ -1,564 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PPAPI_UTILITY_COMPLETION_CALLBACK_FACTORY_H_
-#define PPAPI_UTILITY_COMPLETION_CALLBACK_FACTORY_H_
-
-#include "ppapi/cpp/completion_callback.h"
-#include "ppapi/utility/non_thread_safe_ref_count.h"
-
-namespace pp {
-
-/// CompletionCallbackFactory<T> may be used to create CompletionCallback
-/// objects that are bound to member functions.
-///
-/// If a factory is destroyed, then any pending callbacks will be cancelled
-/// preventing any bound member functions from being called. The CancelAll()
-/// method allows pending callbacks to be cancelled without destroying the
-/// factory.
-///
-/// <strong>Note: </strong><code>CompletionCallbackFactory<T></code> isn't
-/// thread safe, but you can make it more thread-friendly by passing a
-/// thread-safe refcounting class as the second template element. However, it
-/// only guarantees safety for creating a callback from another thread, the
-/// callback itself needs to execute on the same thread as the thread that
-/// creates/destroys the factory. With this restriction, it is safe to create
-/// the <code>CompletionCallbackFactory</code> on the main thread, create
-/// callbacks from any thread and pass them to CallOnMainThread().
-///
-/// <strong>Example: </strong>
-///
-/// @code
-///
-/// class MyHandler {
-/// public:
-/// // If an compiler warns on following using |this| in the initializer
-/// // list, use PP_ALLOW_THIS_IN_INITIALIZER_LIST macro.
-/// MyHandler() : factory_(this), offset_(0) {
-/// }
-///
-/// void ProcessFile(const FileRef& file) {
-/// CompletionCallback cc = factory_.NewRequiredCallback(
-/// &MyHandler::DidOpen);
-/// int32_t rv = fio_.Open(file, PP_FileOpenFlag_Read, cc);
-/// CHECK(rv == PP_OK_COMPLETIONPENDING);
-/// }
-///
-/// private:
-/// CompletionCallback NewCallback() {
-/// return factory_.NewCallback(&MyHandler::DidCompleteIO);
-/// }
-///
-/// void DidOpen(int32_t result) {
-/// if (result == PP_OK) {
-/// // The file is open, and we can begin reading.
-/// offset_ = 0;
-/// ReadMore();
-/// } else {
-/// // Failed to open the file with error given by 'result'.
-/// }
-/// }
-///
-/// void DidRead(int32_t result) {
-/// if (result > 0) {
-/// // buf_ now contains 'result' number of bytes from the file.
-/// ProcessBytes(buf_, result);
-/// offset_ += result;
-/// ReadMore();
-/// } else {
-/// // Done reading (possibly with an error given by 'result').
-/// }
-/// }
-///
-/// void ReadMore() {
-/// CompletionCallback cc =
-/// factory_.NewOptionalCallback(&MyHandler::DidRead);
-/// int32_t rv = fio_.Read(offset_, buf_, sizeof(buf_),
-/// cc.pp_completion_callback());
-/// if (rv != PP_OK_COMPLETIONPENDING)
-/// cc.Run(rv);
-/// }
-///
-/// void ProcessBytes(const char* bytes, int32_t length) {
-/// // Do work ...
-/// }
-///
-/// pp::CompletionCallbackFactory<MyHandler> factory_;
-/// pp::FileIO fio_;
-/// char buf_[4096];
-/// int64_t offset_;
-/// };
-///
-/// @endcode
-///
-template <typename T, typename RefCount = NonThreadSafeRefCount>
-class CompletionCallbackFactory {
- public:
-
- /// This constructor creates a <code>CompletionCallbackFactory</code>
- /// bound to an object. If the constructor is called without an argument,
- /// the default value of <code>NULL</code> is used. The user then must call
- /// Initialize() to initialize the object.
- ///
- /// param[in] object Optional parameter. An object whose member functions
- /// are to be bound to CompletionCallbacks created by this
- /// <code>CompletionCallbackFactory</code>. The default value of this
- /// parameter is <code>NULL</code>.
- explicit CompletionCallbackFactory(T* object = NULL)
- : object_(object) {
- InitBackPointer();
- }
-
- /// Destructor.
- ~CompletionCallbackFactory() {
- ResetBackPointer();
- }
-
- /// CancelAll() cancels all <code>CompletionCallbacks</code> allocated from
- /// this factory.
- void CancelAll() {
- ResetBackPointer();
- InitBackPointer();
- }
- /// Initialize() binds the <code>CallbackFactory</code> to a particular
- /// object. Use this when the object is not available at
- /// <code>CallbackFactory</code> creation, and the <code>NULL</code> default
- /// is passed to the constructor. The object may only be initialized once,
- /// either by the constructor, or by a call to Initialize().
- ///
- /// @param[in] object The object whose member functions are to be bound to
- /// the <code>CompletionCallback</code> created by this
- /// <code>CompletionCallbackFactory</code>.
- void Initialize(T* object) {
- PP_DCHECK(object);
- PP_DCHECK(!object_); // May only initialize once!
- object_ = object;
- }
-
- /// GetObject() returns the object that was passed at initialization to
- /// Intialize().
- ///
- /// @return the object passed to the constructor or Intialize().
- T* GetObject() {
- return object_;
- }
-
- /// NewCallback allocates a new, single-use <code>CompletionCallback</code>.
- /// The <code>CompletionCallback</code> must be run in order for the memory
- /// allocated by the methods to be freed.
- /// NewCallback() is equivalent to NewRequiredCallback() below.
- ///
- /// @param[in] method The method to be invoked upon completion of the
- /// operation.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method>
- CompletionCallback NewCallback(Method method) {
- PP_DCHECK(object_);
- return NewCallbackHelper(Dispatcher0<Method>(method));
- }
-
- /// NewRequiredCallback() allocates a new, single-use
- /// <code>CompletionCallback</code> that will always run. The
- /// <code>CompletionCallback</code> must be run in order for the memory
- /// allocated by the methods to be freed.
- ///
- /// @param[in] method The method to be invoked upon completion of the
- /// operation.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method>
- CompletionCallback NewRequiredCallback(Method method) {
- CompletionCallback cc = NewCallback(method);
- cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
- return cc;
- }
-
- /// NewOptionalCallback() allocates a new, single-use
- /// <code>CompletionCallback</code> that might not run if the method
- /// taking it can complete synchronously. Thus, if after passing the
- /// CompletionCallback to a Pepper method, the method does not return
- /// PP_OK_COMPLETIONPENDING, then you should manually call the
- /// CompletionCallback's Run method, or memory will be leaked.
- ///
- /// @param[in] method The method to be invoked upon completion of the
- /// operation.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method>
- CompletionCallback NewOptionalCallback(Method method) {
- CompletionCallback cc = NewCallback(method);
- cc.set_flags(cc.flags() | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
- return cc;
- }
-
- /// NewCallback() allocates a new, single-use <code>CompletionCallback</code>.
- /// The <code>CompletionCallback</code> must be run in order for the memory
- /// allocated by the methods to be freed.
- /// NewCallback() is equivalent to NewRequiredCallback() below.
- ///
- /// @param[in] method The method to be invoked upon completion of the
- /// operation. Method should be of type:
- /// <code>void (T::*)(int32_t result, const A& a)</code>
- ///
- /// @param[in] a Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method, typename A>
- CompletionCallback NewCallback(Method method, const A& a) {
- PP_DCHECK(object_);
- return NewCallbackHelper(Dispatcher1<Method, A>(method, a));
- }
-
- /// NewRequiredCallback() allocates a new, single-use
- /// <code>CompletionCallback</code> that will always run. The
- /// <code>CompletionCallback</code> must be run in order for the memory
- /// allocated by the methods to be freed.
- ///
- /// @param[in] method The method to be invoked upon completion of the
- /// operation. Method should be of type:
- /// <code>void (T::*)(int32_t result, const A& a)</code>
- ///
- /// @param[in] a Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method, typename A>
- CompletionCallback NewRequiredCallback(Method method, const A& a) {
- CompletionCallback cc = NewCallback(method, a);
- cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
- return cc;
- }
-
- /// NewOptionalCallback() allocates a new, single-use
- /// <code>CompletionCallback</code> that might not run if the method
- /// taking it can complete synchronously. Thus, if after passing the
- /// CompletionCallback to a Pepper method, the method does not return
- /// PP_OK_COMPLETIONPENDING, then you should manually call the
- /// CompletionCallback's Run method, or memory will be leaked.
- ///
- /// @param[in] method The method to be invoked upon completion of the
- /// operation. Method should be of type:
- /// <code>void (T::*)(int32_t result, const A& a)</code>
- ///
- /// @param[in] a Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method, typename A>
- CompletionCallback NewOptionalCallback(Method method, const A& a) {
- CompletionCallback cc = NewCallback(method, a);
- cc.set_flags(cc.flags() | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
- return cc;
- }
-
- /// NewCallback() allocates a new, single-use
- /// <code>CompletionCallback</code>.
- /// The <code>CompletionCallback</code> must be run in order for the memory
- /// allocated by the methods to be freed.
- /// NewCallback() is equivalent to NewRequiredCallback() below.
- ///
- /// @param method The method taking the callback. Method should be of type:
- /// <code>void (T::*)(int32_t result, const A& a, const B& b)</code>
- ///
- /// @param[in] a Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @param[in] b Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method, typename A, typename B>
- CompletionCallback NewCallback(Method method, const A& a, const B& b) {
- PP_DCHECK(object_);
- return NewCallbackHelper(Dispatcher2<Method, A, B>(method, a, b));
- }
-
- /// NewRequiredCallback() allocates a new, single-use
- /// <code>CompletionCallback</code> that will always run. The
- /// <code>CompletionCallback</code> must be run in order for the memory
- /// allocated by the methods to be freed.
- ///
- /// @param method The method taking the callback. Method should be of type:
- /// <code>void (T::*)(int32_t result, const A& a, const B& b)</code>
- ///
- /// @param[in] a Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @param[in] b Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method, typename A, typename B>
- CompletionCallback NewRequiredCallback(Method method, const A& a,
- const B& b) {
- CompletionCallback cc = NewCallback(method, a, b);
- cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
- return cc;
- }
-
- /// NewOptionalCallback() allocates a new, single-use
- /// <code>CompletionCallback</code> that might not run if the method
- /// taking it can complete synchronously. Thus, if after passing the
- /// CompletionCallback to a Pepper method, the method does not return
- /// PP_OK_COMPLETIONPENDING, then you should manually call the
- /// CompletionCallback's Run method, or memory will be leaked.
- ///
- /// @param[in] method The method taking the callback. Method should be of
- /// type:
- /// <code>void (T::*)(int32_t result, const A& a, const B& b)</code>
- ///
- /// @param[in] a Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @param[in] b Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method, typename A, typename B>
- CompletionCallback NewOptionalCallback(Method method, const A& a,
- const B& b) {
- CompletionCallback cc = NewCallback(method, a, b);
- cc.set_flags(cc.flags() | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
- return cc;
- }
-
- /// NewCallback() allocates a new, single-use
- /// <code>CompletionCallback</code>.
- /// The <code>CompletionCallback</code> must be run in order for the memory
- /// allocated by the methods to be freed.
- /// NewCallback() is equivalent to NewRequiredCallback() below.
- ///
- /// @param method The method taking the callback. Method should be of type:
- /// <code>
- /// void (T::*)(int32_t result, const A& a, const B& b, const C& c)
- /// </code>
- ///
- /// @param[in] a Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @param[in] b Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @param[in] c Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method, typename A, typename B, typename C>
- CompletionCallback NewCallback(Method method, const A& a, const B& b,
- const C& c) {
- PP_DCHECK(object_);
- return NewCallbackHelper(Dispatcher3<Method, A, B, C>(method, a, b, c));
- }
-
- /// NewRequiredCallback() allocates a new, single-use
- /// <code>CompletionCallback</code> that will always run. The
- /// <code>CompletionCallback</code> must be run in order for the memory
- /// allocated by the methods to be freed.
- ///
- /// @param method The method taking the callback. Method should be of type:
- /// <code>
- /// void (T::*)(int32_t result, const A& a, const B& b, const C& c)
- /// </code>
- ///
- /// @param[in] a Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @param[in] b Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @param[in] c Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method, typename A, typename B, typename C>
- CompletionCallback NewRequiredCallback(Method method, const A& a,
- const B& b, const C& c) {
- CompletionCallback cc = NewCallback(method, a, b, c);
- cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
- return cc;
- }
-
- /// NewOptionalCallback() allocates a new, single-use
- /// <code>CompletionCallback</code> that might not run if the method
- /// taking it can complete synchronously. Thus, if after passing the
- /// CompletionCallback to a Pepper method, the method does not return
- /// PP_OK_COMPLETIONPENDING, then you should manually call the
- /// CompletionCallback's Run method, or memory will be leaked.
- ///
- /// @param[in] method The method taking the callback. Method should be of
- /// type:
- /// <code>
- /// void (T::*)(int32_t result, const A& a, const B& b, const C& c)
- /// </code>
- ///
- /// @param[in] a Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @param[in] b Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @param[in] c Passed to <code>method</code> when the completion callback
- /// runs.
- ///
- /// @return A <code>CompletionCallback</code>.
- template <typename Method, typename A, typename B, typename C>
- CompletionCallback NewOptionalCallback(Method method, const A& a,
- const B& b, const C& c) {
- CompletionCallback cc = NewCallback(method, a, b, c);
- cc.set_flags(cc.flags() | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
- return cc;
- }
-
- private:
- class BackPointer {
- public:
- typedef CompletionCallbackFactory<T, RefCount> FactoryType;
-
- BackPointer(FactoryType* factory)
- : factory_(factory) {
- }
-
- void AddRef() {
- ref_.AddRef();
- }
-
- void Release() {
- if (ref_.Release() == 0)
- delete this;
- }
-
- void DropFactory() {
- factory_ = NULL;
- }
-
- T* GetObject() {
- return factory_ ? factory_->GetObject() : NULL;
- }
-
- private:
- RefCount ref_;
- FactoryType* factory_;
- };
-
- template <typename Dispatcher>
- class CallbackData {
- public:
- CallbackData(BackPointer* back_pointer, const Dispatcher& dispatcher)
- : back_pointer_(back_pointer),
- dispatcher_(dispatcher) {
- back_pointer_->AddRef();
- }
-
- ~CallbackData() {
- back_pointer_->Release();
- }
-
- static void Thunk(void* user_data, int32_t result) {
- Self* self = static_cast<Self*>(user_data);
- T* object = self->back_pointer_->GetObject();
- if (object)
- self->dispatcher_(object, result);
- delete self;
- }
-
- private:
- typedef CallbackData<Dispatcher> Self;
- BackPointer* back_pointer_;
- Dispatcher dispatcher_;
- };
-
- template <typename Method>
- class Dispatcher0 {
- public:
- Dispatcher0(Method method) : method_(method) {
- }
- void operator()(T* object, int32_t result) {
- (object->*method_)(result);
- }
- private:
- Method method_;
- };
-
- template <typename Method, typename A>
- class Dispatcher1 {
- public:
- Dispatcher1(Method method, const A& a)
- : method_(method),
- a_(a) {
- }
- void operator()(T* object, int32_t result) {
- (object->*method_)(result, a_);
- }
- private:
- Method method_;
- A a_;
- };
-
- template <typename Method, typename A, typename B>
- class Dispatcher2 {
- public:
- Dispatcher2(Method method, const A& a, const B& b)
- : method_(method),
- a_(a),
- b_(b) {
- }
- void operator()(T* object, int32_t result) {
- (object->*method_)(result, a_, b_);
- }
- private:
- Method method_;
- A a_;
- B b_;
- };
-
- template <typename Method, typename A, typename B, typename C>
- class Dispatcher3 {
- public:
- Dispatcher3(Method method, const A& a, const B& b, const C& c)
- : method_(method),
- a_(a),
- b_(b),
- c_(c) {
- }
- void operator()(T* object, int32_t result) {
- (object->*method_)(result, a_, b_, c_);
- }
- private:
- Method method_;
- A a_;
- B b_;
- C c_;
- };
-
- void InitBackPointer() {
- back_pointer_ = new BackPointer(this);
- back_pointer_->AddRef();
- }
-
- void ResetBackPointer() {
- back_pointer_->DropFactory();
- back_pointer_->Release();
- }
-
- template <typename Dispatcher>
- CompletionCallback NewCallbackHelper(const Dispatcher& dispatcher) {
- PP_DCHECK(object_); // Expects a non-null object!
- return CompletionCallback(
- &CallbackData<Dispatcher>::Thunk,
- new CallbackData<Dispatcher>(back_pointer_, dispatcher));
- }
-
- // Disallowed:
- CompletionCallbackFactory(const CompletionCallbackFactory&);
- CompletionCallbackFactory& operator=(const CompletionCallbackFactory&);
-
- T* object_;
- BackPointer* back_pointer_;
-};
-
-} // namespace pp
-
-#endif // PPAPI_UTILITY_COMPLETION_CALLBACK_FACTORY_H_