Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chromeos / dbus / debug_daemon_client.h
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.
4
5 #ifndef CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_
6 #define CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_
7
8 #include "base/callback.h"
9 #include "base/memory/ref_counted_memory.h"
10 #include "base/platform_file.h"
11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/dbus_client.h"
13
14 #include <map>
15
16 namespace metrics {
17 class PerfDataProto;
18 }
19
20 namespace chromeos {
21
22 // DebugDaemonClient is used to communicate with the debug daemon.
23 class CHROMEOS_EXPORT DebugDaemonClient : public DBusClient {
24  public:
25   virtual ~DebugDaemonClient();
26
27   // Called once GetDebugLogs() is complete. Takes one parameter:
28   // - succeeded: was the logs stored successfully.
29   typedef base::Callback<void(bool succeeded)> GetDebugLogsCallback;
30
31   // Requests to store debug logs into |file| and calls |callback|
32   // when completed. Debug logs will be stored in the .tgz format.
33   virtual void GetDebugLogs(base::PlatformFile file,
34                             const GetDebugLogsCallback& callback) = 0;
35
36   // Called once SetDebugMode() is complete. Takes one parameter:
37   // - succeeded: debug mode was changed successfully.
38   typedef base::Callback<void(bool succeeded)> SetDebugModeCallback;
39
40   // Requests to change debug mode to given |subsystem| and calls
41   // |callback| when completed. |subsystem| should be one of the
42   // following: "wifi", "ethernet", "cellular" or "none".
43   virtual void SetDebugMode(const std::string& subsystem,
44                             const SetDebugModeCallback& callback) = 0;
45
46   // Called once GetRoutes() is complete.
47   typedef base::Callback<void(bool succeeded,
48                               const std::vector<std::string>& routes)>
49       GetRoutesCallback;
50   virtual void GetRoutes(bool numeric, bool ipv6,
51                          const GetRoutesCallback& callback) = 0;
52
53   // Called once GetNetworkStatus() is complete.
54   typedef base::Callback<void(bool succeeded, const std::string& status)>
55       GetNetworkStatusCallback;
56
57   // Gets information about network status as json.
58   virtual void GetNetworkStatus(const GetNetworkStatusCallback& callback) = 0;
59
60   // Called once GetModemStatus() is complete.
61   typedef base::Callback<void(bool succeeded, const std::string& status)>
62       GetModemStatusCallback;
63
64   // Gets information about modem status as json.
65   virtual void GetModemStatus(const GetModemStatusCallback& callback) = 0;
66
67   // Called once GetWiMaxStatus() is complete.
68   typedef base::Callback<void(bool succeeded, const std::string& status)>
69       GetWiMaxStatusCallback;
70
71   // Gets information about WiMAX status as json.
72   virtual void GetWiMaxStatus(const GetWiMaxStatusCallback& callback) = 0;
73
74   // Called once GetNetworkInterfaces() is complete. Takes two parameters:
75   // - succeeded: information was obtained successfully.
76   // - status: network interfaces information in json. For details, please refer
77   //   to http://gerrit.chromium.org/gerrit/#/c/28045/5/src/helpers/netif.cc
78   typedef base::Callback<void(bool succeeded, const std::string& status)>
79       GetNetworkInterfacesCallback;
80
81   // Gets information about network interfaces as json.
82   virtual void GetNetworkInterfaces(
83       const GetNetworkInterfacesCallback& callback) = 0;
84
85   // Called once GetPerfData() is complete only if the the data is successfully
86   // obtained from debugd.
87   typedef base::Callback<void(const std::vector<uint8>& data)>
88       GetPerfDataCallback;
89
90   // Runs perf for |duration| seconds and returns data collected.
91   virtual void GetPerfData(uint32_t duration,
92                            const GetPerfDataCallback& callback) = 0;
93
94   // Callback type for GetScrubbedLogs(), GetAllLogs() or GetUserLogFiles().
95   typedef base::Callback<void(bool succeeded,
96                               const std::map<std::string, std::string>& logs)>
97       GetLogsCallback;
98
99   // Gets scrubbed logs from debugd.
100   virtual void GetScrubbedLogs(const GetLogsCallback& callback) = 0;
101
102   // Gets all logs collected by debugd.
103   virtual void GetAllLogs(const GetLogsCallback& callback) = 0;
104
105   // Gets list of user log files that must be read by Chrome.
106   virtual void GetUserLogFiles(const GetLogsCallback& callback) = 0;
107
108   // Requests to start system/kernel tracing.
109   virtual void StartSystemTracing() = 0;
110
111   // Called once RequestStopSystemTracing() is complete. Takes one parameter:
112   // - result: the data collected while tracing was active
113   typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&
114       result)> StopSystemTracingCallback;
115
116   // Requests to stop system tracing and calls |callback| when completed.
117   virtual bool RequestStopSystemTracing(const StopSystemTracingCallback&
118       callback) = 0;
119
120   // Returns an empty SystemTracingCallback that does nothing.
121   static StopSystemTracingCallback EmptyStopSystemTracingCallback();
122
123   // Called once TestICMP() is complete. Takes two parameters:
124   // - succeeded: information was obtained successfully.
125   // - status: information about ICMP connectivity to a specified host as json.
126   //   For details please refer to
127   //   https://gerrit.chromium.org/gerrit/#/c/30310/2/src/helpers/icmp.cc
128   typedef base::Callback<void(bool succeeded, const std::string& status)>
129       TestICMPCallback;
130
131   // Tests ICMP connectivity to a specified host. The |ip_address| contains the
132   // IPv4 or IPv6 address of the host, for example "8.8.8.8".
133   virtual void TestICMP(const std::string& ip_address,
134                         const TestICMPCallback& callback) = 0;
135
136   // Tests ICMP connectivity to a specified host. The |ip_address| contains the
137   // IPv4 or IPv6 address of the host, for example "8.8.8.8".
138   virtual void TestICMPWithOptions(
139       const std::string& ip_address,
140       const std::map<std::string, std::string>& options,
141       const TestICMPCallback& callback) = 0;
142
143   // Trigger uploading of crashes.
144   virtual void UploadCrashes() = 0;
145
146   // Factory function, creates a new instance and returns ownership.
147   // For normal usage, access the singleton via DBusThreadManager::Get().
148   static DebugDaemonClient* Create();
149
150  protected:
151   // Create() should be used instead.
152   DebugDaemonClient();
153
154  private:
155   DISALLOW_COPY_AND_ASSIGN(DebugDaemonClient);
156 };
157
158 }  // namespace chromeos
159
160 #endif  // CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_