Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1471)

Unified Diff: chrome/nacl/nacl_main_win_64.cc

Issue 7863024: Make the NaCl windows 64 bit binaries not depend on chrome targets. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove nacl_win64 and dummy hacks Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/nacl/nacl_main_win_64.cc
===================================================================
--- chrome/nacl/nacl_main_win_64.cc (revision 0)
+++ chrome/nacl/nacl_main_win_64.cc (revision 0)
@@ -0,0 +1,130 @@
+// 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.
Brad Chen (chromium) 2011/09/11 17:35:37 Someplace, perhaps here, it would be nice to have
jam 2011/09/11 22:51:37 that sounds like a good idea. Is there no other do
+
+#include "base/at_exit.h"
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "base/message_loop.h"
+#include "base/process_util.h"
+#include "base/string_util.h"
+#include "base/system_monitor/system_monitor.h"
+#include "chrome/common/chrome_result_codes.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/logging_chrome.h"
+#include "chrome/nacl/nacl_broker_listener.h"
+#include "chrome/nacl/nacl_listener.h"
+#include "chrome/nacl/nacl_main_platform_delegate.h"
+#include "content/app/startup_helper_win.h"
+#include "content/common/hi_res_timer_manager.h"
+#include "content/common/main_function_params.h"
+#include "content/common/sandbox_init_wrapper.h"
+#include "content/common/sandbox_policy.h"
+#include "sandbox/src/sandbox.h"
+
+// main() routine for the NaCl broker process.
+// This is necessary for supporting NaCl in Chrome on Win64.
+int NaClBrokerMain(const MainFunctionParams& parameters) {
+ const CommandLine& parsed_command_line = parameters.command_line_;
+
+ // 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) {
+ sandbox::InitBrokerServices(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();
+ }
+ }
+
+ NaClBrokerListener listener;
+ listener.Listen();
+
+ return 0;
+}
+
+// main() routine for the NaCl loader process.
+int NaClMain(const MainFunctionParams& parameters) {
+ const CommandLine& parsed_command_line = parameters.command_line_;
+
+ NaClMainPlatformDelegate platform(parameters);
+
+ platform.PlatformInitialize();
+ bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox);
+ platform.InitSandboxTests(no_sandbox);
+ if (!no_sandbox)
+ platform.EnableSandbox();
+
+ bool sandbox_test_result = platform.RunSandboxTests();
+ if (sandbox_test_result) {
+ bool debug = parsed_command_line.HasSwitch(switches::kEnableNaClDebug);
Brad Chen (chromium) 2011/09/11 17:35:37 If you are unclear about how this debug support wo
+ NaClListener listener;
+ listener.set_debug_enabled(debug);
+ listener.Listen();
+ } else {
+ // This indirectly prevents the test-harness-success-cookie from being set,
+ // as a way of communicating test failure, because the nexe won't reply.
+ // TODO(jvoung): find a better way to indicate failure that doesn't
+ // require waiting for a timeout.
+ VLOG(1) << "Sandbox test failed: Not launching NaCl process";
+ }
+
+ platform.PlatformUninitialize();
+ return 0;
+}
+
+// We use extern C for the prototype DLLEXPORT to avoid C++ name mangling.
+extern "C" {
+
+__declspec(dllexport) int __cdecl ChromeMain(
Brad Chen (chromium) 2011/09/11 17:35:37 Can you add some sort of comment that explains why
jam 2011/09/11 22:51:37 The code in MainDllLoader (called from nacl_exe_wi
+ HINSTANCE instance, sandbox::SandboxInterfaceInfo* sandbox_info) {
+ base::AtExitManager exit_manager;
+ CommandLine::Init(0, NULL);
+
+ 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);
+
+ // Initialize the sandbox for this process.
+ SandboxInitWrapper sandbox_wrapper;
+ sandbox_wrapper.SetServices(sandbox_info);
+ bool sandbox_initialized_ok =
+ sandbox_wrapper.InitializeSandbox(command_line, process_type);
+ // Die if the sandbox can't be enabled.
+ CHECK(sandbox_initialized_ok) << "Error initializing sandbox for "
+ << process_type;
+ MainFunctionParams main_params(command_line, sandbox_wrapper, NULL);
+
+ MessageLoopForIO main_message_loop;
+ base::PlatformThread::SetName("CrNaCl64Main");
+
+ base::SystemMonitor system_monitor;
+ HighResolutionTimerManager hi_res_timer_manager;
+
+ 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;
+}
+
+} // extern "C"
Property changes on: chrome\nacl\nacl_main_win_64.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698