summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-11 18:59:49 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-11 18:59:49 +0000
commitad7ccb59f490c76455163815e8bd052c0cd27a27 (patch)
treeec9f23642c352e950e6e959202402adcf0a8e01c /components
parent6667e568c78764860b85494d851ca8ce6911aa72 (diff)
downloadchromium_src-ad7ccb59f490c76455163815e8bd052c0cd27a27.zip
chromium_src-ad7ccb59f490c76455163815e8bd052c0cd27a27.tar.gz
chromium_src-ad7ccb59f490c76455163815e8bd052c0cd27a27.tar.bz2
Pepper: Make StartSelLdr asynchronous.
Changing the trusted plugin to use Chromium IPC instead of SRPC requires that we create another channel between the renderer and plugin for communicating the existing SRPC messages. This channel will be created in response to the StartSelLdr request. Since we need that channel to be available immediately, StartSelLdr should not finish until the created channel is available for use. This requires that we make this operation asynchronous. SyncChannel creation is asynchronous because we must wait for the channel to be connected before attempting to use it for Send(). As part of connection, OnChannelConnected must be called on the thread that created the SyncChannel. In local testing, calling Send() before the channel had a chance to connect led to deadlock. BUG=333950 Review URL: https://codereview.chromium.org/149403005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250461 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/nacl/renderer/ppb_nacl_private_impl.cc48
1 files changed, 32 insertions, 16 deletions
diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
index 5fd2f38..a9d909a 100644
--- a/components/nacl/renderer/ppb_nacl_private_impl.cc
+++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
@@ -79,16 +79,17 @@ static int GetRoutingID(PP_Instance instance) {
}
// Launch NaCl's sel_ldr process.
-PP_ExternalPluginResult LaunchSelLdr(PP_Instance instance,
- const char* alleged_url,
- PP_Bool uses_irt,
- PP_Bool uses_ppapi,
- PP_Bool enable_ppapi_dev,
- PP_Bool enable_dyncode_syscalls,
- PP_Bool enable_exception_handling,
- PP_Bool enable_crash_throttling,
- void* imc_handle,
- struct PP_Var* error_message) {
+void LaunchSelLdr(PP_Instance instance,
+ const char* alleged_url,
+ PP_Bool uses_irt,
+ PP_Bool uses_ppapi,
+ PP_Bool enable_ppapi_dev,
+ PP_Bool enable_dyncode_syscalls,
+ PP_Bool enable_exception_handling,
+ PP_Bool enable_crash_throttling,
+ void* imc_handle,
+ struct PP_Var* error_message,
+ PP_CompletionCallback callback) {
nacl::FileDescriptor result_socket;
IPC::Sender* sender = content::RenderThread::Get();
DCHECK(sender);
@@ -100,8 +101,13 @@ PP_ExternalPluginResult LaunchSelLdr(PP_Instance instance,
// so those nexes can skip finding a routing_id.
if (uses_ppapi) {
routing_id = GetRoutingID(instance);
- if (!routing_id)
- return PP_EXTERNAL_PLUGIN_FAILED;
+ if (!routing_id) {
+ ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
+ FROM_HERE,
+ base::Bind(callback.func, callback.user_data,
+ static_cast<int32_t>(PP_ERROR_FAILED)));
+ return;
+ }
}
InstanceInfo instance_info;
@@ -128,11 +134,19 @@ PP_ExternalPluginResult LaunchSelLdr(PP_Instance instance,
PP_ToBool(enable_crash_throttling)),
&launch_result,
&error_message_string))) {
- return PP_EXTERNAL_PLUGIN_FAILED;
+ ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
+ FROM_HERE,
+ base::Bind(callback.func, callback.user_data,
+ static_cast<int32_t>(PP_ERROR_FAILED)));
+ return;
}
if (!error_message_string.empty()) {
*error_message = ppapi::StringVar::StringToPPVar(error_message_string);
- return PP_EXTERNAL_PLUGIN_FAILED;
+ ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
+ FROM_HERE,
+ base::Bind(callback.func, callback.user_data,
+ static_cast<int32_t>(PP_ERROR_FAILED)));
+ return;
}
result_socket = launch_result.imc_channel_handle;
instance_info.channel_handle = launch_result.ipc_channel_handle;
@@ -149,8 +163,10 @@ PP_ExternalPluginResult LaunchSelLdr(PP_Instance instance,
*(static_cast<NaClHandle*>(imc_handle)) =
nacl::ToNativeHandle(result_socket);
-
- return PP_EXTERNAL_PLUGIN_OK;
+ ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
+ FROM_HERE,
+ base::Bind(callback.func, callback.user_data,
+ static_cast<int32_t>(PP_OK)));
}
PP_ExternalPluginResult StartPpapiProxy(PP_Instance instance) {