OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
7 | 7 |
8 #include <errno.h> | 8 #include <errno.h> |
| 9 |
9 #include <algorithm> | 10 #include <algorithm> |
10 #include <set> | 11 #include <set> |
11 #include <string> | 12 #include <string> |
12 #include <vector> | 13 #include <vector> |
| 14 |
13 #include <glib.h> | 15 #include <glib.h> |
| 16 |
14 #include "update_engine/action.h" | 17 #include "update_engine/action.h" |
15 #include "update_engine/action_processor.h" | 18 #include "update_engine/action_processor.h" |
16 | 19 |
17 namespace chromeos_update_engine { | 20 namespace chromeos_update_engine { |
18 | 21 |
19 namespace utils { | 22 namespace utils { |
20 | 23 |
21 // Returns true if this is an official Chrome OS build, false | 24 // Returns true if this is an official Chrome OS build, false |
22 // otherwise. Currently, this routine errs on the official build side | 25 // otherwise. Currently, this routine errs on the official build side |
23 // -- if it doesn't recognize the update track as non-official, it | 26 // -- if it doesn't recognize the update track as non-official, it |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // or something with equivalent funcionality to interpret those. | 179 // or something with equivalent funcionality to interpret those. |
177 const std::string BootDevice(); | 180 const std::string BootDevice(); |
178 | 181 |
179 // Returns the currently booted kernel device, "dev/sda2", for example. | 182 // Returns the currently booted kernel device, "dev/sda2", for example. |
180 // Client must pass in the boot device. The suggested calling convention | 183 // Client must pass in the boot device. The suggested calling convention |
181 // is: BootKernelDevice(BootDevice()). | 184 // is: BootKernelDevice(BootDevice()). |
182 // This function works by doing string modification on boot_device. | 185 // This function works by doing string modification on boot_device. |
183 // Returns empty string on failure. | 186 // Returns empty string on failure. |
184 const std::string BootKernelDevice(const std::string& boot_device); | 187 const std::string BootKernelDevice(const std::string& boot_device); |
185 | 188 |
| 189 enum ProcessPriority { |
| 190 kProcessPriorityHigh = -10, |
| 191 kProcessPriorityNormal = 0, |
| 192 kProcessPriorityLow = 10, |
| 193 }; |
| 194 |
| 195 // Compares process priorities and returns an integer that is less |
| 196 // than, equal to or greater than 0 if |priority_lhs| is, |
| 197 // respectively, lower than, same as or higher than |priority_rhs|. |
| 198 int ComparePriorities(ProcessPriority priority_lhs, |
| 199 ProcessPriority priority_rhs); |
| 200 |
| 201 // Sets the current process priority to |priority|. Returns true on |
| 202 // success, false otherwise. |
| 203 bool SetProcessPriority(ProcessPriority priority); |
186 | 204 |
187 } // namespace utils | 205 } // namespace utils |
188 | 206 |
189 // Class to unmount FS when object goes out of scope | 207 // Class to unmount FS when object goes out of scope |
190 class ScopedFilesystemUnmounter { | 208 class ScopedFilesystemUnmounter { |
191 public: | 209 public: |
192 explicit ScopedFilesystemUnmounter(const std::string& mountpoint) | 210 explicit ScopedFilesystemUnmounter(const std::string& mountpoint) |
193 : mountpoint_(mountpoint) {} | 211 : mountpoint_(mountpoint) {} |
194 ~ScopedFilesystemUnmounter() { | 212 ~ScopedFilesystemUnmounter() { |
195 utils::UnmountFilesystem(mountpoint_); | 213 utils::UnmountFilesystem(mountpoint_); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 bool _success = (_x); \ | 329 bool _success = (_x); \ |
312 if (!_success) { \ | 330 if (!_success) { \ |
313 LOG(ERROR) << #_x " failed."; \ | 331 LOG(ERROR) << #_x " failed."; \ |
314 return; \ | 332 return; \ |
315 } \ | 333 } \ |
316 } while (0) | 334 } while (0) |
317 | 335 |
318 | 336 |
319 | 337 |
320 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 338 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
OLD | NEW |