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

Unified Diff: components/nacl/loader/nacl_listener.cc

Issue 131413009: Prototype: Use Chromium IPC for plugin LOAD_MODULE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased, some FIXMEs cleaned up Created 6 years, 10 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: components/nacl/loader/nacl_listener.cc
diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc
index 0866f26000faafbcfdcefe3b3e72aedf9eb6f2b6..c9d30e49449e7b79f9bfb13f92d59b500f9faf11 100644
--- a/components/nacl/loader/nacl_listener.cc
+++ b/components/nacl/loader/nacl_listener.cc
@@ -18,6 +18,7 @@
#include "base/rand_util.h"
#include "components/nacl/common/nacl_messages.h"
#include "components/nacl/loader/nacl_ipc_adapter.h"
+#include "components/nacl/loader/nacl_trusted_listener.h"
#include "components/nacl/loader/nacl_validation_db.h"
#include "components/nacl/loader/nacl_validation_query.h"
#include "ipc/ipc_channel_handle.h"
@@ -176,6 +177,7 @@ class BrowserValidationDBProxy : public NaClValidationDB {
NaClListener::NaClListener() : shutdown_event_(true, false),
io_thread_("NaCl_IOThread"),
+ chrome_main_thread_("NaCl_ChromeMainThread"),
#if defined(OS_LINUX)
prereserved_sandbox_size_(0),
#endif
@@ -185,6 +187,8 @@ NaClListener::NaClListener() : shutdown_event_(true, false),
main_loop_(NULL) {
io_thread_.StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
+ chrome_main_thread_.StartWithOptions(
+ base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
#if defined(OS_WIN)
DCHECK(g_listener == NULL);
g_listener = this;
@@ -233,6 +237,7 @@ bool NaClListener::OnMessageReceived(const IPC::Message& msg) {
}
void NaClListener::OnStart(const nacl::NaClStartParams& params) {
+ // DCHECK(trusted_plugin_channel_created_);
struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate();
if (args == NULL) {
LOG(ERROR) << "NaClChromeMainArgsCreate() failed";
@@ -333,6 +338,7 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
args->prereserved_sandbox_size = prereserved_sandbox_size_;
#endif
+ // FIXME: Handle nonsfi.
#if defined(OS_LINUX)
if (params.enable_nonsfi_mode) {
nacl::nonsfi::MainStart(args->imc_bootstrap_handle);
@@ -340,6 +346,24 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
return;
}
#endif
- NaClChromeMainStart(args);
- NOTREACHED();
+
+ int irt_fd = args->irt_fd;
+ struct NaClApp* nap = NaClChromeMainCreateApp(args);
+ CreateTrustedPluginChannel(nap, irt_fd);
+}
+
+void NaClListener::CreateTrustedPluginChannel(struct NaClApp* nap, int irt_fd) {
+ fprintf(stderr, "NaClListener::OnCreateTrustedPluginChannel\n");
+ IPC::ChannelHandle handle =
+ IPC::Channel::GenerateVerifiedChannelID("nacl_trusted");
+ trusted_listener_ = new NaClTrustedListener(
+ handle, nap, irt_fd, io_thread_.message_loop_proxy().get(),
+ &shutdown_event_);
+#if defined(OS_POSIX)
+ handle.socket = base::FileDescriptor(
+ trusted_listener_->TakeClientFileDescriptor(), true);
+#endif
+ if (!Send(new NaClProcessHostMsg_TrustedPluginChannelCreated(handle)))
+ LOG(ERROR) << "Failed to send trusted plugin IPC channel handle "
+ << "to NaClProcessHost.";
}

Powered by Google App Engine
This is Rietveld 408576698