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

Unified Diff: ppapi/thunk/enter.cc

Issue 9113044: Convert to new enter method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PATCH DESCRIPTIONS ARE A STUPID WASTE OF TIME Created 8 years, 11 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/thunk/enter.h ('k') | ppapi/thunk/ppb_audio_input_thunk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/thunk/enter.cc
diff --git a/ppapi/thunk/enter.cc b/ppapi/thunk/enter.cc
index 43e80fefd9380624241cb3f72ff8c0adcc219acd..2a0295ac6555b64f4e5e38d29ece9b8be748df06 100644
--- a/ppapi/thunk/enter.cc
+++ b/ppapi/thunk/enter.cc
@@ -83,7 +83,16 @@ void EnterBase::SetStateForResourceError(PP_Resource pp_resource,
if (object)
return; // Everything worked.
- retval_ = PP_ERROR_BADRESOURCE;
+ if (callback_.func) {
+ // Required callback, issue the async completion.
+ MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
+ callback_.func, callback_.user_data,
+ static_cast<int32_t>(PP_ERROR_BADRESOURCE)));
+ callback_ = PP_BlockUntilComplete();
+ retval_ = PP_OK_COMPLETIONPENDING;
+ } else {
+ retval_ = PP_ERROR_BADRESOURCE;
+ }
// We choose to silently ignore the error when the pp_resource is null
// because this is a pretty common case and we don't want to have lots
@@ -104,6 +113,35 @@ void EnterBase::SetStateForResourceError(PP_Resource pp_resource,
}
}
+void EnterBase::SetStateForFunctionError(PP_Instance pp_instance,
+ void* object,
+ bool report_error) {
+ if (object)
+ return; // Everything worked.
+
+ if (callback_.func) {
+ // Required callback, issue the async completion.
+ MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
+ callback_.func, callback_.user_data,
+ static_cast<int32_t>(PP_ERROR_BADARGUMENT)));
+ callback_ = PP_BlockUntilComplete();
+ retval_ = PP_OK_COMPLETIONPENDING;
+ } else {
+ retval_ = PP_ERROR_BADARGUMENT;
+ }
+
+ // We choose to silently ignore the error when the pp_instance is null as
+ // for PP_Resources above.
+ if (report_error && pp_instance) {
+ std::string message;
+ message = base::StringPrintf(
+ "0x%X is not a valid instance ID.",
+ pp_instance);
+ PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
+ std::string(), message);
+ }
+}
+
} // namespace subtle
EnterResourceCreation::EnterResourceCreation(PP_Instance instance)
@@ -114,7 +152,12 @@ EnterResourceCreation::~EnterResourceCreation() {
}
EnterInstance::EnterInstance(PP_Instance instance)
- : EnterFunctionNoLock<PPB_Instance_FunctionAPI>(instance, true) {
+ : EnterFunction<PPB_Instance_FunctionAPI>(instance, true) {
+}
+
+EnterInstance::EnterInstance(PP_Instance instance,
+ const PP_CompletionCallback& callback)
+ : EnterFunction<PPB_Instance_FunctionAPI>(instance, callback, true) {
}
EnterInstance::~EnterInstance() {
« no previous file with comments | « ppapi/thunk/enter.h ('k') | ppapi/thunk/ppb_audio_input_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698