Index: chrome/nacl/nacl_listener.cc |
diff --git a/chrome/nacl/nacl_launcher_thread.cc b/chrome/nacl/nacl_listener.cc |
similarity index 76% |
rename from chrome/nacl/nacl_launcher_thread.cc |
rename to chrome/nacl/nacl_listener.cc |
index ad1c5e44890d9b34ce80c0f4ce51a04a6d8f5ee9..96520707f265f7ec8c2da76e4065c13f973f9815 100644 |
--- a/chrome/nacl/nacl_launcher_thread.cc |
+++ b/chrome/nacl/nacl_listener.cc |
@@ -2,13 +2,17 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/nacl/nacl_launcher_thread.h" |
+#include "chrome/nacl/nacl_listener.h" |
-#include <vector> |
+#include <errno.h> |
-#include "base/atomicops.h" |
+#include "base/command_line.h" |
+#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/message_loop.h" |
#include "chrome/common/nacl_messages.h" |
+#include "ipc/ipc_channel.h" |
+#include "ipc/ipc_switches.h" |
#include "native_client/src/shared/imc/nacl_imc.h" |
#if defined(OS_LINUX) |
@@ -20,6 +24,15 @@ |
#include <io.h> |
#endif |
+// This is ugly. We need an interface header file for the exported |
+// sel_ldr interfaces. |
+// TODO(gregoryd,sehr): Add an interface header. |
+#if defined(OS_WIN) |
+typedef HANDLE NaClHandle; |
+#else |
+typedef int NaClHandle; |
+#endif // NaClHandle |
+ |
#if defined(OS_MACOSX) |
namespace { |
@@ -56,43 +69,34 @@ int CreateMemoryObject(size_t size, bool executable) { |
} // namespace |
#endif // defined(OS_MACOSX) |
-// This is ugly. We need an interface header file for the exported |
-// sel_ldr interfaces. |
-// TODO(gregoryd,sehr): Add an interface header. |
-#if defined(OS_WIN) |
-typedef HANDLE NaClHandle; |
-#else |
-typedef int NaClHandle; |
-#endif // NaClHandle |
- |
-// This is currently necessary because we have a conflict between |
-// NaCl's LOG_FATAL (from platform/nacl_log.h) and Chromium's |
-// LOG_FATAL (from base/logging.h). |
-extern "C" int NaClMainForChromium(int handle_count, const NaClHandle* handles, |
+extern "C" int NaClMainForChromium(int handle_count, |
+ const NaClHandle* handles, |
int debug); |
extern "C" void NaClSetIrtFileDesc(int fd); |
-NaClLauncherThread::NaClLauncherThread(bool debug) { |
- debug_enabled_ = debug ? 1 : 0; |
-} |
+NaClListener::NaClListener() {} |
-NaClLauncherThread::~NaClLauncherThread() { |
-} |
+NaClListener::~NaClListener() {} |
-NaClLauncherThread* NaClLauncherThread::current() { |
- return static_cast<NaClLauncherThread*>(ChildThread::current()); |
+void NaClListener::Listen() { |
+ std::string channel_name = |
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
+ switches::kProcessChannelID); |
+ IPC::Channel channel(channel_name, IPC::Channel::MODE_CLIENT, this); |
+ CHECK(channel.Connect()); |
+ MessageLoop::current()->Run(); |
} |
-bool NaClLauncherThread::OnControlMessageReceived(const IPC::Message& msg) { |
+bool NaClListener::OnMessageReceived(const IPC::Message& msg) { |
bool handled = true; |
- IPC_BEGIN_MESSAGE_MAP(NaClLauncherThread, msg) |
- IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStartSelLdr) |
- IPC_MESSAGE_UNHANDLED(handled = false) |
+ IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) |
+ IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStartSelLdr) |
+ IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
return handled; |
} |
-void NaClLauncherThread::OnStartSelLdr( |
+void NaClListener::OnStartSelLdr( |
std::vector<nacl::FileDescriptor> handles, |
bool have_irt_file) { |
#if defined(OS_LINUX) |
@@ -127,5 +131,5 @@ void NaClLauncherThread::OnStartSelLdr( |
array[i] = nacl::ToNativeHandle(handles[i]); |
} |
NaClMainForChromium(static_cast<int>(handles.size()), array.get(), |
- debug_enabled_); |
+ false /* debug */); |
} |