OLD | NEW |
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_BROWSER_ZYGOTE_HOST_LINUX_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_LINUX_H_ |
6 #define CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_LINUX_H_ | 6 #define CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_LINUX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
11 #include "base/process.h" | 11 #include "base/process.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 // http://code.google.com/p/chromium/wiki/LinuxZygote | 16 // http://code.google.com/p/chromium/wiki/LinuxZygote |
17 | 17 |
18 // The zygote host is the interface, in the browser process, to the zygote | 18 // The zygote host is the interface, in the browser process, to the zygote |
19 // process. | 19 // process. |
20 class ZygoteHost { | 20 class ZygoteHost { |
21 public: | 21 public: |
22 // Returns the singleton instance. | 22 // Returns the singleton instance. |
23 CONTENT_EXPORT static ZygoteHost* GetInstance(); | 23 CONTENT_EXPORT static ZygoteHost* GetInstance(); |
24 | 24 |
25 // These form a bitmask which describes the conditions of the sandbox that | |
26 // the zygote finds itself in. | |
27 enum { | |
28 kSandboxSUID = 1 << 0, // SUID sandbox active | |
29 kSandboxPIDNS = 1 << 1, // SUID sandbox is using the PID namespace | |
30 kSandboxNetNS = 1 << 2, // SUID sandbox is using the network namespace | |
31 kSandboxSeccomp = 1 << 3, // seccomp sandbox active. | |
32 }; | |
33 | |
34 // Returns the pid of the Zygote process. | 25 // Returns the pid of the Zygote process. |
35 virtual pid_t GetPid() const = 0; | 26 virtual pid_t GetPid() const = 0; |
36 | 27 |
37 // Returns the pid of the Sandbox Helper process. | 28 // Returns the pid of the Sandbox Helper process. |
38 virtual pid_t GetSandboxHelperPid() const = 0; | 29 virtual pid_t GetSandboxHelperPid() const = 0; |
39 | 30 |
40 // Returns an int which is a bitmask of kSandbox* values. Only valid after | 31 // Returns an int which is a bitmask of kSandboxLinux* values. Only valid |
41 // the first render has been forked. | 32 // after the first render has been forked. |
42 virtual int GetSandboxStatus() const = 0; | 33 virtual int GetSandboxStatus() const = 0; |
43 | 34 |
44 // Adjust the OOM score of the given renderer's PID. The allowed | 35 // Adjust the OOM score of the given renderer's PID. The allowed |
45 // range for the score is [0, 1000], where higher values are more | 36 // range for the score is [0, 1000], where higher values are more |
46 // likely to be killed by the OOM killer. | 37 // likely to be killed by the OOM killer. |
47 virtual void AdjustRendererOOMScore(base::ProcessHandle process_handle, | 38 virtual void AdjustRendererOOMScore(base::ProcessHandle process_handle, |
48 int score) = 0; | 39 int score) = 0; |
49 | 40 |
50 // Adjust the point at which the low memory notifier in the kernel tells | 41 // Adjust the point at which the low memory notifier in the kernel tells |
51 // us that we're low on memory. When there is less than |margin_mb| left, | 42 // us that we're low on memory. When there is less than |margin_mb| left, |
52 // then the notifier will notify us. Set |margin_mb| to -1 to turn off | 43 // then the notifier will notify us. Set |margin_mb| to -1 to turn off |
53 // low memory notification altogether. | 44 // low memory notification altogether. |
54 virtual void AdjustLowMemoryMargin(int64 margin_mb) = 0; | 45 virtual void AdjustLowMemoryMargin(int64 margin_mb) = 0; |
55 }; | 46 }; |
56 | 47 |
57 } // namespace content | 48 } // namespace content |
58 | 49 |
59 #endif // CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_LINUX_H_ | 50 #endif // CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_LINUX_H_ |
OLD | NEW |