Commit 778a4025 authored by jvoung@chromium.org's avatar jvoung@chromium.org

Add a flag to LaunchSelLdr to skip grabbing a routing_id.

Finding the routing id requires LaunchSelLdr to run from the
main thread.  However, some sel_ldr instances host nexes that do
not actually need to use Pepper APIs (e.g., the PNaCl translator),
and should be run on a background thread.

BUG= http://code.google.com/p/nativeclient/issues/detail?id=3176


Review URL: https://chromiumcodereview.appspot.com/11428063

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171020 0039d316-1c4b-4281-b951-d872f2087c98
parent 993dcbee
......@@ -177,6 +177,10 @@ NaClProcessHost::NaClProcessHost(const GURL& manifest_url,
enable_ipc_proxy_ = !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableNaClSRPCProxy);
// If render_view_id == 0 we do not need PPAPI, so we can skip
// PPAPI IPC proxy channel creation, etc.
if (!render_view_id_)
enable_ipc_proxy_ = false;
}
NaClProcessHost::~NaClProcessHost() {
......
......@@ -57,6 +57,7 @@ base::LazyInstance<InstanceInfoMap> g_instance_info =
// Launch NaCl's sel_ldr process.
PP_NaClResult LaunchSelLdr(PP_Instance instance,
const char* alleged_url,
PP_Bool uses_ppapi,
PP_Bool enable_ppapi_dev,
int socket_count,
void* imc_handles) {
......@@ -65,17 +66,27 @@ PP_NaClResult LaunchSelLdr(PP_Instance instance,
if (sender == NULL)
sender = g_background_thread_sender.Pointer()->get();
webkit::ppapi::PluginInstance* plugin_instance =
content::GetHostGlobals()->GetInstance(instance);
if (!plugin_instance)
return PP_NACL_FAILED;
WebKit::WebView* web_view =
plugin_instance->container()->element().document().frame()->view();
content::RenderView* render_view =
content::RenderView::FromWebView(web_view);
if (!render_view)
return PP_NACL_FAILED;
int routing_id = 0;
// If the nexe uses ppapi APIs, we need a routing ID.
// To get the routing ID, we must be on the main thread.
// Some nexes do not use ppapi and launch from the background thread,
// so those nexes can skip finding a routing_id.
if (uses_ppapi) {
// Check that we are on the main renderer thread.
CHECK(content::RenderThread::Get());
webkit::ppapi::PluginInstance* plugin_instance =
content::GetHostGlobals()->GetInstance(instance);
if (!plugin_instance)
return PP_NACL_FAILED;
WebKit::WebView* web_view =
plugin_instance->container()->element().document().frame()->view();
content::RenderView* render_view =
content::RenderView::FromWebView(web_view);
if (!render_view)
return PP_NACL_FAILED;
routing_id = render_view->GetRoutingID();
}
InstanceInfo instance_info;
instance_info.url = GURL(alleged_url);
......@@ -91,7 +102,7 @@ PP_NaClResult LaunchSelLdr(PP_Instance instance,
if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl(
instance_info.url,
render_view->GetRoutingID(),
routing_id,
perm_bits,
socket_count, &sockets,
&instance_info.channel_handle,
......
......@@ -31,10 +31,14 @@ interface PPB_NaCl_Private {
/* Launches NaCl's sel_ldr process. Returns PP_NACL_OK on success and writes
* |socket_count| nacl::Handles to imc_handles. Returns PP_NACL_FAILED on
* failure. The |enable_ppapi_dev| parameter controls whether GetInterface
* returns 'Dev' interfaces to the NaCl plugin.
* returns 'Dev' interfaces to the NaCl plugin. The |uses_ppapi| flag
* indicates that the nexe run by sel_ldr will use the PPAPI APIs.
* This implies that LaunchSelLdr is run from the main thread. If a nexe
* does not need PPAPI, then it can run off the main thread.
*/
PP_NaClResult LaunchSelLdr([in] PP_Instance instance,
[in] str_t alleged_url,
[in] PP_Bool uses_ppapi,
[in] PP_Bool enable_ppapi_dev,
[in] int32_t socket_count,
[out] mem_t imc_handles);
......
......@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
/* From private/ppb_nacl_private.idl modified Tue Nov 20 08:49:26 2012. */
/* From private/ppb_nacl_private.idl modified Thu Nov 29 15:01:09 2012. */
#ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
#define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
......@@ -56,10 +56,14 @@ struct PPB_NaCl_Private_1_0 {
/* Launches NaCl's sel_ldr process. Returns PP_NACL_OK on success and writes
* |socket_count| nacl::Handles to imc_handles. Returns PP_NACL_FAILED on
* failure. The |enable_ppapi_dev| parameter controls whether GetInterface
* returns 'Dev' interfaces to the NaCl plugin.
* returns 'Dev' interfaces to the NaCl plugin. The |uses_ppapi| flag
* indicates that the nexe run by sel_ldr will use the PPAPI APIs.
* This implies that LaunchSelLdr is run from the main thread. If a nexe
* does not need PPAPI, then it can run off the main thread.
*/
PP_NaClResult (*LaunchSelLdr)(PP_Instance instance,
const char* alleged_url,
PP_Bool uses_ppapi,
PP_Bool enable_ppapi_dev,
int32_t socket_count,
void* imc_handles);
......
......@@ -18,6 +18,7 @@
typedef PP_NaClResult (*LaunchNaClProcessFunc)(PP_Instance instance,
const char* alleged_url,
PP_Bool uses_ppapi,
PP_Bool enable_ppapi_dev,
int socket_count,
nacl::Handle* result_sockets);
......
......@@ -544,6 +544,7 @@ bool Plugin::LoadNaClModuleCommon(nacl::DescWrapper* wrapper,
NaClSubprocess* subprocess,
const Manifest* manifest,
bool should_report_uma,
bool uses_ppapi,
ErrorInfo* error_info,
pp::CompletionCallback init_done_cb,
pp::CompletionCallback crash_cb) {
......@@ -563,6 +564,7 @@ bool Plugin::LoadNaClModuleCommon(nacl::DescWrapper* wrapper,
new_service_runtime->Start(wrapper,
error_info,
manifest_base_url(),
uses_ppapi,
enable_dev_interfaces_,
crash_cb);
PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (service_runtime_started=%d)\n",
......@@ -583,7 +585,9 @@ bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper,
// outlive the Plugin object, they will not be memory safe.
ShutDownSubprocesses();
if (!LoadNaClModuleCommon(wrapper, &main_subprocess_, manifest_.get(),
true, error_info, init_done_cb, crash_cb)) {
true /* should_report_uma */,
true /* uses_ppapi */,
error_info, init_done_cb, crash_cb)) {
return false;
}
PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n",
......@@ -641,7 +645,9 @@ NaClSubprocess* Plugin::LoadHelperNaClModule(nacl::DescWrapper* wrapper,
// Do not report UMA stats for translator-related nexes.
// TODO(sehr): define new UMA stats for translator related nexe events.
if (!LoadNaClModuleCommon(wrapper, nacl_subprocess.get(), manifest,
false, error_info,
false /* should_report_uma */,
false /* uses_ppapi */,
error_info,
pp::BlockUntilComplete(),
pp::BlockUntilComplete())) {
return NULL;
......
......@@ -350,6 +350,7 @@ class Plugin : public pp::InstancePrivate {
NaClSubprocess* subprocess,
const Manifest* manifest,
bool should_report_uma,
bool uses_ppapi,
ErrorInfo* error_info,
pp::CompletionCallback init_done_cb,
pp::CompletionCallback crash_cb);
......
......@@ -11,11 +11,12 @@ LaunchNaClProcessFunc launch_nacl_process = NULL;
namespace plugin {
bool SelLdrLauncherChrome::Start(const char* url) {
return Start(0, url, false);
return Start(0, url, true, false);
}
bool SelLdrLauncherChrome::Start(PP_Instance instance,
const char* url,
bool uses_ppapi,
bool enable_ppapi_dev) {
if (!launch_nacl_process)
return false;
......@@ -24,6 +25,7 @@ bool SelLdrLauncherChrome::Start(PP_Instance instance,
static const int kNumberOfChannelsToBeCreated = 1;
if (launch_nacl_process(instance,
url,
PP_FromBool(uses_ppapi),
PP_FromBool(enable_ppapi_dev),
kNumberOfChannelsToBeCreated,
&channel_) != PP_NACL_OK) {
......
......@@ -15,6 +15,7 @@ class SelLdrLauncherChrome : public nacl::SelLdrLauncherBase {
virtual bool Start(const char* url);
virtual bool Start(PP_Instance instance,
const char* url,
bool uses_ppapi,
bool enable_ppapi_dev);
};
......
......@@ -700,6 +700,7 @@ bool ServiceRuntime::InitCommunication(nacl::DescWrapper* nacl_desc,
bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc,
ErrorInfo* error_info,
const nacl::string& url,
bool uses_ppapi,
bool enable_ppapi_dev,
pp::CompletionCallback crash_cb) {
PLUGIN_PRINTF(("ServiceRuntime::Start (nacl_desc=%p)\n",
......@@ -715,6 +716,7 @@ bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc,
}
bool started = tmp_subprocess->Start(plugin_->pp_instance(),
url.c_str(),
uses_ppapi,
enable_ppapi_dev);
if (!started) {
PLUGIN_PRINTF(("ServiceRuntime::Start (start failed)\n"));
......
......@@ -238,6 +238,7 @@ class ServiceRuntime {
bool Start(nacl::DescWrapper* nacl_file_desc,
ErrorInfo* error_info,
const nacl::string& url,
bool uses_ppapi,
bool enable_ppapi_dev,
pp::CompletionCallback crash_cb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment