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_
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"
20 // DebugDaemonClient is used to communicate with the debug daemon.
21 class CHROMEOS_EXPORT DebugDaemonClient
: public DBusClient
{
23 ~DebugDaemonClient() override
;
25 // Called once GetDebugLogs() is complete. Takes one parameter:
26 // - succeeded: was the logs stored successfully.
27 typedef base::Callback
<void(bool succeeded
)> GetDebugLogsCallback
;
29 // Requests to store debug logs into |file| and calls |callback|
30 // when completed. Debug logs will be stored in the .tgz if
31 // |is_compressed| is true, otherwise in logs will be stored in .tar format.
32 virtual void DumpDebugLogs(bool is_compressed
,
34 scoped_refptr
<base::TaskRunner
> task_runner
,
35 const GetDebugLogsCallback
& callback
) = 0;
37 // Called once SetDebugMode() is complete. Takes one parameter:
38 // - succeeded: debug mode was changed successfully.
39 typedef base::Callback
<void(bool succeeded
)> SetDebugModeCallback
;
41 // Requests to change debug mode to given |subsystem| and calls
42 // |callback| when completed. |subsystem| should be one of the
43 // following: "wifi", "ethernet", "cellular" or "none".
44 virtual void SetDebugMode(const std::string
& subsystem
,
45 const SetDebugModeCallback
& callback
) = 0;
47 // Called once GetRoutes() is complete.
48 typedef base::Callback
<void(bool succeeded
,
49 const std::vector
<std::string
>& routes
)>
51 virtual void GetRoutes(bool numeric
, bool ipv6
,
52 const GetRoutesCallback
& callback
) = 0;
54 // Called once GetNetworkStatus() is complete.
55 typedef base::Callback
<void(bool succeeded
, const std::string
& status
)>
56 GetNetworkStatusCallback
;
58 // Gets information about network status as json.
59 virtual void GetNetworkStatus(const GetNetworkStatusCallback
& callback
) = 0;
61 // Called once GetModemStatus() is complete.
62 typedef base::Callback
<void(bool succeeded
, const std::string
& status
)>
63 GetModemStatusCallback
;
65 // Gets information about modem status as json.
66 virtual void GetModemStatus(const GetModemStatusCallback
& callback
) = 0;
68 // Called once GetWiMaxStatus() is complete.
69 typedef base::Callback
<void(bool succeeded
, const std::string
& status
)>
70 GetWiMaxStatusCallback
;
72 // Gets information about WiMAX status as json.
73 virtual void GetWiMaxStatus(const GetWiMaxStatusCallback
& callback
) = 0;
75 // Called once GetNetworkInterfaces() is complete. Takes two parameters:
76 // - succeeded: information was obtained successfully.
77 // - status: network interfaces information in json. For details, please refer
78 // to http://gerrit.chromium.org/gerrit/#/c/28045/5/src/helpers/netif.cc
79 typedef base::Callback
<void(bool succeeded
, const std::string
& status
)>
80 GetNetworkInterfacesCallback
;
82 // Gets information about network interfaces as json.
83 virtual void GetNetworkInterfaces(
84 const GetNetworkInterfacesCallback
& callback
) = 0;
86 // Called once GetPerfOutput() is complete only if the the data is
87 // successfully obtained from debugd.
89 // - The status from running perf.
90 // - Output from "perf record", in PerfDataProto format.
91 // - Output from "perf stat", in PerfStatProto format.
92 using GetPerfOutputCallback
=
93 base::Callback
<void(int status
,
94 const std::vector
<uint8
>& perf_data
,
95 const std::vector
<uint8
>& perf_stat
)>;
97 // Runs perf for |duration| seconds and returns data collected.
98 // TODO(dhsharp): Remove this overload.
99 virtual void GetPerfOutput(uint32_t duration
,
100 const GetPerfOutputCallback
& callback
) = 0;
102 // Runs perf with arguments for |duration| seconds and returns data collected.
103 virtual void GetPerfOutput(uint32_t duration
,
104 const std::vector
<std::string
>& perf_args
,
105 const GetPerfOutputCallback
& callback
) = 0;
107 // Callback type for GetScrubbedLogs(), GetAllLogs() or GetUserLogFiles().
108 typedef base::Callback
<void(bool succeeded
,
109 const std::map
<std::string
, std::string
>& logs
)>
112 // Gets scrubbed logs from debugd.
113 virtual void GetScrubbedLogs(const GetLogsCallback
& callback
) = 0;
115 // Gets all logs collected by debugd.
116 virtual void GetAllLogs(const GetLogsCallback
& callback
) = 0;
118 // Gets list of user log files that must be read by Chrome.
119 virtual void GetUserLogFiles(const GetLogsCallback
& callback
) = 0;
121 // Requests to start system/kernel tracing.
122 virtual void StartSystemTracing() = 0;
124 // Called once RequestStopSystemTracing() is complete. Takes one parameter:
125 // - result: the data collected while tracing was active
126 typedef base::Callback
<void(const scoped_refptr
<base::RefCountedString
>&
127 result
)> StopSystemTracingCallback
;
129 // Requests to stop system tracing and calls |callback| when completed.
130 virtual bool RequestStopSystemTracing(
131 scoped_refptr
<base::TaskRunner
> task_runner
,
132 const StopSystemTracingCallback
& callback
) = 0;
134 // Returns an empty SystemTracingCallback that does nothing.
135 static StopSystemTracingCallback
EmptyStopSystemTracingCallback();
137 // Called once TestICMP() is complete. Takes two parameters:
138 // - succeeded: information was obtained successfully.
139 // - status: information about ICMP connectivity to a specified host as json.
140 // For details please refer to
141 // https://gerrit.chromium.org/gerrit/#/c/30310/2/src/helpers/icmp.cc
142 typedef base::Callback
<void(bool succeeded
, const std::string
& status
)>
145 // Tests ICMP connectivity to a specified host. The |ip_address| contains the
146 // IPv4 or IPv6 address of the host, for example "8.8.8.8".
147 virtual void TestICMP(const std::string
& ip_address
,
148 const TestICMPCallback
& callback
) = 0;
150 // Tests ICMP connectivity to a specified host. The |ip_address| contains the
151 // IPv4 or IPv6 address of the host, for example "8.8.8.8".
152 virtual void TestICMPWithOptions(
153 const std::string
& ip_address
,
154 const std::map
<std::string
, std::string
>& options
,
155 const TestICMPCallback
& callback
) = 0;
157 // Called once EnableDebuggingFeatures() is complete. |succeeded| will be true
158 // if debugging features have been successfully enabled.
159 typedef base::Callback
<void(bool succeeded
)> EnableDebuggingCallback
;
161 // Enables debugging features (sshd, boot from USB). |password| is a new
162 // password for root user. Can be only called in dev mode.
163 virtual void EnableDebuggingFeatures(
164 const std::string
& password
,
165 const EnableDebuggingCallback
& callback
) = 0;
167 static const int DEV_FEATURE_NONE
= 0;
168 static const int DEV_FEATURE_ALL_ENABLED
=
169 debugd::DevFeatureFlag::DEV_FEATURE_ROOTFS_VERIFICATION_REMOVED
|
170 debugd::DevFeatureFlag::DEV_FEATURE_BOOT_FROM_USB_ENABLED
|
171 debugd::DevFeatureFlag::DEV_FEATURE_SSH_SERVER_CONFIGURED
|
172 debugd::DevFeatureFlag::DEV_FEATURE_DEV_MODE_ROOT_PASSWORD_SET
;
174 // Called once QueryDebuggingFeatures() is complete. |succeeded| will be true
175 // if debugging features have been successfully enabled. |feature_mask| is a
176 // bitmask made out of DebuggingFeature enum values.
177 typedef base::Callback
<void(bool succeeded
,
178 int feature_mask
)> QueryDevFeaturesCallback
;
179 // Checks which debugging features have been already enabled.
180 virtual void QueryDebuggingFeatures(
181 const QueryDevFeaturesCallback
& callback
) = 0;
183 // Removes rootfs verification from the file system. Can be only called in
185 virtual void RemoveRootfsVerification(
186 const EnableDebuggingCallback
& callback
) = 0;
188 // Trigger uploading of crashes.
189 virtual void UploadCrashes() = 0;
191 // A callback for WaitForServiceToBeAvailable().
192 typedef base::Callback
<void(bool service_is_ready
)>
193 WaitForServiceToBeAvailableCallback
;
195 // Runs the callback as soon as the service becomes available.
196 virtual void WaitForServiceToBeAvailable(
197 const WaitForServiceToBeAvailableCallback
& callback
) = 0;
199 // Factory function, creates a new instance and returns ownership.
200 // For normal usage, access the singleton via DBusThreadManager::Get().
201 static DebugDaemonClient
* Create();
204 // Create() should be used instead.
208 DISALLOW_COPY_AND_ASSIGN(DebugDaemonClient
);
211 } // namespace chromeos
213 #endif // CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_