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

Unified Diff: chrome/renderer/pepper/ppb_nacl_private_impl.cc

Issue 10214007: Add an IPC channel between the NaCl loader process and the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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: chrome/renderer/pepper/ppb_nacl_private_impl.cc
===================================================================
--- chrome/renderer/pepper/ppb_nacl_private_impl.cc (revision 136022)
+++ chrome/renderer/pepper/ppb_nacl_private_impl.cc (working copy)
@@ -9,26 +9,47 @@
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/path_service.h"
#include "base/rand_util_c.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
+#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/render_view.h"
#include "ipc/ipc_sync_message_filter.h"
-#include "native_client/src/shared/imc/nacl_imc.h"
#include "ppapi/c/private/ppb_nacl_private.h"
#include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+#include "webkit/plugins/ppapi/host_globals.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#if defined(OS_WIN)
#include "content/public/common/sandbox_init.h"
#endif
+using content::RenderThread;
+using webkit::ppapi::HostGlobals;
+using webkit::ppapi::PluginInstance;
+using WebKit::WebView;
+
namespace {
base::LazyInstance<scoped_refptr<IPC::SyncMessageFilter> >
g_background_thread_sender = LAZY_INSTANCE_INITIALIZER;
+IPC::ChannelHandle g_plugin_ppapi_channel;
dmichael (off chromium) 2012/05/10 19:38:58 I think this one will have to be a LazyInstance if
+base::ProcessHandle g_plugin_process_handle;
+base::ProcessId g_plugin_process_id;
dmichael (off chromium) 2012/05/10 19:38:58 Suppose one page has >1 NaCl module embedded on it
bbudge 2012/05/11 01:21:16 This is just for the sake of getting something wor
+
// Launch NaCl's sel_ldr process.
-bool LaunchSelLdr(const char* alleged_url, int socket_count,
+bool LaunchSelLdr(PP_Instance instance,
+ const char* alleged_url, int socket_count,
void* imc_handles) {
std::vector<nacl::FileDescriptor> sockets;
IPC::Message::Sender* sender = content::RenderThread::Get();
@@ -36,7 +57,10 @@
sender = g_background_thread_sender.Pointer()->get();
if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl(
- GURL(alleged_url), socket_count, &sockets)))
+ GURL(alleged_url), socket_count, &sockets,
+ &g_plugin_ppapi_channel,
+ &g_plugin_process_handle,
+ &g_plugin_process_id)))
return false;
CHECK(static_cast<int>(sockets.size()) == socket_count);
@@ -44,9 +68,37 @@
static_cast<nacl::Handle*>(imc_handles)[i] =
nacl::ToNativeHandle(sockets[i]);
}
+
return true;
}
+bool StartPpapiProxy(PP_Instance instance) {
+ // Using the RenderView, establish the HostDispatcher for the PPAPI proxy.
dmichael (off chromium) 2012/05/10 19:38:58 I think this comment might be better right before
bbudge 2012/05/11 01:21:16 Done.
+ webkit::ppapi::PluginInstance* plugin_instance =
+ content::GetHostGlobals()->GetInstance(instance);
+ if (!plugin_instance)
+ return false;
+ FilePath plugin_path;
+ if (!PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_path))
+ return false;
+ if (g_plugin_ppapi_channel.name.empty())
+ return false;
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableNaClIPCProxy)) {
dmichael (off chromium) 2012/05/10 19:38:58 Maybe you should check for that switch at the begi
bbudge 2012/05/11 01:21:16 Yes indeed.
+ WebView* view =
+ plugin_instance->container()->element().document().frame()->view();
+ content::RenderView* render_view = content::RenderView::FromWebView(view);
+ render_view->CreatePepperHostDispatcher(plugin_path,
+ g_plugin_process_id,
+ g_plugin_process_handle,
+ g_plugin_ppapi_channel);
+ return true;
+ }
+
+ return false;
+}
+
int UrandomFD(void) {
#if defined(OS_POSIX)
return GetUrandomFD();
@@ -80,6 +132,7 @@
const PPB_NaCl_Private nacl_interface = {
&LaunchSelLdr,
+ &StartPpapiProxy,
&UrandomFD,
&Are3DInterfacesDisabled,
&EnableBackgroundSelLdrLaunch,

Powered by Google App Engine
This is Rietveld 408576698