diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-19 07:11:52 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-19 07:11:52 +0000 |
commit | 1d8a3d1fe0e07d5aaf1f0a5527097b9e313d23b6 (patch) | |
tree | b298f570c373f95b55cdfb8334ab7b510b5942c4 /chrome/browser/nacl_host | |
parent | 3e45d8f9c4c6eabec2458cc5e0b481e73f2705ab (diff) | |
download | chromium_src-1d8a3d1fe0e07d5aaf1f0a5527097b9e313d23b6.zip chromium_src-1d8a3d1fe0e07d5aaf1f0a5527097b9e313d23b6.tar.gz chromium_src-1d8a3d1fe0e07d5aaf1f0a5527097b9e313d23b6.tar.bz2 |
Move core pieces of browser\renderer_host to src\content.
TBR=avi
Review URL: http://codereview.chromium.org/6532073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/nacl_host')
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.cc | 37 | ||||
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.h | 10 |
2 files changed, 30 insertions, 17 deletions
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc index 18b727e..138bb08 100644 --- a/chrome/browser/nacl_host/nacl_process_host.cc +++ b/chrome/browser/nacl_host/nacl_process_host.cc @@ -20,6 +20,7 @@ #include "chrome/common/nacl_messages.h" #include "chrome/common/render_messages.h" #include "ipc/ipc_switches.h" +#include "native_client/src/shared/imc/nacl_imc.h" #if defined(OS_POSIX) #include "ipc/ipc_channel_posix.h" @@ -42,12 +43,18 @@ void SetCloseOnExec(nacl::Handle fd) { } // namespace +struct NaClProcessHost::NaClInternal { + std::vector<nacl::Handle> sockets_for_renderer; + std::vector<nacl::Handle> sockets_for_sel_ldr; +}; + NaClProcessHost::NaClProcessHost( ResourceDispatcherHost *resource_dispatcher_host, const std::wstring& url) : BrowserChildProcessHost(NACL_LOADER_PROCESS, resource_dispatcher_host), resource_dispatcher_host_(resource_dispatcher_host), reply_msg_(NULL), + internal_(new NaClInternal()), running_on_wow64_(false) { set_name(url); #if defined(OS_WIN) @@ -63,11 +70,11 @@ NaClProcessHost::~NaClProcessHost() { // defined, but we still compile a bunch of other code from this // file anyway. TODO(mseaborn): Make this less messy. #ifndef DISABLE_NACL - for (size_t i = 0; i < sockets_for_renderer_.size(); i++) { - nacl::Close(sockets_for_renderer_[i]); + for (size_t i = 0; i < internal_->sockets_for_renderer.size(); i++) { + nacl::Close(internal_->sockets_for_renderer[i]); } - for (size_t i = 0; i < sockets_for_sel_ldr_.size(); i++) { - nacl::Close(sockets_for_sel_ldr_[i]); + for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) { + nacl::Close(internal_->sockets_for_sel_ldr[i]); } #endif @@ -105,8 +112,8 @@ bool NaClProcessHost::Launch(RenderMessageFilter* render_message_filter, // Create a connected socket if (nacl::SocketPair(pair) == -1) return false; - sockets_for_renderer_.push_back(pair[0]); - sockets_for_sel_ldr_.push_back(pair[1]); + internal_->sockets_for_renderer.push_back(pair[0]); + internal_->sockets_for_sel_ldr.push_back(pair[1]); SetCloseOnExec(pair[0]); SetCloseOnExec(pair[1]); } @@ -183,12 +190,13 @@ void NaClProcessHost::OnProcessLaunched() { std::vector<nacl::FileDescriptor> handles_for_renderer; base::ProcessHandle nacl_process_handle; - for (size_t i = 0; i < sockets_for_renderer_.size(); i++) { + for (size_t i = 0; i < internal_->sockets_for_renderer.size(); i++) { #if defined(OS_WIN) // Copy the handle into the renderer process. HANDLE handle_in_renderer; DuplicateHandle(base::GetCurrentProcessHandle(), - reinterpret_cast<HANDLE>(sockets_for_renderer_[i]), + reinterpret_cast<HANDLE>( + internal_->sockets_for_renderer[i]), render_message_filter_->peer_handle(), &handle_in_renderer, GENERIC_READ | GENERIC_WRITE, @@ -200,7 +208,7 @@ void NaClProcessHost::OnProcessLaunched() { // No need to dup the imc_handle - we don't pass it anywhere else so // it cannot be closed. nacl::FileDescriptor imc_handle; - imc_handle.fd = sockets_for_renderer_[i]; + imc_handle.fd = internal_->sockets_for_renderer[i]; imc_handle.auto_close = true; handles_for_renderer.push_back(imc_handle); #endif @@ -228,18 +236,19 @@ void NaClProcessHost::OnProcessLaunched() { render_message_filter_->Send(reply_msg_); render_message_filter_ = NULL; reply_msg_ = NULL; - sockets_for_renderer_.clear(); + internal_->sockets_for_renderer.clear(); SendStartMessage(); } void NaClProcessHost::SendStartMessage() { std::vector<nacl::FileDescriptor> handles_for_sel_ldr; - for (size_t i = 0; i < sockets_for_sel_ldr_.size(); i++) { + for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) { #if defined(OS_WIN) HANDLE channel; if (!DuplicateHandle(GetCurrentProcess(), - reinterpret_cast<HANDLE>(sockets_for_sel_ldr_[i]), + reinterpret_cast<HANDLE>( + internal_->sockets_for_sel_ldr[i]), handle(), &channel, GENERIC_READ | GENERIC_WRITE, @@ -250,7 +259,7 @@ void NaClProcessHost::SendStartMessage() { reinterpret_cast<nacl::FileDescriptor>(channel)); #else nacl::FileDescriptor channel; - channel.fd = dup(sockets_for_sel_ldr_[i]); + channel.fd = dup(internal_->sockets_for_sel_ldr[i]); if (channel.fd < 0) { LOG(ERROR) << "Failed to dup() a file descriptor"; return; @@ -281,7 +290,7 @@ void NaClProcessHost::SendStartMessage() { #endif Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); - sockets_for_sel_ldr_.clear(); + internal_->sockets_for_sel_ldr.clear(); } bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { diff --git a/chrome/browser/nacl_host/nacl_process_host.h b/chrome/browser/nacl_host/nacl_process_host.h index c0d5731..c54f6ba 100644 --- a/chrome/browser/nacl_host/nacl_process_host.h +++ b/chrome/browser/nacl_host/nacl_process_host.h @@ -11,7 +11,6 @@ #include "base/ref_counted.h" #include "chrome/browser/browser_child_process_host.h" #include "chrome/common/nacl_types.h" -#include "native_client/src/shared/imc/nacl_imc.h" class RenderMessageFilter; @@ -41,6 +40,12 @@ class NaClProcessHost : public BrowserChildProcessHost { virtual void OnChildDied(); private: + // Internal class that holds the nacl::Handle objecs so that + // nacl_process_host.h doesn't include NaCl headers. Needed since it's + // included by src\content, which can't depend on the NaCl gyp file because it + // depends on chrome.gyp (circular dependency). + struct NaClInternal; + bool LaunchSelLdr(); void SendStartMessage(); @@ -65,8 +70,7 @@ class NaClProcessHost : public BrowserChildProcessHost { IPC::Message* reply_msg_; // Socket pairs for the NaCl process and renderer. - std::vector<nacl::Handle> sockets_for_renderer_; - std::vector<nacl::Handle> sockets_for_sel_ldr_; + scoped_ptr<NaClInternal> internal_; // Windows platform flag bool running_on_wow64_; |