From 599e66405108cc22e3cfadeeb65ed59a7913d153 Mon Sep 17 00:00:00 2001 From: "dspringer@google.com" Date: Wed, 27 Jan 2010 18:52:13 +0000 Subject: Make NaCl run in Chrome on the Mac. Note: this is a *slight* rework of CL 555082, which accidentally broke the build. That CL was reviewed and LGTM'd byt sehr@ and bsy@. BUG=none TEST=none Review URL: http://codereview.chromium.org/551172 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37279 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/nacl/nacl_main.cc | 53 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 14 deletions(-) (limited to 'chrome/nacl') diff --git a/chrome/nacl/nacl_main.cc b/chrome/nacl/nacl_main.cc index 5271cf4..72bc8a2 100644 --- a/chrome/nacl/nacl_main.cc +++ b/chrome/nacl/nacl_main.cc @@ -22,8 +22,42 @@ #include "chrome/common/main_function_params.h" #include "chrome/nacl/nacl_thread.h" +// This function provides some ways to test crash and assertion handling +// behavior of the renderer. +static void HandleNaClTestParameters(const CommandLine& command_line) { + if (command_line.HasSwitch(switches::kNaClStartupDialog)) { + ChildProcess::WaitForDebugger(L"NativeClient"); + } +} + +// Launch the NaCl child process in its own thread. +#if defined (OS_WIN) +static void LaunchNaClChildProcess(bool no_sandbox, + sandbox::TargetServices* target_services) { + ChildProcess nacl_process; + nacl_process.set_main_thread(new NaClThread()); + if (!no_sandbox && target_services) + target_services->LowerToken(); + MessageLoop::current()->Run(); +} +#elif defined(OS_MACOSX) +static void LaunchNaClChildProcess() { + ChildProcess nacl_process; + nacl_process.set_main_thread(new NaClThread()); + MessageLoop::current()->Run(); +} +#endif + // main() routine for running as the sel_ldr process. int NaClMain(const MainFunctionParams& parameters) { + const CommandLine& parsed_command_line = parameters.command_line_; + + // This function allows pausing execution using the --nacl-startup-dialog + // flag allowing us to attach a debugger. + // Do not move this function down since that would mean we can't easily debug + // whatever occurs before it. + HandleNaClTestParameters(parsed_command_line); + // The main thread of the plugin services IO. MessageLoopForIO main_message_loop; std::wstring app_name = chrome::kBrowserAppName; @@ -33,8 +67,6 @@ int NaClMain(const MainFunctionParams& parameters) { HighResolutionTimerManager hi_res_timer_manager; #if defined(OS_WIN) - const CommandLine& parsed_command_line = parameters.command_line_; - sandbox::TargetServices* target_services = parameters.sandbox_info_.TargetServices(); @@ -52,22 +84,15 @@ int NaClMain(const MainFunctionParams& parameters) { DCHECK(sandbox_test_module); } } + LaunchNaClChildProcess(no_sandbox, target_services); -#else - NOTIMPLEMENTED() << " non-windows startup, plugin startup dialog etc."; -#endif +#elif defined(OS_MACOSX) + LaunchNaClChildProcess(); - { - ChildProcess nacl_process; - nacl_process.set_main_thread(new NaClThread()); -#if defined(OS_WIN) - if (!no_sandbox && target_services) - target_services->LowerToken(); +#else + NOTIMPLEMENTED() << " not implemented startup, plugin startup dialog etc."; #endif - MessageLoop::current()->Run(); - } - return 0; } -- cgit v1.1