1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "build/build_config.h"
7 #include "base/command_line.h"
8 #include "base/hi_res_timer_manager.h"
9 #include "base/message_loop.h"
10 #include "base/system_monitor/system_monitor.h"
11 #include "chrome/common/chrome_result_codes.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/logging_chrome.h"
14 #include "chrome/nacl/nacl_listener.h"
15 #include "chrome/nacl/nacl_main_platform_delegate.h"
16 #include "content/public/common/main_function_params.h"
18 // main() routine for the NaCl loader process.
19 int NaClMain(const content::MainFunctionParams
& parameters
) {
20 const CommandLine
& parsed_command_line
= parameters
.command_line
;
22 // The main thread of the plugin services IO.
23 MessageLoopForIO main_message_loop
;
24 base::PlatformThread::SetName("CrNaClMain");
26 base::SystemMonitor system_monitor
;
27 HighResolutionTimerManager hi_res_timer_manager
;
29 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
30 NaClMainPlatformDelegate
platform(parameters
);
32 platform
.PlatformInitialize();
33 bool no_sandbox
= parsed_command_line
.HasSwitch(switches::kNoSandbox
);
34 platform
.InitSandboxTests(no_sandbox
);
37 platform
.EnableSandbox();
39 bool sandbox_test_result
= platform
.RunSandboxTests();
41 if (sandbox_test_result
) {
42 NaClListener listener
;
45 // This indirectly prevents the test-harness-success-cookie from being set,
46 // as a way of communicating test failure, because the nexe won't reply.
47 // TODO(jvoung): find a better way to indicate failure that doesn't
48 // require waiting for a timeout.
49 VLOG(1) << "Sandbox test failed: Not launching NaCl process";
52 NOTIMPLEMENTED() << " not implemented startup, plugin startup dialog etc.";
55 platform
.PlatformUninitialize();