Satoru Takabayashi | e7f6d2a | 2018-08-08 17:06:29 +0900 | [diff] [blame] | 1 | // Copyright 2018 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CRASH_REPORTER_UTIL_H_ |
| 6 | #define CRASH_REPORTER_UTIL_H_ |
| 7 | |
Satoru Takabayashi | b2ca40d | 2018-08-09 14:02:04 +0900 | [diff] [blame] | 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include <base/files/file_path.h> |
Satoru Takabayashi | 8ce6db8 | 2018-08-17 15:18:41 +0900 | [diff] [blame^] | 12 | #include <session_manager/dbus-proxies.h> |
Satoru Takabayashi | b2ca40d | 2018-08-09 14:02:04 +0900 | [diff] [blame] | 13 | |
Satoru Takabayashi | e7f6d2a | 2018-08-08 17:06:29 +0900 | [diff] [blame] | 14 | namespace util { |
| 15 | |
| 16 | // Returns true if integration tests are currently running. |
| 17 | bool IsCrashTestInProgress(); |
| 18 | |
| 19 | // Returns true if running on a developer image. |
| 20 | bool IsDeveloperImage(); |
| 21 | |
Satoru Takabayashi | f6a3680 | 2018-08-14 16:23:05 +0900 | [diff] [blame] | 22 | // Returns true if running on a test image. |
| 23 | bool IsTestImage(); |
| 24 | |
Satoru Takabayashi | b2ca40d | 2018-08-09 14:02:04 +0900 | [diff] [blame] | 25 | // Tries to find |key| in a key-value file named |base_name| in |directories| in |
| 26 | // the specified order, and writes the value to |value|. This function returns |
| 27 | // as soon as the key is found (i.e. if the key is found in the first directory, |
| 28 | // the remaining directories won't be checked). Returns true on success. |
| 29 | bool GetCachedKeyValue(const base::FilePath& base_name, |
| 30 | const std::string& key, |
| 31 | const std::vector<base::FilePath>& directories, |
| 32 | std::string* value); |
| 33 | |
| 34 | // Similar to GetCachedKeyValue(), but this version checks the predefined |
| 35 | // default directories. |
| 36 | bool GetCachedKeyValueDefault(const base::FilePath& base_name, |
| 37 | const std::string& key, |
| 38 | std::string* value); |
| 39 | |
Satoru Takabayashi | 8ce6db8 | 2018-08-17 15:18:41 +0900 | [diff] [blame^] | 40 | // Gets the user crash directories via D-Bus using |session_manager_proxy|. |
| 41 | // Returns true on success. The original contents of |directories| will be lost. |
| 42 | bool GetUserCrashDirectories( |
| 43 | org::chromium::SessionManagerInterfaceProxyInterface* session_manager_proxy, |
| 44 | std::vector<base::FilePath>* directories); |
| 45 | |
Satoru Takabayashi | e7f6d2a | 2018-08-08 17:06:29 +0900 | [diff] [blame] | 46 | } // namespace util |
| 47 | |
| 48 | #endif // CRASH_REPORTER_UTIL_H_ |