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

Unified Diff: ppapi/thunk/enter.cc

Issue 600553002: PPAPI: Disallow blocking callbacks while handling a blocking message (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try to improve comment Created 6 years, 3 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/tests/test_message_handler.cc ('k') | no next file » | 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 03937c9b5338b353b469fc9d92366b9f2eb1247e..a98a3ec3102e07130639f8f26f6d22c4467b59d4 100644
--- a/ppapi/thunk/enter.cc
+++ b/ppapi/thunk/enter.cc
@@ -23,6 +23,12 @@ bool IsMainThread() {
PpapiGlobals::Get()->GetMainThreadMessageLoop()->BelongsToCurrentThread();
}
+bool CurrentThreadHandlingBlockingMessage() {
+ ppapi::MessageLoopShared* current =
+ PpapiGlobals::Get()->GetCurrentMessageLoop();
+ return current && current->CurrentlyHandlingBlockingMessage();
+}
+
} // namespace
namespace thunk {
@@ -141,6 +147,18 @@ void EnterBase::SetStateForCallbackError(bool report_error) {
PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
std::string(), message);
}
+ } else if (callback_->is_blocking() &&
+ CurrentThreadHandlingBlockingMessage()) {
+ // Blocking callbacks are not allowed while handling a blocking message.
+ callback_->MarkAsCompleted();
+ callback_ = NULL;
+ retval_ = PP_ERROR_WOULD_BLOCK_THREAD;
+ if (report_error) {
+ std::string message("Blocking callbacks are not allowed while handling "
+ "a blocking message from JavaScript.");
+ PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
+ std::string(), message);
+ }
} else if (!IsMainThread() &&
callback_->has_null_target_loop() &&
!callback_->is_blocking()) {
« no previous file with comments | « ppapi/tests/test_message_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698