blob: 85d1e56e1690185c90fe9d155915d68c9fbac2ca [file] [log] [blame]
Satoru Takabayashie7f6d2a2018-08-08 17:06:29 +09001// 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 Takabayashib2ca40d2018-08-09 14:02:04 +09008#include <string>
9#include <vector>
10
11#include <base/files/file_path.h>
Satoru Takabayashi8ce6db82018-08-17 15:18:41 +090012#include <session_manager/dbus-proxies.h>
Satoru Takabayashib2ca40d2018-08-09 14:02:04 +090013
Satoru Takabayashie7f6d2a2018-08-08 17:06:29 +090014namespace util {
15
16// Returns true if integration tests are currently running.
17bool IsCrashTestInProgress();
18
19// Returns true if running on a developer image.
20bool IsDeveloperImage();
21
Satoru Takabayashif6a36802018-08-14 16:23:05 +090022// Returns true if running on a test image.
23bool IsTestImage();
24
Satoru Takabayashib2ca40d2018-08-09 14:02:04 +090025// 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.
29bool 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.
36bool GetCachedKeyValueDefault(const base::FilePath& base_name,
37 const std::string& key,
38 std::string* value);
39
Satoru Takabayashi8ce6db82018-08-17 15:18:41 +090040// 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.
42bool GetUserCrashDirectories(
43 org::chromium::SessionManagerInterfaceProxyInterface* session_manager_proxy,
44 std::vector<base::FilePath>* directories);
45
Satoru Takabayashie7f6d2a2018-08-08 17:06:29 +090046} // namespace util
47
48#endif // CRASH_REPORTER_UTIL_H_