[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / chromeos / dbus / debug_daemon_client.h
blob85b1ccd02b65875652bc465459ee1f6ba11a6118
1 // Copyright (c) 2012 The Chromium 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.
5 #ifndef CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_
6 #define CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_
8 #include <map>
10 #include "base/callback.h"
11 #include "base/files/file.h"
12 #include "base/memory/ref_counted_memory.h"
13 #include "base/task_runner.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_client.h"
16 #include "third_party/cros_system_api/dbus/service_constants.h"
18 namespace metrics {
19 class PerfDataProto;
22 namespace chromeos {
24 // DebugDaemonClient is used to communicate with the debug daemon.
25 class CHROMEOS_EXPORT DebugDaemonClient : public DBusClient {
26 public:
27 ~DebugDaemonClient() override;
29 // Called once GetDebugLogs() is complete. Takes one parameter:
30 // - succeeded: was the logs stored successfully.
31 typedef base::Callback<void(bool succeeded)> GetDebugLogsCallback;
33 // Requests to store debug logs into |file| and calls |callback|
34 // when completed. Debug logs will be stored in the .tgz if
35 // |is_compressed| is true, otherwise in logs will be stored in .tar format.
36 virtual void DumpDebugLogs(bool is_compressed,
37 base::File file,
38 scoped_refptr<base::TaskRunner> task_runner,
39 const GetDebugLogsCallback& callback) = 0;
41 // Called once SetDebugMode() is complete. Takes one parameter:
42 // - succeeded: debug mode was changed successfully.
43 typedef base::Callback<void(bool succeeded)> SetDebugModeCallback;
45 // Requests to change debug mode to given |subsystem| and calls
46 // |callback| when completed. |subsystem| should be one of the
47 // following: "wifi", "ethernet", "cellular" or "none".
48 virtual void SetDebugMode(const std::string& subsystem,
49 const SetDebugModeCallback& callback) = 0;
51 // Called once GetRoutes() is complete.
52 typedef base::Callback<void(bool succeeded,
53 const std::vector<std::string>& routes)>
54 GetRoutesCallback;
55 virtual void GetRoutes(bool numeric, bool ipv6,
56 const GetRoutesCallback& callback) = 0;
58 // Called once GetNetworkStatus() is complete.
59 typedef base::Callback<void(bool succeeded, const std::string& status)>
60 GetNetworkStatusCallback;
62 // Gets information about network status as json.
63 virtual void GetNetworkStatus(const GetNetworkStatusCallback& callback) = 0;
65 // Called once GetModemStatus() is complete.
66 typedef base::Callback<void(bool succeeded, const std::string& status)>
67 GetModemStatusCallback;
69 // Gets information about modem status as json.
70 virtual void GetModemStatus(const GetModemStatusCallback& callback) = 0;
72 // Called once GetWiMaxStatus() is complete.
73 typedef base::Callback<void(bool succeeded, const std::string& status)>
74 GetWiMaxStatusCallback;
76 // Gets information about WiMAX status as json.
77 virtual void GetWiMaxStatus(const GetWiMaxStatusCallback& callback) = 0;
79 // Called once GetNetworkInterfaces() is complete. Takes two parameters:
80 // - succeeded: information was obtained successfully.
81 // - status: network interfaces information in json. For details, please refer
82 // to http://gerrit.chromium.org/gerrit/#/c/28045/5/src/helpers/netif.cc
83 typedef base::Callback<void(bool succeeded, const std::string& status)>
84 GetNetworkInterfacesCallback;
86 // Gets information about network interfaces as json.
87 virtual void GetNetworkInterfaces(
88 const GetNetworkInterfacesCallback& callback) = 0;
90 // Called once GetPerfData() is complete only if the the data is successfully
91 // obtained from debugd.
92 typedef base::Callback<void(const std::vector<uint8>& data)>
93 GetPerfDataCallback;
95 // Runs perf for |duration| seconds and returns data collected.
96 virtual void GetPerfData(uint32_t duration,
97 const GetPerfDataCallback& callback) = 0;
99 // Callback type for GetScrubbedLogs(), GetAllLogs() or GetUserLogFiles().
100 typedef base::Callback<void(bool succeeded,
101 const std::map<std::string, std::string>& logs)>
102 GetLogsCallback;
104 // Gets scrubbed logs from debugd.
105 virtual void GetScrubbedLogs(const GetLogsCallback& callback) = 0;
107 // Gets all logs collected by debugd.
108 virtual void GetAllLogs(const GetLogsCallback& callback) = 0;
110 // Gets list of user log files that must be read by Chrome.
111 virtual void GetUserLogFiles(const GetLogsCallback& callback) = 0;
113 // Requests to start system/kernel tracing.
114 virtual void StartSystemTracing() = 0;
116 // Called once RequestStopSystemTracing() is complete. Takes one parameter:
117 // - result: the data collected while tracing was active
118 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&
119 result)> StopSystemTracingCallback;
121 // Requests to stop system tracing and calls |callback| when completed.
122 virtual bool RequestStopSystemTracing(
123 scoped_refptr<base::TaskRunner> task_runner,
124 const StopSystemTracingCallback& callback) = 0;
126 // Returns an empty SystemTracingCallback that does nothing.
127 static StopSystemTracingCallback EmptyStopSystemTracingCallback();
129 // Called once TestICMP() is complete. Takes two parameters:
130 // - succeeded: information was obtained successfully.
131 // - status: information about ICMP connectivity to a specified host as json.
132 // For details please refer to
133 // https://gerrit.chromium.org/gerrit/#/c/30310/2/src/helpers/icmp.cc
134 typedef base::Callback<void(bool succeeded, const std::string& status)>
135 TestICMPCallback;
137 // Tests ICMP connectivity to a specified host. The |ip_address| contains the
138 // IPv4 or IPv6 address of the host, for example "8.8.8.8".
139 virtual void TestICMP(const std::string& ip_address,
140 const TestICMPCallback& callback) = 0;
142 // Tests ICMP connectivity to a specified host. The |ip_address| contains the
143 // IPv4 or IPv6 address of the host, for example "8.8.8.8".
144 virtual void TestICMPWithOptions(
145 const std::string& ip_address,
146 const std::map<std::string, std::string>& options,
147 const TestICMPCallback& callback) = 0;
149 // Called once EnableDebuggingFeatures() is complete. |succeeded| will be true
150 // if debugging features have been successfully enabled.
151 typedef base::Callback<void(bool succeeded)> EnableDebuggingCallback;
153 // Enables debugging features (sshd, boot from USB). |password| is a new
154 // password for root user. Can be only called in dev mode.
155 virtual void EnableDebuggingFeatures(
156 const std::string& password,
157 const EnableDebuggingCallback& callback) = 0;
159 static const int DEV_FEATURE_NONE = 0;
160 static const int DEV_FEATURE_ALL_ENABLED =
161 debugd::DevFeatureFlag::DEV_FEATURE_ROOTFS_VERIFICATION_REMOVED |
162 debugd::DevFeatureFlag::DEV_FEATURE_BOOT_FROM_USB_ENABLED |
163 debugd::DevFeatureFlag::DEV_FEATURE_SSH_SERVER_CONFIGURED |
164 debugd::DevFeatureFlag::DEV_FEATURE_DEV_MODE_ROOT_PASSWORD_SET;
166 // Called once QueryDebuggingFeatures() is complete. |succeeded| will be true
167 // if debugging features have been successfully enabled. |feature_mask| is a
168 // bitmask made out of DebuggingFeature enum values.
169 typedef base::Callback<void(bool succeeded,
170 int feature_mask)> QueryDevFeaturesCallback;
171 // Checks which debugging features have been already enabled.
172 virtual void QueryDebuggingFeatures(
173 const QueryDevFeaturesCallback& callback) = 0;
175 // Removes rootfs verification from the file system. Can be only called in
176 // dev mode.
177 virtual void RemoveRootfsVerification(
178 const EnableDebuggingCallback& callback) = 0;
180 // Trigger uploading of crashes.
181 virtual void UploadCrashes() = 0;
183 // A callback for WaitForServiceToBeAvailable().
184 typedef base::Callback<void(bool service_is_ready)>
185 WaitForServiceToBeAvailableCallback;
187 // Runs the callback as soon as the service becomes available.
188 virtual void WaitForServiceToBeAvailable(
189 const WaitForServiceToBeAvailableCallback& callback) = 0;
191 // Factory function, creates a new instance and returns ownership.
192 // For normal usage, access the singleton via DBusThreadManager::Get().
193 static DebugDaemonClient* Create();
195 protected:
196 // Create() should be used instead.
197 DebugDaemonClient();
199 private:
200 DISALLOW_COPY_AND_ASSIGN(DebugDaemonClient);
203 } // namespace chromeos
205 #endif // CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_