Index: base/process/process_linux.cc |
diff --git a/base/process/process_linux.cc b/base/process/process_linux.cc |
index 2c22d26484294024453b607b689309079b46999a..59ee288f880135bc66d77f47d88478dd2a2aa993 100644 |
--- a/base/process/process_linux.cc |
+++ b/base/process/process_linux.cc |
@@ -17,6 +17,7 @@ |
namespace base { |
namespace { |
+ |
const int kForegroundPriority = 0; |
#if defined(OS_CHROMEOS) |
@@ -62,10 +63,37 @@ base::LazyInstance<CGroups> cgroups = LAZY_INSTANCE_INITIALIZER; |
#else |
const int kBackgroundPriority = 5; |
#endif |
+ |
+struct CheckForNicePermission { |
+ CheckForNicePermission() : can_reraise_priority(false) { |
+ // We won't be able to raise the priority if we don't have the right rlimit. |
+ // The limit may be adjusted in /etc/security/limits.conf for PAM systems. |
+ struct rlimit rlim; |
+ if ((getrlimit(RLIMIT_NICE, &rlim) == 0) && |
+ (20 - kForegroundPriority) <= static_cast<int>(rlim.rlim_cur)) { |
+ can_reraise_priority = true; |
+ } |
+ }; |
+ |
+ bool can_reraise_priority; |
+}; |
+ |
+} // namespace |
+ |
+// static |
+bool Process::CanBackgroundProcesses() { |
+#if defined(OS_CHROMEOS) |
+ if (cgroups.Get().enabled) |
+ return true; |
+#endif |
+ |
+ static LazyInstance<CheckForNicePermission> check_for_nice_permission = |
+ LAZY_INSTANCE_INITIALIZER; |
+ return check_for_nice_permission.Get().can_reraise_priority; |
} |
bool Process::IsProcessBackgrounded() const { |
- DCHECK(process_); |
+ DCHECK(IsValid()); |
#if defined(OS_CHROMEOS) |
if (cgroups.Get().enabled) { |
@@ -87,7 +115,7 @@ bool Process::IsProcessBackgrounded() const { |
} |
bool Process::SetProcessBackgrounded(bool background) { |
- DCHECK(process_); |
+ DCHECK(IsValid()); |
#if defined(OS_CHROMEOS) |
if (cgroups.Get().enabled) { |
@@ -108,30 +136,4 @@ bool Process::SetProcessBackgrounded(bool background) { |
return result == 0; |
} |
-struct CheckForNicePermission { |
- CheckForNicePermission() : can_reraise_priority(false) { |
- // We won't be able to raise the priority if we don't have the right rlimit. |
- // The limit may be adjusted in /etc/security/limits.conf for PAM systems. |
- struct rlimit rlim; |
- if ((getrlimit(RLIMIT_NICE, &rlim) == 0) && |
- (20 - kForegroundPriority) <= static_cast<int>(rlim.rlim_cur)) { |
- can_reraise_priority = true; |
- } |
- }; |
- |
- bool can_reraise_priority; |
-}; |
- |
-// static |
-bool Process::CanBackgroundProcesses() { |
-#if defined(OS_CHROMEOS) |
- if (cgroups.Get().enabled) |
- return true; |
-#endif |
- |
- static LazyInstance<CheckForNicePermission> check_for_nice_permission = |
- LAZY_INSTANCE_INITIALIZER; |
- return check_for_nice_permission.Get().can_reraise_priority; |
-} |
- |
} // namespace base |