| 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 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // Detects which bootloader this system uses and returns it via the out | 134 // Detects which bootloader this system uses and returns it via the out |
| 135 // param. Returns true on success. | 135 // param. Returns true on success. |
| 136 bool GetBootloader(BootLoader* out_bootloader); | 136 bool GetBootloader(BootLoader* out_bootloader); |
| 137 | 137 |
| 138 // Returns the error message, if any, from a GError pointer. | 138 // Returns the error message, if any, from a GError pointer. |
| 139 const char* GetGErrorMessage(const GError* error); | 139 const char* GetGErrorMessage(const GError* error); |
| 140 | 140 |
| 141 // Initiates a system reboot. Returns true on success, false otherwise. | 141 // Initiates a system reboot. Returns true on success, false otherwise. |
| 142 bool Reboot(); | 142 bool Reboot(); |
| 143 | 143 |
| 144 // Schedules a Main Loop callback to trigger the crash reporter to perform an |
| 145 // upload as if this process had crashed. |
| 146 void ScheduleCrashReporterUpload(); |
| 147 |
| 144 // Fuzzes an integer |value| randomly in the range: | 148 // Fuzzes an integer |value| randomly in the range: |
| 145 // [value - range / 2, value + range - range / 2] | 149 // [value - range / 2, value + range - range / 2] |
| 146 int FuzzInt(int value, unsigned int range); | 150 int FuzzInt(int value, unsigned int range); |
| 147 | 151 |
| 148 // Log a string in hex to LOG(INFO). Useful for debugging. | 152 // Log a string in hex to LOG(INFO). Useful for debugging. |
| 149 void HexDumpArray(const unsigned char* const arr, const size_t length); | 153 void HexDumpArray(const unsigned char* const arr, const size_t length); |
| 150 inline void HexDumpString(const std::string& str) { | 154 inline void HexDumpString(const std::string& str) { |
| 151 HexDumpArray(reinterpret_cast<const unsigned char*>(str.data()), str.size()); | 155 HexDumpArray(reinterpret_cast<const unsigned char*>(str.data()), str.size()); |
| 152 } | 156 } |
| 153 inline void HexDumpVector(const std::vector<char>& vect) { | 157 inline void HexDumpVector(const std::vector<char>& vect) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 if (_error) { \ | 411 if (_error) { \ |
| 408 errno = _error; \ | 412 errno = _error; \ |
| 409 LOG(ERROR) << #_x " failed: " << _error; \ | 413 LOG(ERROR) << #_x " failed: " << _error; \ |
| 410 return false; \ | 414 return false; \ |
| 411 } \ | 415 } \ |
| 412 } while (0) | 416 } while (0) |
| 413 | 417 |
| 414 | 418 |
| 415 | 419 |
| 416 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 420 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
| OLD | NEW |