| 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.h" | 5 #include "base/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 24 matching lines...) Expand all Loading... |
| 35 // Check for cgroups files. ChromeOS supports these by default. It creates | 35 // Check for cgroups files. ChromeOS supports these by default. It creates |
| 36 // a cgroup mount in /sys/fs/cgroup and then configures two cpu task groups, | 36 // a cgroup mount in /sys/fs/cgroup and then configures two cpu task groups, |
| 37 // one contains at most a single foreground renderer and the other contains | 37 // one contains at most a single foreground renderer and the other contains |
| 38 // all background renderers. This allows us to limit the impact of background | 38 // all background renderers. This allows us to limit the impact of background |
| 39 // renderers on foreground ones to a greater level than simple renicing. | 39 // renderers on foreground ones to a greater level than simple renicing. |
| 40 bool enabled; | 40 bool enabled; |
| 41 base::FilePath foreground_file; | 41 base::FilePath foreground_file; |
| 42 base::FilePath background_file; | 42 base::FilePath background_file; |
| 43 | 43 |
| 44 CGroups() { | 44 CGroups() { |
| 45 foreground_file = base::FilePath(StringPrintf(kControlPath, kForeground)); | 45 foreground_file = |
| 46 background_file = base::FilePath(StringPrintf(kControlPath, kBackground)); | 46 base::FilePath(base::StringPrintf(kControlPath, kForeground)); |
| 47 background_file = |
| 48 base::FilePath(base::StringPrintf(kControlPath, kBackground)); |
| 47 file_util::FileSystemType foreground_type; | 49 file_util::FileSystemType foreground_type; |
| 48 file_util::FileSystemType background_type; | 50 file_util::FileSystemType background_type; |
| 49 enabled = | 51 enabled = |
| 50 file_util::GetFileSystemType(foreground_file, &foreground_type) && | 52 file_util::GetFileSystemType(foreground_file, &foreground_type) && |
| 51 file_util::GetFileSystemType(background_file, &background_type) && | 53 file_util::GetFileSystemType(background_file, &background_type) && |
| 52 foreground_type == file_util::FILE_SYSTEM_CGROUP && | 54 foreground_type == file_util::FILE_SYSTEM_CGROUP && |
| 53 background_type == file_util::FILE_SYSTEM_CGROUP; | 55 background_type == file_util::FILE_SYSTEM_CGROUP; |
| 54 } | 56 } |
| 55 }; | 57 }; |
| 56 | 58 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 if (cgroups.Get().enabled) | 128 if (cgroups.Get().enabled) |
| 127 return true; | 129 return true; |
| 128 #endif | 130 #endif |
| 129 | 131 |
| 130 static LazyInstance<CheckForNicePermission> check_for_nice_permission = | 132 static LazyInstance<CheckForNicePermission> check_for_nice_permission = |
| 131 LAZY_INSTANCE_INITIALIZER; | 133 LAZY_INSTANCE_INITIALIZER; |
| 132 return check_for_nice_permission.Get().can_reraise_priority; | 134 return check_for_nice_permission.Get().can_reraise_priority; |
| 133 } | 135 } |
| 134 | 136 |
| 135 } // namespace base | 137 } // namespace base |
| OLD | NEW |