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/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 DCHECK(IsValid()); | 96 DCHECK(IsValid()); |
97 | 97 |
98 #if defined(OS_CHROMEOS) | 98 #if defined(OS_CHROMEOS) |
99 if (cgroups.Get().enabled) { | 99 if (cgroups.Get().enabled) { |
100 std::string proc; | 100 std::string proc; |
101 if (base::ReadFileToString( | 101 if (base::ReadFileToString( |
102 base::FilePath(StringPrintf(kProcPath, process_)), | 102 base::FilePath(StringPrintf(kProcPath, process_)), |
103 &proc)) { | 103 &proc)) { |
104 std::vector<std::string> proc_parts; | 104 std::vector<std::string> proc_parts; |
105 base::SplitString(proc, ':', &proc_parts); | 105 base::SplitString(proc, ':', &proc_parts); |
106 DCHECK(proc_parts.size() == 3); | 106 DCHECK_EQ(proc_parts.size(), 3u); |
107 bool ret = proc_parts[2] == std::string(kBackground); | 107 bool ret = proc_parts[2] == std::string(kBackground); |
108 return ret; | 108 return ret; |
109 } else { | 109 } else { |
110 return false; | 110 return false; |
111 } | 111 } |
112 } | 112 } |
113 #endif | 113 #endif |
114 return GetPriority() == kBackgroundPriority; | 114 return GetPriority() == kBackgroundPriority; |
115 } | 115 } |
116 | 116 |
(...skipping 13 matching lines...) Expand all Loading... |
130 if (!CanBackgroundProcesses()) | 130 if (!CanBackgroundProcesses()) |
131 return false; | 131 return false; |
132 | 132 |
133 int priority = background ? kBackgroundPriority : kForegroundPriority; | 133 int priority = background ? kBackgroundPriority : kForegroundPriority; |
134 int result = setpriority(PRIO_PROCESS, process_, priority); | 134 int result = setpriority(PRIO_PROCESS, process_, priority); |
135 DPCHECK(result == 0); | 135 DPCHECK(result == 0); |
136 return result == 0; | 136 return result == 0; |
137 } | 137 } |
138 | 138 |
139 } // namespace base | 139 } // namespace base |
OLD | NEW |