summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexis.menard@intel.com <alexis.menard@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-14 01:45:50 +0000
committeralexis.menard@intel.com <alexis.menard@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-14 01:45:50 +0000
commit6b492fd04f29d5c41161119fac828c338304ac35 (patch)
tree3b1caed1bacbba2807e3a27a21ff5f6607b64fe0
parentf40dcd1ceab1a3dccd47b414128998a48a538173 (diff)
downloadchromium_src-6b492fd04f29d5c41161119fac828c338304ac35.zip
chromium_src-6b492fd04f29d5c41161119fac828c338304ac35.tar.gz
chromium_src-6b492fd04f29d5c41161119fac828c338304ac35.tar.bz2
Split chrome/nacl/nacl_exe_win_64.cc
Move most of the content to the components/nacl folder and make sure it doesn't include anything from chrome. Setting the breakpad client is kept in chrome. This is part of an effort to componentize NaCl code. BUG=244791 Review URL: https://codereview.chromium.org/59263006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235013 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/nacl/nacl_exe_win_64.cc73
-rw-r--r--components/nacl.gyp2
-rw-r--r--components/nacl/loader/nacl_helper_win_64.cc83
-rw-r--r--components/nacl/loader/nacl_helper_win_64.h14
4 files changed, 101 insertions, 71 deletions
diff --git a/chrome/nacl/nacl_exe_win_64.cc b/chrome/nacl/nacl_exe_win_64.cc
index f6bd902..0b534b4 100644
--- a/chrome/nacl/nacl_exe_win_64.cc
+++ b/chrome/nacl/nacl_exe_win_64.cc
@@ -5,30 +5,9 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
-#include "base/power_monitor/power_monitor.h"
-#include "base/power_monitor/power_monitor_device_source.h"
-#include "base/process/launch.h"
-#include "base/process/memory.h"
-#include "base/strings/string_util.h"
-#include "base/timer/hi_res_timer_manager.h"
#include "chrome/app/chrome_breakpad_client.h"
-#include "chrome/common/chrome_result_codes.h"
-#include "chrome/common/logging_chrome.h"
-#include "components/breakpad/app/breakpad_client.h"
#include "components/breakpad/app/breakpad_win.h"
-#include "components/nacl/broker/nacl_broker_listener.h"
-#include "components/nacl/common/nacl_switches.h"
-#include "components/nacl/loader/nacl_listener.h"
-#include "components/nacl/loader/nacl_main_platform_delegate.h"
-#include "content/public/app/startup_helper_win.h"
-#include "content/public/common/content_switches.h"
-#include "content/public/common/main_function_params.h"
-#include "content/public/common/sandbox_init.h"
-#include "sandbox/win/src/sandbox_types.h"
-
-extern int NaClMain(const content::MainFunctionParams&);
+#include "components/nacl/loader/nacl_helper_win_64.h"
namespace {
@@ -37,60 +16,12 @@ base::LazyInstance<chrome::ChromeBreakpadClient>::Leaky
} // namespace
-// main() routine for the NaCl broker process.
-// This is necessary for supporting NaCl in Chrome on Win64.
-int NaClBrokerMain(const content::MainFunctionParams& parameters) {
- base::MessageLoopForIO main_message_loop;
- base::PlatformThread::SetName("CrNaClBrokerMain");
-
- scoped_ptr<base::PowerMonitorSource> power_monitor_source(
- new base::PowerMonitorDeviceSource());
- base::PowerMonitor power_monitor(power_monitor_source.Pass());
- base::HighResolutionTimerManager hi_res_timer_manager;
-
- NaClBrokerListener listener;
- listener.Listen();
-
- return 0;
-}
-
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
- sandbox::SandboxInterfaceInfo sandbox_info = {0};
- content::InitializeSandboxInfo(&sandbox_info);
-
base::AtExitManager exit_manager;
CommandLine::Init(0, NULL);
breakpad::SetBreakpadClient(g_chrome_breakpad_client.Pointer());
breakpad::InitCrashReporter();
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- std::string process_type =
- command_line.GetSwitchValueASCII(switches::kProcessType);
-
- // Copy what ContentMain() does.
- base::EnableTerminationOnHeapCorruption();
- base::EnableTerminationOnOutOfMemory();
- content::RegisterInvalidParamHandler();
- content::SetupCRT(command_line);
- // Route stdio to parent console (if any) or create one.
- if (command_line.HasSwitch(switches::kEnableLogging))
- base::RouteStdioToConsole();
-
- // Initialize the sandbox for this process.
- bool sandbox_initialized_ok = content::InitializeSandbox(&sandbox_info);
- // Die if the sandbox can't be enabled.
- CHECK(sandbox_initialized_ok) << "Error initializing sandbox for "
- << process_type;
- content::MainFunctionParams main_params(command_line);
- main_params.sandbox_info = &sandbox_info;
-
- if (process_type == switches::kNaClLoaderProcess)
- return NaClMain(main_params);
-
- if (process_type == switches::kNaClBrokerProcess)
- return NaClBrokerMain(main_params);
-
- CHECK(false) << "Unknown NaCl 64 process.";
- return -1;
+ return nacl::NaClWin64Main();
}
diff --git a/components/nacl.gyp b/components/nacl.gyp
index f841b7b..5ec4fce 100644
--- a/components/nacl.gyp
+++ b/components/nacl.gyp
@@ -193,6 +193,8 @@
'../components/nacl/broker/nacl_broker_listener.cc',
'../components/nacl/broker/nacl_broker_listener.h',
'../components/nacl/common/nacl_debug_exception_handler_win.cc',
+ '../components/nacl/loader/nacl_helper_win_64.cc',
+ '../components/nacl/loader/nacl_helper_win_64.h',
],
'include_dirs': [
'..',
diff --git a/components/nacl/loader/nacl_helper_win_64.cc b/components/nacl/loader/nacl_helper_win_64.cc
new file mode 100644
index 0000000..fbb5265
--- /dev/null
+++ b/components/nacl/loader/nacl_helper_win_64.cc
@@ -0,0 +1,83 @@
+// Copyright 2013 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 "base/command_line.h"
+#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
+#include "base/power_monitor/power_monitor.h"
+#include "base/power_monitor/power_monitor_device_source.h"
+#include "base/process/launch.h"
+#include "base/process/memory.h"
+#include "base/strings/string_util.h"
+#include "base/timer/hi_res_timer_manager.h"
+#include "components/nacl/broker/nacl_broker_listener.h"
+#include "components/nacl/common/nacl_switches.h"
+#include "components/nacl/loader/nacl_listener.h"
+#include "components/nacl/loader/nacl_main_platform_delegate.h"
+#include "content/public/app/startup_helper_win.h"
+#include "content/public/common/content_switches.h"
+#include "content/public/common/main_function_params.h"
+#include "content/public/common/sandbox_init.h"
+#include "sandbox/win/src/sandbox_types.h"
+
+extern int NaClMain(const content::MainFunctionParams&);
+
+namespace {
+// main() routine for the NaCl broker process.
+// This is necessary for supporting NaCl in Chrome on Win64.
+int NaClBrokerMain(const content::MainFunctionParams& parameters) {
+ base::MessageLoopForIO main_message_loop;
+ base::PlatformThread::SetName("CrNaClBrokerMain");
+
+ scoped_ptr<base::PowerMonitorSource> power_monitor_source(
+ new base::PowerMonitorDeviceSource());
+ base::PowerMonitor power_monitor(power_monitor_source.Pass());
+ base::HighResolutionTimerManager hi_res_timer_manager;
+
+ NaClBrokerListener listener;
+ listener.Listen();
+
+ return 0;
+}
+
+} // namespace
+
+namespace nacl {
+
+int NaClWin64Main() {
+ sandbox::SandboxInterfaceInfo sandbox_info = {0};
+ content::InitializeSandboxInfo(&sandbox_info);
+
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ std::string process_type =
+ command_line.GetSwitchValueASCII(switches::kProcessType);
+
+ // Copy what ContentMain() does.
+ base::EnableTerminationOnHeapCorruption();
+ base::EnableTerminationOnOutOfMemory();
+ content::RegisterInvalidParamHandler();
+ content::SetupCRT(command_line);
+ // Route stdio to parent console (if any) or create one.
+ if (command_line.HasSwitch(switches::kEnableLogging))
+ base::RouteStdioToConsole();
+
+ // Initialize the sandbox for this process.
+ bool sandbox_initialized_ok = content::InitializeSandbox(&sandbox_info);
+ // Die if the sandbox can't be enabled.
+ CHECK(sandbox_initialized_ok) << "Error initializing sandbox for "
+ << process_type;
+ content::MainFunctionParams main_params(command_line);
+ main_params.sandbox_info = &sandbox_info;
+
+ if (process_type == switches::kNaClLoaderProcess)
+ return NaClMain(main_params);
+
+ if (process_type == switches::kNaClBrokerProcess)
+ return NaClBrokerMain(main_params);
+
+ CHECK(false) << "Unknown NaCl 64 process.";
+ return -1;
+}
+
+} // namespace nacl
diff --git a/components/nacl/loader/nacl_helper_win_64.h b/components/nacl/loader/nacl_helper_win_64.h
new file mode 100644
index 0000000..2f4f4a4
--- /dev/null
+++ b/components/nacl/loader/nacl_helper_win_64.h
@@ -0,0 +1,14 @@
+// Copyright 2013 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 COMPONENTS_NACL_LOADER_NACL_HELPER_WIN_64_H_
+#define COMPONENTS_NACL_LOADER_NACL_HELPER_WIN_64_H_
+
+namespace nacl {
+
+int NaClWin64Main();
+
+} // namespace nacl
+
+#endif // COMPONENTS_NACL_LOADER_NACL_HELPER_WIN_64_H_