| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/nacl_host/nacl_process_host.h" | 7 #include "chrome/browser/nacl_host/nacl_process_host.h" |
| 8 | 8 |
| 9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/metrics/nacl_histogram.h" | 14 #include "base/metrics/nacl_histogram.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "base/win/windows_version.h" |
| 16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/logging_chrome.h" | 18 #include "chrome/common/logging_chrome.h" |
| 18 #include "chrome/common/nacl_cmd_line.h" | 19 #include "chrome/common/nacl_cmd_line.h" |
| 19 #include "chrome/common/nacl_messages.h" | 20 #include "chrome/common/nacl_messages.h" |
| 20 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
| 21 #include "content/browser/renderer_host/render_message_filter.h" | 22 #include "content/browser/renderer_host/render_message_filter.h" |
| 22 #include "ipc/ipc_switches.h" | 23 #include "ipc/ipc_switches.h" |
| 23 #include "native_client/src/shared/imc/nacl_imc.h" | 24 #include "native_client/src/shared/imc/nacl_imc.h" |
| 24 | 25 |
| 25 #if defined(OS_POSIX) | 26 #if defined(OS_POSIX) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 51 NaClProcessHost::NaClProcessHost( | 52 NaClProcessHost::NaClProcessHost( |
| 52 ResourceDispatcherHost *resource_dispatcher_host, | 53 ResourceDispatcherHost *resource_dispatcher_host, |
| 53 const std::wstring& url) | 54 const std::wstring& url) |
| 54 : BrowserChildProcessHost(NACL_LOADER_PROCESS, resource_dispatcher_host), | 55 : BrowserChildProcessHost(NACL_LOADER_PROCESS, resource_dispatcher_host), |
| 55 resource_dispatcher_host_(resource_dispatcher_host), | 56 resource_dispatcher_host_(resource_dispatcher_host), |
| 56 reply_msg_(NULL), | 57 reply_msg_(NULL), |
| 57 internal_(new NaClInternal()), | 58 internal_(new NaClInternal()), |
| 58 running_on_wow64_(false) { | 59 running_on_wow64_(false) { |
| 59 set_name(url); | 60 set_name(url); |
| 60 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 61 CheckIsWow64(); | 62 running_on_wow64_ = (base::win::GetWOW64Status() == base::win::WOW64_ENABLED); |
| 62 #endif | 63 #endif |
| 63 } | 64 } |
| 64 | 65 |
| 65 NaClProcessHost::~NaClProcessHost() { | 66 NaClProcessHost::~NaClProcessHost() { |
| 66 if (!reply_msg_) | 67 if (!reply_msg_) |
| 67 return; | 68 return; |
| 68 | 69 |
| 69 // nacl::Close() is not available at link time if DISABLE_NACL is | 70 // nacl::Close() is not available at link time if DISABLE_NACL is |
| 70 // defined, but we still compile a bunch of other code from this | 71 // defined, but we still compile a bunch of other code from this |
| 71 // file anyway. TODO(mseaborn): Make this less messy. | 72 // file anyway. TODO(mseaborn): Make this less messy. |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 295 } |
| 295 | 296 |
| 296 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { | 297 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 297 NOTREACHED() << "Invalid message with type = " << msg.type(); | 298 NOTREACHED() << "Invalid message with type = " << msg.type(); |
| 298 return false; | 299 return false; |
| 299 } | 300 } |
| 300 | 301 |
| 301 bool NaClProcessHost::CanShutdown() { | 302 bool NaClProcessHost::CanShutdown() { |
| 302 return true; | 303 return true; |
| 303 } | 304 } |
| 304 | |
| 305 #if defined(OS_WIN) | |
| 306 // TODO(gregoryd): invoke CheckIsWow64 only once, not for each NaClProcessHost | |
| 307 typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); | |
| 308 void NaClProcessHost::CheckIsWow64() { | |
| 309 LPFN_ISWOW64PROCESS fnIsWow64Process; | |
| 310 | |
| 311 fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( | |
| 312 GetModuleHandle(TEXT("kernel32")), | |
| 313 "IsWow64Process"); | |
| 314 | |
| 315 if (fnIsWow64Process != NULL) { | |
| 316 BOOL bIsWow64 = FALSE; | |
| 317 if (fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) { | |
| 318 if (bIsWow64) { | |
| 319 running_on_wow64_ = true; | |
| 320 } | |
| 321 } | |
| 322 } | |
| 323 } | |
| 324 #endif | |
| OLD | NEW |