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