OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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. | |
4 | |
5 #include "chrome/service/service_child_process_host.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/logging.h" | |
9 #include "base/process_util.h" | |
10 #include "chrome/common/chrome_switches.h" | |
11 #include "content/public/common/result_codes.h" | |
12 | |
13 #if defined(OS_WIN) | |
14 #include "base/file_path.h" | |
15 #include "content/common/sandbox_policy.h" | |
16 #endif // defined(OS_WIN) | |
17 | |
18 ServiceChildProcessHost::ServiceChildProcessHost() | |
19 : handle_(base::kNullProcessHandle) { | |
20 } | |
21 | |
22 ServiceChildProcessHost::~ServiceChildProcessHost() { | |
23 // We need to kill the child process when the host dies. | |
24 base::KillProcess(handle_, content::RESULT_CODE_NORMAL_EXIT, false); | |
25 } | |
26 | |
27 bool ServiceChildProcessHost::Launch(CommandLine* cmd_line, | |
28 bool no_sandbox, | |
29 const FilePath& exposed_dir) { | |
30 #if !defined(OS_WIN) | |
31 // TODO(sanjeevr): Implement for non-Windows OSes. | |
32 NOTIMPLEMENTED(); | |
33 return false; | |
34 #else // !defined(OS_WIN) | |
35 | |
36 if (no_sandbox) { | |
37 base::ProcessHandle process = base::kNullProcessHandle; | |
38 cmd_line->AppendSwitch(switches::kNoSandbox); | |
39 base::LaunchProcess(*cmd_line, base::LaunchOptions(), &handle_); | |
40 } else { | |
41 handle_ = sandbox::StartProcessWithAccess(cmd_line, exposed_dir); | |
42 } | |
43 return (handle_ != base::kNullProcessHandle); | |
44 #endif // !defined(OS_WIN) | |
45 } | |
OLD | NEW |