summaryrefslogtreecommitdiffstats
path: root/ppapi/native_client
diff options
context:
space:
mode:
authorbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-21 23:07:04 +0000
committerbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-21 23:07:04 +0000
commite46177921cafffdf8d911d92388f6d3b66483817 (patch)
tree7857dafa96f2eb9b76e1a013a875abc9d1120ac0 /ppapi/native_client
parenta86c93c574d51e430b89b41a18f72924614ade6e (diff)
downloadchromium_src-e46177921cafffdf8d911d92388f6d3b66483817.zip
chromium_src-e46177921cafffdf8d911d92388f6d3b66483817.tar.gz
chromium_src-e46177921cafffdf8d911d92388f6d3b66483817.tar.bz2
Add an IPC channel between the NaCl loader process and the renderer.
BUG=116317 TEST=manual Review URL: https://chromiumcodereview.appspot.com/10214007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143483 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/native_client')
-rw-r--r--ppapi/native_client/src/trusted/plugin/nacl_entry_points.h6
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.cc38
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.h3
-rw-r--r--ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc9
-rw-r--r--ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h4
-rw-r--r--ppapi/native_client/src/trusted/plugin/service_runtime.cc8
-rw-r--r--ppapi/native_client/src/trusted/plugin/service_runtime.h6
7 files changed, 60 insertions, 14 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h b/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h
index 3723394..eb66b8f 100644
--- a/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h
+++ b/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h
@@ -19,12 +19,10 @@
typedef bool (*LaunchNaClProcessFunc)(PP_Instance instance,
const char* url,
int socket_count,
- nacl::Handle* result_sockets);
-
-typedef bool (*StartPpapiProxyFunc)(PP_Instance instance);
+ nacl::Handle* result_sockets,
+ void** ipc_channel_handle);
extern LaunchNaClProcessFunc launch_nacl_process;
-extern StartPpapiProxyFunc start_ppapi_proxy;
#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_ENTRY_POINTS_H_
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc
index 891df69..2bfc50e 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.cc
+++ b/ppapi/native_client/src/trusted/plugin/plugin.cc
@@ -34,6 +34,7 @@
#include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
#include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h"
#include "native_client/src/trusted/plugin/json_manifest.h"
+#include "native_client/src/trusted/plugin/nacl_entry_points.h"
#include "native_client/src/trusted/plugin/nacl_subprocess.h"
#include "native_client/src/trusted/plugin/nexe_arch.h"
#include "native_client/src/trusted/plugin/plugin_error.h"
@@ -54,6 +55,7 @@
#include "ppapi/c/ppp_input_event.h"
#include "ppapi/c/ppp_instance.h"
#include "ppapi/c/ppp_mouse_lock.h"
+#include "ppapi/c/private/ppb_nacl_private.h"
#include "ppapi/c/private/ppb_uma_private.h"
#include "ppapi/cpp/dev/find_dev.h"
#include "ppapi/cpp/dev/printing_dev.h"
@@ -120,6 +122,13 @@ const int64_t kSizeKBMin = 1;
const int64_t kSizeKBMax = 512*1024; // very large .nexe
const uint32_t kSizeKBBuckets = 100;
+const PPB_NaCl_Private* GetNaclInterface() {
+ pp::Module *module = pp::Module::Get();
+ CHECK(module);
+ return static_cast<const PPB_NaCl_Private*>(
+ module->GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE));
+}
+
const PPB_UMA_Private* GetUMAInterface() {
pp::Module *module = pp::Module::Get();
CHECK(module);
@@ -602,13 +611,32 @@ bool Plugin::LoadNaClModuleCommon(nacl::DescWrapper* wrapper,
return false;
}
+ void* ipc_channel_handle = NULL;
bool service_runtime_started =
- new_service_runtime->Start(wrapper, error_info, manifest_base_url());
+ new_service_runtime->Start(wrapper,
+ error_info,
+ manifest_base_url(),
+ &ipc_channel_handle);
+ nacl::scoped_ptr<char> ipc_channel_handle_ptr(
+ reinterpret_cast<char*>(ipc_channel_handle));
PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (service_runtime_started=%d)\n",
service_runtime_started));
if (!service_runtime_started) {
return false;
}
+
+ // Try to start the Chrome IPC-based proxy.
+ const PPB_NaCl_Private* ppb_nacl = GetNaclInterface();
+ if (ppb_nacl->StartPpapiProxy(
+ pp_instance(),
+ reinterpret_cast<void*>(ipc_channel_handle_ptr.release()))) {
+ using_ipc_proxy_ = true;
+ // We need to explicitly schedule this here. It is normally called in
+ // response to starting the SRPC proxy.
+ CHECK(init_done_cb.pp_completion_callback().func != NULL);
+ PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon, started ipc proxy.\n"));
+ pp::Module::Get()->core()->CallOnMainThread(0, init_done_cb, PP_OK);
+ }
return true;
}
@@ -631,6 +659,11 @@ bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper,
}
bool Plugin::LoadNaClModuleContinuationIntern(ErrorInfo* error_info) {
+ // If we are using the IPC proxy, StartSrpcServices and StartJSObjectProxy
+ // don't makes sense. Return 'true' so that the plugin continues loading.
+ if (using_ipc_proxy_)
+ return true;
+
if (!main_subprocess_.StartSrpcServices()) {
error_info->SetReport(ERROR_SRPC_CONNECTION_FAIL,
"SRPC connection failure for " +
@@ -862,7 +895,8 @@ Plugin::Plugin(PP_Instance pp_instance)
init_time_(0),
ready_time_(0),
nexe_size_(0),
- time_of_last_progress_event_(0) {
+ time_of_last_progress_event_(0),
+ using_ipc_proxy_(false) {
PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%"
NACL_PRId32")\n", static_cast<void*>(this), pp_instance));
callback_factory_.Initialize(this);
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h
index cd79517..1a709d8 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.h
+++ b/ppapi/native_client/src/trusted/plugin/plugin.h
@@ -517,6 +517,9 @@ class Plugin : public pp::InstancePrivate {
const FileDownloader* FindFileDownloader(PP_Resource url_loader) const;
int64_t time_of_last_progress_event_;
+
+ // Whether we are using IPC-based PPAPI proxy.
+ bool using_ipc_proxy_;
};
} // namespace plugin
diff --git a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc
index d301612..140e0d8 100644
--- a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc
+++ b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc
@@ -11,10 +11,12 @@ LaunchNaClProcessFunc launch_nacl_process = NULL;
namespace plugin {
bool SelLdrLauncherChrome::Start(const char* url) {
- return Start(0, url);
+ return Start(0, url, NULL);
}
-bool SelLdrLauncherChrome::Start(PP_Instance instance, const char* url) {
+bool SelLdrLauncherChrome::Start(PP_Instance instance,
+ const char* url,
+ void** ipc_channel_handle) {
// send a synchronous message to the browser process
// TODO(sehr): This is asserted to be one. Remove this parameter.
static const int kNumberOfChannelsToBeCreated = 1;
@@ -22,7 +24,8 @@ bool SelLdrLauncherChrome::Start(PP_Instance instance, const char* url) {
!launch_nacl_process(instance,
url,
kNumberOfChannelsToBeCreated,
- &channel_)) {
+ &channel_,
+ ipc_channel_handle)) {
return false;
}
return true;
diff --git a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h
index e479499..15ce771 100644
--- a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h
+++ b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h
@@ -13,7 +13,9 @@ namespace plugin {
class SelLdrLauncherChrome : public nacl::SelLdrLauncherBase {
public:
virtual bool Start(const char* url);
- virtual bool Start(PP_Instance instance, const char* url);
+ bool Start(PP_Instance instance,
+ const char* url,
+ void** ipc_channel_handle);
};
} // namespace plugin
diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/ppapi/native_client/src/trusted/plugin/service_runtime.cc
index 5c3b4fd..4177cf1 100644
--- a/ppapi/native_client/src/trusted/plugin/service_runtime.cc
+++ b/ppapi/native_client/src/trusted/plugin/service_runtime.cc
@@ -623,7 +623,9 @@ bool ServiceRuntime::InitCommunication(nacl::DescWrapper* nacl_desc,
}
bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc,
- ErrorInfo* error_info, const nacl::string& url) {
+ ErrorInfo* error_info,
+ const nacl::string& url,
+ void** ipc_channel_handle) {
PLUGIN_PRINTF(("ServiceRuntime::Start (nacl_desc=%p)\n",
reinterpret_cast<void*>(nacl_desc)));
@@ -643,7 +645,9 @@ bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc,
#ifdef NACL_STANDALONE
bool started = tmp_subprocess->Start(url.c_str());
#else
- bool started = tmp_subprocess->Start(plugin_->pp_instance(), url.c_str());
+ bool started = tmp_subprocess->Start(plugin_->pp_instance(),
+ url.c_str(),
+ ipc_channel_handle);
#endif
if (!started) {
PLUGIN_PRINTF(("ServiceRuntime::Start (start failed)\n"));
diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.h b/ppapi/native_client/src/trusted/plugin/service_runtime.h
index 554942a..8c9b55c 100644
--- a/ppapi/native_client/src/trusted/plugin/service_runtime.h
+++ b/ppapi/native_client/src/trusted/plugin/service_runtime.h
@@ -216,10 +216,12 @@ class ServiceRuntime {
// Spawn a sel_ldr instance and establish an SrpcClient to it. The nexe
// to be started is passed through |nacl_file_desc|. On success, returns
// true. On failure, returns false and |error_string| is set to something
- // describing the error.
+ // describing the error. |ipc_channel_handle| returns information for
+ // connecting the Chrome IPC-based proxy.
bool Start(nacl::DescWrapper* nacl_file_desc,
ErrorInfo* error_info,
- const nacl::string& url);
+ const nacl::string& url,
+ void** ipc_channel_handle);
// Starts the application channel to the nexe.
SrpcClient* SetupAppChannel();