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 "base/callback.h"
9 #include "base/platform_file.h"
10 #include "base/memory/ref_counted_memory.h"
11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/dbus_client.h"
13 #include "chromeos/dbus/dbus_client_implementation_type.h"
23 // DebugDaemonClient is used to communicate with the debug daemon.
24 class CHROMEOS_EXPORT DebugDaemonClient : public DBusClient {
26 virtual ~DebugDaemonClient();
28 // Called once GetDebugLogs() is complete. Takes one parameter:
29 // - succeeded: was the logs stored successfully.
30 typedef base::Callback<void(bool succeeded)> GetDebugLogsCallback;
32 // Requests to store debug logs into |file| and calls |callback|
33 // when completed. Debug logs will be stored in the .tgz format.
34 virtual void GetDebugLogs(base::PlatformFile file,
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 GetPerfData() is complete only if the the data is successfully
87 // obtained from debugd.
88 typedef base::Callback<void(const std::vector<uint8>& data)>
91 // Runs perf for |duration| seconds and returns data collected.
92 virtual void GetPerfData(uint32_t duration,
93 const GetPerfDataCallback& callback) = 0;
95 // Callback type for GetScrubbedLogs(), GetAllLogs() or GetUserLogFiles().
96 typedef base::Callback<void(bool succeeded,
97 const std::map<std::string, std::string>& logs)>
100 // Gets scrubbed logs from debugd.
101 virtual void GetScrubbedLogs(const GetLogsCallback& callback) = 0;
103 // Gets all logs collected by debugd.
104 virtual void GetAllLogs(const GetLogsCallback& callback) = 0;
106 // Gets list of user log files that must be read by Chrome.
107 virtual void GetUserLogFiles(const GetLogsCallback& callback) = 0;
109 // Requests to start system/kernel tracing.
110 virtual void StartSystemTracing() = 0;
112 // Called once RequestStopSystemTracing() is complete. Takes one parameter:
113 // - result: the data collected while tracing was active
114 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&
115 result)> StopSystemTracingCallback;
117 // Requests to stop system tracing and calls |callback| when completed.
118 virtual bool RequestStopSystemTracing(const StopSystemTracingCallback&
121 // Returns an empty SystemTracingCallback that does nothing.
122 static StopSystemTracingCallback EmptyStopSystemTracingCallback();
124 // Called once TestICMP() is complete. Takes two parameters:
125 // - succeeded: information was obtained successfully.
126 // - status: information about ICMP connectivity to a specified host as json.
127 // For details please refer to
128 // https://gerrit.chromium.org/gerrit/#/c/30310/2/src/helpers/icmp.cc
129 typedef base::Callback<void(bool succeeded, const std::string& status)>
132 // Tests ICMP connectivity to a specified host. The |ip_address| contains the
133 // IPv4 or IPv6 address of the host, for example "8.8.8.8".
134 virtual void TestICMP(const std::string& ip_address,
135 const TestICMPCallback& callback) = 0;
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 TestICMPWithOptions(
140 const std::string& ip_address,
141 const std::map<std::string, std::string>& options,
142 const TestICMPCallback& callback) = 0;
144 // Factory function, creates a new instance and returns ownership.
145 // For normal usage, access the singleton via DBusThreadManager::Get().
146 static DebugDaemonClient* Create(DBusClientImplementationType type);
149 // Create() should be used instead.
153 DISALLOW_COPY_AND_ASSIGN(DebugDaemonClient);
156 } // namespace chromeos
158 #endif // CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_