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

Unified Diff: ppapi/native_client/src/trusted/plugin/service_runtime.cc

Issue 321053004: Add limitation that LoadNexeAndStart must be called on the main thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
Index: ppapi/native_client/src/trusted/plugin/service_runtime.cc
diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/ppapi/native_client/src/trusted/plugin/service_runtime.cc
index 272bbabebcb18fa79ea7e9bc49e3b084cef88410..ed4fbe8fa363deead3ed157ae5578b7b3bb089a3 100644
--- a/ppapi/native_client/src/trusted/plugin/service_runtime.cc
+++ b/ppapi/native_client/src/trusted/plugin/service_runtime.cc
@@ -418,6 +418,8 @@ void PluginReverseInterface::ReportCrash() {
if (crash_cb_.pp_completion_callback().func != NULL) {
NaClLog(4, "PluginReverseInterface::ReportCrash: invoking CB\n");
pp::Module::Get()->core()->CallOnMainThread(0, crash_cb_, PP_OK);
+ // Clear the callback to avoid it gets invoked twice.
+ crash_cb_ = pp::CompletionCallback();
} else {
NaClLog(1,
"PluginReverseInterface::ReportCrash:"
@@ -683,8 +685,7 @@ void ServiceRuntime::SignalNexeStarted() {
}
void ServiceRuntime::LoadNexeAndStart(PP_NaClFileInfo file_info,
- const pp::CompletionCallback& started_cb,
- const pp::CompletionCallback& crash_cb) {
+ const pp::CompletionCallback& callback) {
NaClLog(4, "ServiceRuntime::LoadNexeAndStart (handle_valid=%d "
"token_lo=%" NACL_PRIu64 " token_hi=%" NACL_PRIu64 ")\n",
file_info.handle != PP_kInvalidFileHandle,
@@ -695,7 +696,9 @@ void ServiceRuntime::LoadNexeAndStart(PP_NaClFileInfo file_info,
InitReverseService() &&
LoadModule(file_info) &&
StartModule();
- if (!ok) {
+ if (ok) {
+ NaClLog(4, "ServiceRuntime::LoadNexeAndStart (return 1)\n");
+ } else {
// On a load failure the service runtime does not crash itself to
// avoid a race where the no-more-senders error on the reverse
// channel esrvice thread might cause the crash-detection logic to
@@ -707,17 +710,16 @@ void ServiceRuntime::LoadNexeAndStart(PP_NaClFileInfo file_info,
if (NULL == reverse_service_) {
// No crash detector thread.
NaClLog(LOG_ERROR, "scheduling to get crash log\n");
- pp::Module::Get()->core()->CallOnMainThread(0, crash_cb, PP_OK);
+ // Invoking rev_interface's method is workaround to avoid crash_cb
+ // gets called twice or more. We should clean this up later.
+ rev_interface_->ReportCrash();
NaClLog(LOG_ERROR, "should fire soon\n");
} else {
NaClLog(LOG_ERROR, "Reverse service thread will pick up crash log\n");
}
- pp::Module::Get()->core()->CallOnMainThread(0, started_cb, PP_ERROR_FAILED);
- return;
}
-
- NaClLog(4, "ServiceRuntime::LoadNexeAndStart (return 1)\n");
- pp::Module::Get()->core()->CallOnMainThread(0, started_cb, PP_OK);
+ pp::Module::Get()->core()->CallOnMainThread(
+ 0, callback, ok ? PP_OK : PP_ERROR_FAILED);
}
SrpcClient* ServiceRuntime::SetupAppChannel() {

Powered by Google App Engine
This is Rietveld 408576698