summaryrefslogtreecommitdiffstats
path: root/chrome/browser/nacl_host
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/nacl_host')
-rw-r--r--chrome/browser/nacl_host/nacl_broker_host_win.cc15
-rw-r--r--chrome/browser/nacl_host/nacl_broker_host_win.h14
-rw-r--r--chrome/browser/nacl_host/nacl_broker_service_win.cc8
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.cc38
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.h18
5 files changed, 58 insertions, 35 deletions
diff --git a/chrome/browser/nacl_host/nacl_broker_host_win.cc b/chrome/browser/nacl_host/nacl_broker_host_win.cc
index d64c1ea..186e15e 100644
--- a/chrome/browser/nacl_host/nacl_broker_host_win.cc
+++ b/chrome/browser/nacl_host/nacl_broker_host_win.cc
@@ -14,11 +14,13 @@
#include "chrome/common/logging_chrome.h"
#include "chrome/common/nacl_cmd_line.h"
#include "chrome/common/nacl_messages.h"
+#include "content/public/browser/browser_child_process_host.h"
#include "content/public/common/child_process_host.h"
NaClBrokerHost::NaClBrokerHost()
- : BrowserChildProcessHost(content::PROCESS_TYPE_NACL_BROKER),
- stopping_(false) {
+ : stopping_(false) {
+ process_.reset(content::BrowserChildProcessHost::Create(
+ content::PROCESS_TYPE_NACL_BROKER, this));
}
NaClBrokerHost::~NaClBrokerHost() {
@@ -26,7 +28,7 @@ NaClBrokerHost::~NaClBrokerHost() {
bool NaClBrokerHost::Init() {
// Create the channel that will be used for communicating with the broker.
- std::string channel_id = child_process_host()->CreateChannel();
+ std::string channel_id = process_->GetHost()->CreateChannel();
if (channel_id.empty())
return false;
@@ -45,7 +47,7 @@ bool NaClBrokerHost::Init() {
if (logging::DialogsAreSuppressed())
cmd_line->AppendSwitch(switches::kNoErrorDialogs);
- BrowserChildProcessHost::Launch(FilePath(), cmd_line);
+ process_->Launch(FilePath(), cmd_line);
return true;
}
@@ -60,7 +62,8 @@ bool NaClBrokerHost::OnMessageReceived(const IPC::Message& msg) {
bool NaClBrokerHost::LaunchLoader(
const std::wstring& loader_channel_id) {
- return Send(new NaClProcessMsg_LaunchLoaderThroughBroker(loader_channel_id));
+ return process_->Send(
+ new NaClProcessMsg_LaunchLoaderThroughBroker(loader_channel_id));
}
void NaClBrokerHost::OnLoaderLaunched(const std::wstring& loader_channel_id,
@@ -70,5 +73,5 @@ void NaClBrokerHost::OnLoaderLaunched(const std::wstring& loader_channel_id,
void NaClBrokerHost::StopBroker() {
stopping_ = true;
- Send(new NaClProcessMsg_StopBroker());
+ process_->Send(new NaClProcessMsg_StopBroker());
}
diff --git a/chrome/browser/nacl_host/nacl_broker_host_win.h b/chrome/browser/nacl_host/nacl_broker_host_win.h
index bcb3a44..368f462 100644
--- a/chrome/browser/nacl_host/nacl_broker_host_win.h
+++ b/chrome/browser/nacl_host/nacl_broker_host_win.h
@@ -7,9 +7,15 @@
#pragma once
#include "base/basictypes.h"
-#include "content/browser/browser_child_process_host.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/process.h"
+#include "content/public/browser/browser_child_process_host_delegate.h"
-class NaClBrokerHost : public BrowserChildProcessHost {
+namespace content {
+class BrowserChildProcessHost;
+}
+
+class NaClBrokerHost : public content::BrowserChildProcessHostDelegate {
public:
NaClBrokerHost();
~NaClBrokerHost();
@@ -30,11 +36,13 @@ class NaClBrokerHost : public BrowserChildProcessHost {
void OnLoaderLaunched(const std::wstring& loader_channel_id,
base::ProcessHandle handle);
- // BrowserChildProcessHost implementation:
+ // BrowserChildProcessHostDelegate implementation:
virtual bool OnMessageReceived(const IPC::Message& msg);
bool stopping_;
+ scoped_ptr<content::BrowserChildProcessHost> process_;
+
DISALLOW_COPY_AND_ASSIGN(NaClBrokerHost);
};
diff --git a/chrome/browser/nacl_host/nacl_broker_service_win.cc b/chrome/browser/nacl_host/nacl_broker_service_win.cc
index 7e93e3e..8b7bd90b 100644
--- a/chrome/browser/nacl_host/nacl_broker_service_win.cc
+++ b/chrome/browser/nacl_host/nacl_broker_service_win.cc
@@ -5,6 +5,9 @@
#include "chrome/browser/nacl_host/nacl_broker_service_win.h"
#include "chrome/browser/nacl_host/nacl_process_host.h"
+#include "content/public/browser/browser_child_process_host_iterator.h"
+
+using content::BrowserChildProcessHostIterator;
NaClBrokerService* NaClBrokerService::GetInstance() {
return Singleton<NaClBrokerService>::get();
@@ -62,9 +65,8 @@ void NaClBrokerService::OnLoaderDied() {
}
NaClBrokerHost* NaClBrokerService::GetBrokerHost() {
- BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_NACL_BROKER);
+ BrowserChildProcessHostIterator iter(content::PROCESS_TYPE_NACL_BROKER);
if (iter.Done())
return NULL;
- NaClBrokerHost* broker_host = static_cast<NaClBrokerHost*>(*iter);
- return broker_host;
+ return static_cast<NaClBrokerHost*>(iter.GetDelegate());
}
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index da2ae24..7d8ddd3 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -24,6 +24,8 @@
#include "chrome/common/nacl_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
+#include "content/public/browser/browser_child_process_host.h"
+#include "content/public/browser/child_process_data.h"
#include "content/public/common/child_process_host.h"
#include "ipc/ipc_switches.h"
#include "native_client/src/shared/imc/nacl_imc.h"
@@ -35,6 +37,7 @@
#endif
using content::BrowserThread;
+using content::ChildProcessData;
using content::ChildProcessHost;
namespace {
@@ -109,16 +112,17 @@ static bool RunningOnWOW64() {
#endif
NaClProcessHost::NaClProcessHost(const std::wstring& url)
- : BrowserChildProcessHost(content::PROCESS_TYPE_NACL_LOADER),
- reply_msg_(NULL),
+ : reply_msg_(NULL),
internal_(new NaClInternal()),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
- SetName(WideToUTF16Hack(url));
+ process_.reset(content::BrowserChildProcessHost::Create(
+ content::PROCESS_TYPE_NACL_LOADER, this));
+ process_->SetName(WideToUTF16Hack(url));
}
NaClProcessHost::~NaClProcessHost() {
int exit_code;
- GetChildTerminationStatus(&exit_code);
+ process_->GetTerminationStatus(&exit_code);
std::string message =
base::StringPrintf("NaCl process exited with status %i (0x%x)",
exit_code, exit_code);
@@ -234,7 +238,7 @@ bool NaClProcessHost::Launch(
}
bool NaClProcessHost::LaunchSelLdr() {
- std::string channel_id = child_process_host()->CreateChannel();
+ std::string channel_id = process_->GetHost()->CreateChannel();
if (channel_id.empty())
return false;
@@ -283,19 +287,19 @@ bool NaClProcessHost::LaunchSelLdr() {
return NaClBrokerService::GetInstance()->LaunchLoader(
this, ASCIIToWide(channel_id));
} else {
- BrowserChildProcessHost::Launch(FilePath(), cmd_line);
+ process_->Launch(FilePath(), cmd_line);
}
#elif defined(OS_POSIX)
- BrowserChildProcessHost::Launch(nacl_loader_prefix.empty(), // use_zygote
- base::environment_vector(),
- cmd_line);
+ process_->Launch(nacl_loader_prefix.empty(), // use_zygote
+ base::environment_vector(),
+ cmd_line);
#endif
return true;
}
void NaClProcessHost::OnProcessLaunchedByBroker(base::ProcessHandle handle) {
- SetHandle(handle);
+ process_->SetHandle(handle);
OnProcessLaunched();
}
@@ -469,10 +473,11 @@ void NaClProcessHost::SendStart(base::PlatformFile irt_file) {
#endif
}
+ const ChildProcessData& data = process_->GetData();
#if defined(OS_WIN)
// Copy the process handle into the renderer process.
if (!DuplicateHandle(base::GetCurrentProcessHandle(),
- data().handle,
+ data.handle,
chrome_render_message_filter_->peer_handle(),
&nacl_process_handle,
PROCESS_DUP_HANDLE,
@@ -484,11 +489,11 @@ void NaClProcessHost::SendStart(base::PlatformFile irt_file) {
}
#else
// We use pid as process handle on Posix
- nacl_process_handle = data().handle;
+ nacl_process_handle = data.handle;
#endif
// Get the pid of the NaCl process
- base::ProcessId nacl_process_id = base::GetProcId(data().handle);
+ base::ProcessId nacl_process_id = base::GetProcId(data.handle);
ChromeViewHostMsg_LaunchNaCl::WriteReplyParams(
reply_msg_, handles_for_renderer, nacl_process_handle, nacl_process_id);
@@ -499,7 +504,7 @@ void NaClProcessHost::SendStart(base::PlatformFile irt_file) {
std::vector<nacl::FileDescriptor> handles_for_sel_ldr;
for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) {
- if (!SendHandleToSelLdr(data().handle,
+ if (!SendHandleToSelLdr(data.handle,
internal_->sockets_for_sel_ldr[i], true,
&handles_for_sel_ldr)) {
delete this;
@@ -508,8 +513,7 @@ void NaClProcessHost::SendStart(base::PlatformFile irt_file) {
}
// Send over the IRT file handle. We don't close our own copy!
- if (!SendHandleToSelLdr(
- data().handle, irt_file, false, &handles_for_sel_ldr)) {
+ if (!SendHandleToSelLdr(data.handle, irt_file, false, &handles_for_sel_ldr)) {
delete this;
return;
}
@@ -539,7 +543,7 @@ void NaClProcessHost::SendStart(base::PlatformFile irt_file) {
handles_for_sel_ldr.push_back(memory_fd);
#endif
- Send(new NaClProcessMsg_Start(handles_for_sel_ldr));
+ process_->Send(new NaClProcessMsg_Start(handles_for_sel_ldr));
internal_->sockets_for_sel_ldr.clear();
}
diff --git a/chrome/browser/nacl_host/nacl_process_host.h b/chrome/browser/nacl_host/nacl_process_host.h
index 0677801..56f0553 100644
--- a/chrome/browser/nacl_host/nacl_process_host.h
+++ b/chrome/browser/nacl_host/nacl_process_host.h
@@ -12,18 +12,23 @@
#include "base/file_util_proxy.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/process.h"
#include "chrome/common/nacl_types.h"
-#include "content/browser/browser_child_process_host.h"
+#include "content/public/browser/browser_child_process_host_delegate.h"
class ChromeRenderMessageFilter;
+namespace content {
+class BrowserChildProcessHost;
+}
+
// Represents the browser side of the browser <--> NaCl communication
// channel. There will be one NaClProcessHost per NaCl process
// The browser is responsible for starting the NaCl process
// when requested by the renderer.
// After that, most of the communication is directly between NaCl plugin
// running in the renderer and NaCl processes.
-class NaClProcessHost : public BrowserChildProcessHost {
+class NaClProcessHost : public content::BrowserChildProcessHostDelegate {
public:
explicit NaClProcessHost(const std::wstring& url);
virtual ~NaClProcessHost();
@@ -39,10 +44,6 @@ class NaClProcessHost : public BrowserChildProcessHost {
int socket_count,
IPC::Message* reply_msg);
- // BrowserChildProcessHost implementation:
- virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
- virtual void OnProcessCrashed(int exit_code) OVERRIDE;
-
void OnProcessLaunchedByBroker(base::ProcessHandle handle);
private:
@@ -54,6 +55,9 @@ class NaClProcessHost : public BrowserChildProcessHost {
bool LaunchSelLdr();
+ // BrowserChildProcessHostDelegate implementation:
+ virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
+ virtual void OnProcessCrashed(int exit_code) OVERRIDE;
virtual void OnProcessLaunched() OVERRIDE;
void IrtReady();
@@ -74,6 +78,8 @@ class NaClProcessHost : public BrowserChildProcessHost {
base::WeakPtrFactory<NaClProcessHost> weak_factory_;
+ scoped_ptr<content::BrowserChildProcessHost> process_;
+
DISALLOW_COPY_AND_ASSIGN(NaClProcessHost);
};