summaryrefslogtreecommitdiffstats
path: root/chrome/browser/nacl_host
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2011-06-09 11:47:42 +0100
committerKristian Monsen <kristianm@google.com>2011-06-29 14:33:03 +0100
commitdc0f95d653279beabeb9817299e2902918ba123e (patch)
tree32eb121cd532053a5b9cb0c390331349af8d6baa /chrome/browser/nacl_host
parentba160cd4054d13d0cb0b1b46e61c3bed67095811 (diff)
downloadexternal_chromium-dc0f95d653279beabeb9817299e2902918ba123e.zip
external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.gz
external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.bz2
Merge Chromium at r11.0.696.0: Initial merge by git
Change-Id: I273dde2843af0839dfc08b419bb443fbd449532d
Diffstat (limited to 'chrome/browser/nacl_host')
-rw-r--r--chrome/browser/nacl_host/nacl_broker_host_win.h2
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.cc65
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.h17
3 files changed, 36 insertions, 48 deletions
diff --git a/chrome/browser/nacl_host/nacl_broker_host_win.h b/chrome/browser/nacl_host/nacl_broker_host_win.h
index 27ceb24..f226564 100644
--- a/chrome/browser/nacl_host/nacl_broker_host_win.h
+++ b/chrome/browser/nacl_host/nacl_broker_host_win.h
@@ -7,7 +7,7 @@
#pragma once
#include "base/basictypes.h"
-#include "chrome/browser/browser_child_process_host.h"
+#include "content/browser/browser_child_process_host.h"
class NaClBrokerHost : public BrowserChildProcessHost {
public:
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index 18b727e..2b97881 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,13 +13,15 @@
#include "base/command_line.h"
#include "base/metrics/nacl_histogram.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/renderer_host/render_message_filter.h"
+#include "base/win/windows_version.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/nacl_cmd_line.h"
#include "chrome/common/nacl_messages.h"
#include "chrome/common/render_messages.h"
+#include "content/browser/renderer_host/render_message_filter.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,16 +44,22 @@ 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)
- CheckIsWow64();
+ running_on_wow64_ = (base::win::GetWOW64Status() == base::win::WOW64_ENABLED);
#endif
}
@@ -63,11 +71,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 +113,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 +191,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 +209,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 +237,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 +260,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 +291,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) {
@@ -292,24 +302,3 @@ bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) {
bool NaClProcessHost::CanShutdown() {
return true;
}
-
-#if defined(OS_WIN)
-// TODO(gregoryd): invoke CheckIsWow64 only once, not for each NaClProcessHost
-typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
-void NaClProcessHost::CheckIsWow64() {
- LPFN_ISWOW64PROCESS fnIsWow64Process;
-
- fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
- GetModuleHandle(TEXT("kernel32")),
- "IsWow64Process");
-
- if (fnIsWow64Process != NULL) {
- BOOL bIsWow64 = FALSE;
- if (fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) {
- if (bIsWow64) {
- running_on_wow64_ = true;
- }
- }
- }
-}
-#endif
diff --git a/chrome/browser/nacl_host/nacl_process_host.h b/chrome/browser/nacl_host/nacl_process_host.h
index c0d5731..b4deaea 100644
--- a/chrome/browser/nacl_host/nacl_process_host.h
+++ b/chrome/browser/nacl_host/nacl_process_host.h
@@ -9,9 +9,8 @@
#include "build/build_config.h"
#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"
+#include "content/browser/browser_child_process_host.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();
@@ -49,11 +54,6 @@ class NaClProcessHost : public BrowserChildProcessHost {
virtual bool CanShutdown();
-#if defined(OS_WIN)
- // Check whether the browser process is running on WOW64 - Windows only
- void CheckIsWow64();
-#endif
-
private:
ResourceDispatcherHost* resource_dispatcher_host_;
@@ -65,8 +65,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_;