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

Side by Side Diff: content/public/common/sandboxed_process_launcher_delegate.h

Issue 1532423003: Have each SandboxedProcessLauncherDelegate maintain a zygote. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Load and initialize all zygotes on browser startup. Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_ 5 #ifndef CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_
6 #define CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_ 6 #define CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_
7 7
8 #include <cstddef>
9
8 #include "base/environment.h" 10 #include "base/environment.h"
9 #include "base/files/scoped_file.h" 11 #include "base/files/scoped_file.h"
10 #include "base/process/process.h" 12 #include "base/process/process.h"
11 #include "build/build_config.h" 13 #include "build/build_config.h"
12 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
13 #include "content/public/common/sandbox_type.h" 15 #include "content/public/common/sandbox_type.h"
14 16
15 namespace base { 17 namespace base {
16 class FilePath; 18 class FilePath;
17 } 19 }
18 20
19 namespace sandbox { 21 namespace sandbox {
20 class TargetPolicy; 22 class TargetPolicy;
21 } 23 }
22 24
23 namespace content { 25 namespace content {
24 26
27 #if defined(OS_LINUX)
28 class ZygoteCommunication;
29 using ZygoteHandle = ZygoteCommunication*;
30 #else
31 using ZygoteHandle = std::nullptr_t;
32 #endif
33
25 // Allows a caller of StartSandboxedProcess or 34 // Allows a caller of StartSandboxedProcess or
26 // BrowserChildProcessHost/ChildProcessLauncher to control the sandbox policy, 35 // BrowserChildProcessHost/ChildProcessLauncher to control the sandbox policy,
27 // i.e. to loosen it if needed. 36 // i.e. to loosen it if needed.
28 // The methods below will be called on the PROCESS_LAUNCHER thread. 37 // The methods below will be called on the PROCESS_LAUNCHER thread.
29 class CONTENT_EXPORT SandboxedProcessLauncherDelegate { 38 class CONTENT_EXPORT SandboxedProcessLauncherDelegate {
30 public: 39 public:
31 virtual ~SandboxedProcessLauncherDelegate() {} 40 virtual ~SandboxedProcessLauncherDelegate() {}
32 41
33 #if defined(OS_WIN) 42 #if defined(OS_WIN)
34 // Override to return true if the process should be launched as an elevated 43 // Override to return true if the process should be launched as an elevated
35 // process (which implies no sandbox). 44 // process (which implies no sandbox).
36 virtual bool ShouldLaunchElevated(); 45 virtual bool ShouldLaunchElevated();
37 46
38 // By default, the process is launched sandboxed. Override this method to 47 // By default, the process is launched sandboxed. Override this method to
39 // return false if the process should be launched without a sandbox 48 // return false if the process should be launched without a sandbox
40 // (i.e. through base::LaunchProcess directly). 49 // (i.e. through base::LaunchProcess directly).
41 virtual bool ShouldSandbox(); 50 virtual bool ShouldSandbox();
42 51
43 // Whether to disable the default policy specified in 52 // Whether to disable the default policy specified in
44 // AddPolicyForSandboxedProcess. 53 // AddPolicyForSandboxedProcess.
45 virtual bool DisableDefaultPolicy(); 54 virtual bool DisableDefaultPolicy();
46 55
47 // Called right before spawning the process. Returns false on failure. 56 // Called right before spawning the process. Returns false on failure.
48 virtual bool PreSpawnTarget(sandbox::TargetPolicy* policy); 57 virtual bool PreSpawnTarget(sandbox::TargetPolicy* policy);
49 58
50 // Called right after the process is launched, but before its thread is run. 59 // Called right after the process is launched, but before its thread is run.
51 virtual void PostSpawnTarget(base::ProcessHandle process) {} 60 virtual void PostSpawnTarget(base::ProcessHandle process) {}
52 61
53 #elif defined(OS_POSIX) 62 #elif defined(OS_POSIX)
63 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
54 // Override this to return true to use the setuid sandbox. 64 // Override this to return true to use the setuid sandbox.
55 virtual bool ShouldUseZygote(); 65 virtual ZygoteHandle* GetZygote();
66 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID)
56 67
57 // Override this if the process needs a non-empty environment map. 68 // Override this if the process needs a non-empty environment map.
58 virtual base::EnvironmentMap GetEnvironment(); 69 virtual base::EnvironmentMap GetEnvironment();
59 70
60 // Return the file descriptor for the IPC channel. 71 // Return the file descriptor for the IPC channel.
61 virtual base::ScopedFD TakeIpcFd() = 0; 72 virtual base::ScopedFD TakeIpcFd() = 0;
62 #endif 73 #endif
63 74
64 // Returns the SandboxType to enforce on the process, or SANDBOX_TYPE_INVALID 75 // Returns the SandboxType to enforce on the process, or SANDBOX_TYPE_INVALID
65 // for no sandbox policy. 76 // for no sandbox policy.
66 virtual SandboxType GetSandboxType(); 77 virtual SandboxType GetSandboxType();
67 }; 78 };
68 79
69 } // namespace content 80 } // namespace content
70 81
71 #endif // CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_ 82 #endif // CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698