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

Unified Diff: chrome/nacl/nacl_broker_listener.cc

Issue 7863024: Make the NaCl windows 64 bit binaries not depend on chrome targets. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: simplify chrome_exe.gypi Created 9 years, 3 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
« no previous file with comments | « chrome/nacl/nacl_broker_listener.h ('k') | chrome/nacl/nacl_exe_win_64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/nacl/nacl_broker_listener.cc
===================================================================
--- chrome/nacl/nacl_broker_listener.cc (revision 100565)
+++ chrome/nacl/nacl_broker_listener.cc (working copy)
@@ -2,35 +2,45 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/nacl/broker_thread.h"
+#include "chrome/nacl/nacl_broker_listener.h"
#include "base/base_switches.h"
#include "base/command_line.h"
+#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/process_util.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/nacl_cmd_line.h"
#include "chrome/common/nacl_messages.h"
-#include "content/common/child_process.h"
+#include "content/common/content_switches.h"
#include "content/common/sandbox_policy.h"
#include "ipc/ipc_switches.h"
-NaClBrokerThread::NaClBrokerThread()
- : browser_handle_(0),
- broker_services_(NULL) {
+NaClBrokerListener::NaClBrokerListener()
+ : browser_handle_(base::kNullProcessHandle) {
}
-NaClBrokerThread::~NaClBrokerThread() {
+NaClBrokerListener::~NaClBrokerListener() {
base::CloseProcessHandle(browser_handle_);
}
-NaClBrokerThread* NaClBrokerThread::current() {
- return static_cast<NaClBrokerThread*>(ChildThread::current());
+void NaClBrokerListener::Listen() {
+ std::string channel_name =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kProcessChannelID);
+ channel_.reset(new IPC::Channel(
+ channel_name, IPC::Channel::MODE_CLIENT, this));
+ CHECK(channel_->Connect());
+ MessageLoop::current()->Run();
}
-bool NaClBrokerThread::OnControlMessageReceived(const IPC::Message& msg) {
+void NaClBrokerListener::OnChannelConnected(int32 peer_pid) {
+ bool res = base::OpenProcessHandle(peer_pid, &browser_handle_);
+ CHECK(res);
+}
+
+bool NaClBrokerListener::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(NaClBrokerThread, msg)
+ IPC_BEGIN_MESSAGE_MAP(NaClBrokerListener, msg)
IPC_MESSAGE_HANDLER(NaClProcessMsg_LaunchLoaderThroughBroker,
OnLaunchLoaderThroughBroker)
IPC_MESSAGE_HANDLER(NaClProcessMsg_StopBroker, OnStopBroker)
@@ -39,7 +49,7 @@
return handled;
}
-void NaClBrokerThread::OnLaunchLoaderThroughBroker(
+void NaClBrokerListener::OnLaunchLoaderThroughBroker(
const std::wstring& loader_channel_id) {
base::ProcessHandle loader_process = 0;
base::ProcessHandle loader_handle_in_browser = 0;
@@ -62,21 +72,14 @@
loader_process = sandbox::StartProcessWithAccess(cmd_line, FilePath());
if (loader_process) {
DuplicateHandle(::GetCurrentProcess(), loader_process,
- browser_handle_, &loader_handle_in_browser,
- PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION , FALSE, 0);
+ browser_handle_, &loader_handle_in_browser,
+ PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION , FALSE, 0);
}
}
- Send(new NaClProcessMsg_LoaderLaunched(loader_channel_id,
- loader_handle_in_browser));
+ channel_->Send(new NaClProcessMsg_LoaderLaunched(loader_channel_id,
+ loader_handle_in_browser));
}
-void NaClBrokerThread::OnStopBroker() {
- ChildProcess::current()->ReleaseProcess();
+void NaClBrokerListener::OnStopBroker() {
+ MessageLoop::current()->Quit();
}
-
-void NaClBrokerThread::OnChannelConnected(int32 peer_pid) {
- bool res = base::OpenProcessHandle(peer_pid, &browser_handle_);
- DCHECK(res);
- ChildProcess::current()->AddRefProcess();
-}
-
« no previous file with comments | « chrome/nacl/nacl_broker_listener.h ('k') | chrome/nacl/nacl_exe_win_64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698