diff options
author | gregoryd@google.com <gregoryd@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-30 00:29:54 +0000 |
---|---|---|
committer | gregoryd@google.com <gregoryd@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-30 00:29:54 +0000 |
commit | 0b6e0a2ba1c90550d2dc4e33e2d0d282e09ebfdb (patch) | |
tree | 7e0c2f17e82dd477294d26a51051bee13c4dc5bb /chrome/nacl | |
parent | 732a0f086db4bfdfd29749c3a500af0405934b6f (diff) | |
download | chromium_src-0b6e0a2ba1c90550d2dc4e33e2d0d282e09ebfdb.zip chromium_src-0b6e0a2ba1c90550d2dc4e33e2d0d282e09ebfdb.tar.gz chromium_src-0b6e0a2ba1c90550d2dc4e33e2d0d282e09ebfdb.tar.bz2 |
Revert 37578 - Implement the broker process that launches NaCl loader processes on 64bit Windows systems.
BUG=28176
TEST=none
Review URL: http://codereview.chromium.org/542030
TBR=gregoryd@google.com
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/nacl')
-rw-r--r-- | chrome/nacl/broker_thread.cc | 72 | ||||
-rw-r--r-- | chrome/nacl/broker_thread.h | 37 | ||||
-rw-r--r-- | chrome/nacl/nacl_main.cc | 67 | ||||
-rw-r--r-- | chrome/nacl/nacl_thread.cc | 2 | ||||
-rw-r--r-- | chrome/nacl/nacl_thread.h | 2 |
5 files changed, 5 insertions, 175 deletions
diff --git a/chrome/nacl/broker_thread.cc b/chrome/nacl/broker_thread.cc deleted file mode 100644 index 0b4bbd2..0000000 --- a/chrome/nacl/broker_thread.cc +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2010 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. - -#include "chrome/nacl/broker_thread.h" - -#include "base/base_switches.h" -#include "base/command_line.h" -#include "base/path_service.h" -#include "base/process_util.h" -#include "chrome/common/sandbox_policy.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/nacl_cmd_line.h" -#include "chrome/common/nacl_messages.h" -#include "ipc/ipc_switches.h" - -NaClBrokerThread::NaClBrokerThread() - : browser_handle_(0), - broker_services_(NULL) { -} - -NaClBrokerThread::~NaClBrokerThread() { - base::CloseProcessHandle(browser_handle_); -} - -NaClBrokerThread* NaClBrokerThread::current() { - return static_cast<NaClBrokerThread*>(ChildThread::current()); -} - -void NaClBrokerThread::OnControlMessageReceived(const IPC::Message& msg) { - IPC_BEGIN_MESSAGE_MAP(NaClBrokerThread, msg) - IPC_MESSAGE_HANDLER(NaClProcessMsg_LaunchLoaderThroughBroker, - OnLaunchLoaderThroughBroker) - IPC_END_MESSAGE_MAP() -} - -void NaClBrokerThread::OnLaunchLoaderThroughBroker( - const std::wstring& loader_channel_id) { - base::ProcessHandle loader_process = 0; - base::ProcessHandle loader_handle_in_browser = 0; - - // Create the path to the nacl broker/loader executable - it's the executable - // this code is running in. - FilePath exe_path; - PathService::Get(base::FILE_EXE, &exe_path); - if (!exe_path.empty()) { - CommandLine* cmd_line = new CommandLine(exe_path); - nacl::CopyNaClCommandLineArguments(cmd_line); - - cmd_line->AppendSwitchWithValue(switches::kProcessType, - switches::kNaClLoaderProcess); - - cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, - loader_channel_id); - - loader_process = sandbox::StartProcessWithAccess(cmd_line, FilePath()); - if (loader_process) { - DuplicateHandle(::GetCurrentProcess(), loader_process, - browser_handle_, &loader_handle_in_browser, - PROCESS_DUP_HANDLE, FALSE, 0); - } - } - Send(new NaClProcessMsg_LoaderLaunched(loader_channel_id, - loader_handle_in_browser)); -} - -void NaClBrokerThread::OnChannelConnected(int32 peer_pid) { - bool res = base::OpenProcessHandle(peer_pid, &browser_handle_); - DCHECK(res); - Send(new NaClProcessMsg_BrokerReady()); -} - diff --git a/chrome/nacl/broker_thread.h b/chrome/nacl/broker_thread.h deleted file mode 100644 index d88919f..0000000 --- a/chrome/nacl/broker_thread.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2010 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. - -#ifndef CHROME_NACL_BROKER_THREAD_H_ -#define CHROME_NACL_BROKER_THREAD_H_ - -#include "chrome/common/child_thread.h" -#include "chrome/common/nacl_types.h" - -#if defined(OS_WIN) -#include "sandbox/src/sandbox.h" -#endif - -// The BrokerThread class represents the thread that handles the messages from -// the browser process and starts NaCl loader processes. -class NaClBrokerThread : public ChildThread { - public: - NaClBrokerThread(); - ~NaClBrokerThread(); - // Returns the one NaCl thread. - static NaClBrokerThread* current(); - - virtual void OnChannelConnected(int32 peer_pid); - - private: - virtual void OnControlMessageReceived(const IPC::Message& msg); - void OnLaunchLoaderThroughBroker(const std::wstring& loader_channel_id); - void OnShareBrowserHandle(int browser_handle); - - base::ProcessHandle browser_handle_; - sandbox::BrokerServices* broker_services_; - - DISALLOW_COPY_AND_ASSIGN(NaClBrokerThread); -}; - -#endif // CHROME_NACL_BROKER_THREAD_H_ diff --git a/chrome/nacl/nacl_main.cc b/chrome/nacl/nacl_main.cc index ffda8ab..72bc8a2 100644 --- a/chrome/nacl/nacl_main.cc +++ b/chrome/nacl/nacl_main.cc @@ -20,66 +20,8 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/main_function_params.h" -#include "chrome/common/result_codes.h" -#if defined(OS_WIN) -#include "chrome/nacl/broker_thread.h" -#endif #include "chrome/nacl/nacl_thread.h" -#ifdef _WIN64 - -sandbox::BrokerServices* g_broker_services = NULL; - -// main() routine for the NaCl broker process. -// This is necessary for supporting NaCl in Chrome on Win64. -int NaClBrokerMain(const MainFunctionParams& parameters) { - // The main thread of the broker. - MessageLoopForIO main_message_loop; - std::wstring app_name = chrome::kNaClAppName; - PlatformThread::SetName(WideToASCII(app_name + L"_NaClBrokerMain").c_str()); - - SystemMonitor system_monitor; - HighResolutionTimerManager hi_res_timer_manager; - - const CommandLine& parsed_command_line = parameters.command_line_; - - DLOG(INFO) << "Started NaCL broker with " << - parsed_command_line.command_line_string(); - - // NOTE: this code is duplicated from browser_main.cc - // IMPORTANT: This piece of code needs to run as early as possible in the - // process because it will initialize the sandbox broker, which requires the - // process to swap its window station. During this time all the UI will be - // broken. This has to run before threads and windows are created. - sandbox::BrokerServices* broker_services = - parameters.sandbox_info_.BrokerServices(); - if (broker_services) { - g_broker_services = broker_services; - if (!parsed_command_line.HasSwitch(switches::kNoSandbox)) { - bool use_winsta = !parsed_command_line.HasSwitch( - switches::kDisableAltWinstation); - // Precreate the desktop and window station used by the renderers. - sandbox::TargetPolicy* policy = broker_services->CreatePolicy(); - sandbox::ResultCode result = policy->CreateAlternateDesktop(use_winsta); - CHECK(sandbox::SBOX_ERROR_FAILED_TO_SWITCH_BACK_WINSTATION != result); - policy->Release(); - } - } - - { - ChildProcess broker_process; - broker_process.set_main_thread(new NaClBrokerThread()); - MessageLoop::current()->Run(); - } - - return 0; -} -#else -int NaClBrokerMain(const MainFunctionParams& parameters) { - return ResultCodes::BAD_PROCESS_TYPE; -} -#endif // _WIN64 - // This function provides some ways to test crash and assertion handling // behavior of the renderer. static void HandleNaClTestParameters(const CommandLine& command_line) { @@ -106,7 +48,7 @@ static void LaunchNaClChildProcess() { } #endif -// main() routine for the NaCl loader process. +// main() routine for running as the sel_ldr process. int NaClMain(const MainFunctionParams& parameters) { const CommandLine& parsed_command_line = parameters.command_line_; @@ -118,12 +60,7 @@ int NaClMain(const MainFunctionParams& parameters) { // The main thread of the plugin services IO. MessageLoopForIO main_message_loop; - // NaCl code runs in a different binary on Win64. -#ifdef _WIN64 - std::wstring app_name = chrome::kNaClAppName; -#else std::wstring app_name = chrome::kBrowserAppName; -#endif PlatformThread::SetName(WideToASCII(app_name + L"_NaClMain").c_str()); SystemMonitor system_monitor; @@ -133,7 +70,7 @@ int NaClMain(const MainFunctionParams& parameters) { sandbox::TargetServices* target_services = parameters.sandbox_info_.TargetServices(); - DLOG(INFO) << "Started NaCl loader with " << + DLOG(INFO) << "Started plugin with " << parsed_command_line.command_line_string(); HMODULE sandbox_test_module = NULL; diff --git a/chrome/nacl/nacl_thread.cc b/chrome/nacl/nacl_thread.cc index 0f05f06..4c9dd5f05 100644 --- a/chrome/nacl/nacl_thread.cc +++ b/chrome/nacl/nacl_thread.cc @@ -36,5 +36,5 @@ void NaClThread::OnControlMessageReceived(const IPC::Message& msg) { void NaClThread::OnStartSelLdr(int channel_descriptor, nacl::FileDescriptor handle) { - SelMain(channel_descriptor, nacl::ToNativeHandle(handle)); + SelMain(channel_descriptor, NATIVE_HANDLE(handle)); } diff --git a/chrome/nacl/nacl_thread.h b/chrome/nacl/nacl_thread.h index 8893819..fd8fe76 100644 --- a/chrome/nacl/nacl_thread.h +++ b/chrome/nacl/nacl_thread.h @@ -10,6 +10,8 @@ #include "chrome/common/child_thread.h" #include "chrome/common/nacl_types.h" +class NotificationService; + // The NaClThread class represents a background thread where NaCl app gets // started. class NaClThread : public ChildThread { |