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