OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #include "base/process/process.h" | 5 #include "base/process/process.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sys/resource.h> | 8 #include <sys/resource.h> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 bool Process::SetProcessBackgrounded(bool background) { | 89 bool Process::SetProcessBackgrounded(bool background) { |
90 DCHECK(process_); | 90 DCHECK(process_); |
91 | 91 |
92 #if defined(OS_CHROMEOS) | 92 #if defined(OS_CHROMEOS) |
93 if (cgroups.Get().enabled) { | 93 if (cgroups.Get().enabled) { |
94 std::string pid = StringPrintf("%d", process_); | 94 std::string pid = StringPrintf("%d", process_); |
95 const base::FilePath file = | 95 const base::FilePath file = |
96 background ? | 96 background ? |
97 cgroups.Get().background_file : cgroups.Get().foreground_file; | 97 cgroups.Get().background_file : cgroups.Get().foreground_file; |
98 return file_util::WriteFile(file, pid.c_str(), pid.size()) > 0; | 98 return base::WriteFile(file, pid.c_str(), pid.size()) > 0; |
99 } | 99 } |
100 #endif // OS_CHROMEOS | 100 #endif // OS_CHROMEOS |
101 | 101 |
102 if (!CanBackgroundProcesses()) | 102 if (!CanBackgroundProcesses()) |
103 return false; | 103 return false; |
104 | 104 |
105 int priority = background ? kBackgroundPriority : kForegroundPriority; | 105 int priority = background ? kBackgroundPriority : kForegroundPriority; |
106 int result = setpriority(PRIO_PROCESS, process_, priority); | 106 int result = setpriority(PRIO_PROCESS, process_, priority); |
107 DPCHECK(result == 0); | 107 DPCHECK(result == 0); |
108 return result == 0; | 108 return result == 0; |
(...skipping 19 matching lines...) Expand all Loading... |
128 if (cgroups.Get().enabled) | 128 if (cgroups.Get().enabled) |
129 return true; | 129 return true; |
130 #endif | 130 #endif |
131 | 131 |
132 static LazyInstance<CheckForNicePermission> check_for_nice_permission = | 132 static LazyInstance<CheckForNicePermission> check_for_nice_permission = |
133 LAZY_INSTANCE_INITIALIZER; | 133 LAZY_INSTANCE_INITIALIZER; |
134 return check_for_nice_permission.Get().can_reraise_priority; | 134 return check_for_nice_permission.Get().can_reraise_priority; |
135 } | 135 } |
136 | 136 |
137 } // namespace base | 137 } // namespace base |
OLD | NEW |