Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Unified Diff: ppapi/proxy/enter_proxy.h

Issue 8371008: Revert 106717 - Revert 106677 (caused several PPAPI test timeouts, see http://crbug.com/101154) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/dispatcher.cc ('k') | ppapi/proxy/interface_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/enter_proxy.h
===================================================================
--- ppapi/proxy/enter_proxy.h (revision 106763)
+++ ppapi/proxy/enter_proxy.h (working copy)
@@ -166,6 +166,82 @@
pp::CompletionCallback callback_;
};
+// Like EnterHostFromHostResourceForceCallback but for Function APIs. It takes
+// an instance instead of a resource ID.
+template<typename FunctionT>
+class EnterHostFunctionForceCallback
+ : public thunk::EnterFunctionNoLock<FunctionT> {
+ public:
+ // For callbacks that take no parameters except the "int32_t result". Most
+ // implementations will use the 1-extra-argument constructor below.
+ template<class CallbackFactory, typename Method>
+ EnterHostFunctionForceCallback(PP_Instance instance,
+ CallbackFactory& factory,
+ Method method)
+ : thunk::EnterFunctionNoLock<FunctionT>(instance, false),
+ needs_running_(true),
+ callback_(factory.NewOptionalCallback(method)) {
+ if (this->failed())
+ RunCallback(PP_ERROR_BADARGUMENT);
+ }
+
+ // For callbacks that take an extra parameter as a closure.
+ template<class CallbackFactory, typename Method, typename A>
+ EnterHostFunctionForceCallback(PP_Instance instance,
+ CallbackFactory& factory,
+ Method method,
+ const A& a)
+ : thunk::EnterFunctionNoLock<FunctionT>(instance, false),
+ needs_running_(true),
+ callback_(factory.NewOptionalCallback(method, a)) {
+ if (this->failed())
+ RunCallback(PP_ERROR_BADARGUMENT);
+ }
+
+ // For callbacks that take two extra parameters as a closure.
+ template<class CallbackFactory, typename Method, typename A, typename B>
+ EnterHostFunctionForceCallback(PP_Instance instance,
+ CallbackFactory& factory,
+ Method method,
+ const A& a,
+ const B& b)
+ : thunk::EnterFunctionNoLock<FunctionT>(instance),
+ needs_running_(true),
+ callback_(factory.NewOptionalCallback(method, a, b)) {
+ if (this->failed())
+ RunCallback(PP_ERROR_BADARGUMENT);
+ }
+
+ ~EnterHostFunctionForceCallback() {
+ if (needs_running_) {
+ NOTREACHED() << "Should always call SetResult except in the "
+ "initialization failed case.";
+ RunCallback(PP_ERROR_FAILED);
+ }
+ }
+
+ void SetResult(int32_t result) {
+ DCHECK(needs_running_) << "Don't call SetResult when there already is one.";
+ needs_running_ = false;
+ if (result != PP_OK_COMPLETIONPENDING)
+ callback_.Run(result);
+ }
+
+ PP_CompletionCallback callback() {
+ return callback_.pp_completion_callback();
+ }
+
+ private:
+ void RunCallback(int32_t result) {
+ DCHECK(needs_running_);
+ needs_running_ = false;
+ callback_.Run(result);
+ }
+
+ bool needs_running_;
+ pp::CompletionCallback callback_;
+};
+
} // namespace proxy
} // namespace ppapi
« no previous file with comments | « ppapi/proxy/dispatcher.cc ('k') | ppapi/proxy/interface_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698