| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_ | 6 #define CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/files/file.h" | 13 #include "base/files/file.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
| 16 #include "base/task_runner.h" | 16 #include "base/task_runner.h" |
| 17 #include "base/trace_event/tracing_agent.h" | 17 #include "base/trace_event/tracing_agent.h" |
| 18 #include "chromeos/chromeos_export.h" | 18 #include "chromeos/chromeos_export.h" |
| 19 #include "chromeos/dbus/dbus_client.h" | 19 #include "chromeos/dbus/dbus_client.h" |
| 20 #include "dbus/file_descriptor.h" | |
| 21 #include "third_party/cros_system_api/dbus/service_constants.h" | 20 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 22 | 21 |
| 23 namespace chromeos { | 22 namespace chromeos { |
| 24 | 23 |
| 25 // DebugDaemonClient is used to communicate with the debug daemon. | 24 // DebugDaemonClient is used to communicate with the debug daemon. |
| 26 class CHROMEOS_EXPORT DebugDaemonClient | 25 class CHROMEOS_EXPORT DebugDaemonClient |
| 27 : public DBusClient, | 26 : public DBusClient, |
| 28 public base::trace_event::TracingAgent { | 27 public base::trace_event::TracingAgent { |
| 29 public: | 28 public: |
| 30 ~DebugDaemonClient() override; | 29 ~DebugDaemonClient() override; |
| 31 | 30 |
| 32 // Called once GetDebugLogs() is complete. Takes one parameter: | 31 // Called once GetDebugLogs() is complete. Takes one parameter: |
| 33 // - succeeded: was the logs stored successfully. | 32 // - succeeded: was the logs stored successfully. |
| 34 typedef base::Callback<void(bool succeeded)> GetDebugLogsCallback; | 33 typedef base::Callback<void(bool succeeded)> GetDebugLogsCallback; |
| 35 | 34 |
| 36 // Requests to store debug logs into |file| and calls |callback| | 35 // Requests to store debug logs into |file_descriptor| and calls |callback| |
| 37 // when completed. Debug logs will be stored in the .tgz if | 36 // when completed. Debug logs will be stored in the .tgz if |
| 38 // |is_compressed| is true, otherwise in logs will be stored in .tar format. | 37 // |is_compressed| is true, otherwise in logs will be stored in .tar format. |
| 38 // This method duplicates |file_descriptor| so it's OK to close the FD without |
| 39 // waiting for the result. |
| 39 virtual void DumpDebugLogs(bool is_compressed, | 40 virtual void DumpDebugLogs(bool is_compressed, |
| 40 base::File file, | 41 int file_descriptor, |
| 41 scoped_refptr<base::TaskRunner> task_runner, | |
| 42 const GetDebugLogsCallback& callback) = 0; | 42 const GetDebugLogsCallback& callback) = 0; |
| 43 | 43 |
| 44 // Called once SetDebugMode() is complete. Takes one parameter: | 44 // Called once SetDebugMode() is complete. Takes one parameter: |
| 45 // - succeeded: debug mode was changed successfully. | 45 // - succeeded: debug mode was changed successfully. |
| 46 typedef base::Callback<void(bool succeeded)> SetDebugModeCallback; | 46 typedef base::Callback<void(bool succeeded)> SetDebugModeCallback; |
| 47 | 47 |
| 48 // Requests to change debug mode to given |subsystem| and calls | 48 // Requests to change debug mode to given |subsystem| and calls |
| 49 // |callback| when completed. |subsystem| should be one of the | 49 // |callback| when completed. |subsystem| should be one of the |
| 50 // following: "wifi", "ethernet", "cellular" or "none". | 50 // following: "wifi", "ethernet", "cellular" or "none". |
| 51 virtual void SetDebugMode(const std::string& subsystem, | 51 virtual void SetDebugMode(const std::string& subsystem, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 const GetNetworkInterfacesCallback& callback) = 0; | 91 const GetNetworkInterfacesCallback& callback) = 0; |
| 92 | 92 |
| 93 using DBusMethodErrorCallback = | 93 using DBusMethodErrorCallback = |
| 94 base::Callback<void(const std::string& error_name, | 94 base::Callback<void(const std::string& error_name, |
| 95 const std::string& error_message)>; | 95 const std::string& error_message)>; |
| 96 | 96 |
| 97 // Runs perf (via quipper) with arguments for |duration| (converted to | 97 // Runs perf (via quipper) with arguments for |duration| (converted to |
| 98 // seconds) and returns data collected over the passed |file_descriptor|. | 98 // seconds) and returns data collected over the passed |file_descriptor|. |
| 99 // |error_callback| is called if there is an error with the DBus call. | 99 // |error_callback| is called if there is an error with the DBus call. |
| 100 // Note that quipper failures may occur after successfully running the DBus | 100 // Note that quipper failures may occur after successfully running the DBus |
| 101 // method. Such errors can be detected by |file_descriptor| being closed with | 101 // method. Such errors can be detected by |file_descriptor| and all its |
| 102 // no data written. | 102 // duplicates being closed with no data written. |
| 103 // This method duplicates |file_descriptor| so it's OK to close the FD without |
| 104 // waiting for the result. |
| 103 virtual void GetPerfOutput(base::TimeDelta duration, | 105 virtual void GetPerfOutput(base::TimeDelta duration, |
| 104 const std::vector<std::string>& perf_args, | 106 const std::vector<std::string>& perf_args, |
| 105 dbus::ScopedFileDescriptor file_descriptor, | 107 int file_descriptor, |
| 106 const DBusMethodErrorCallback& error_callback) = 0; | 108 const DBusMethodErrorCallback& error_callback) = 0; |
| 107 | 109 |
| 108 // Callback type for GetScrubbedLogs(), GetAllLogs() or GetUserLogFiles(). | 110 // Callback type for GetScrubbedLogs(), GetAllLogs() or GetUserLogFiles(). |
| 109 using GetLogsCallback = | 111 using GetLogsCallback = |
| 110 base::Callback<void(bool succeeded, | 112 base::Callback<void(bool succeeded, |
| 111 const std::map<std::string, std::string>& logs)>; | 113 const std::map<std::string, std::string>& logs)>; |
| 112 | 114 |
| 113 // Gets scrubbed logs from debugd. | 115 // Gets scrubbed logs from debugd. |
| 114 virtual void GetScrubbedLogs(const GetLogsCallback& callback) = 0; | 116 virtual void GetScrubbedLogs(const GetLogsCallback& callback) = 0; |
| 115 | 117 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // Create() should be used instead. | 202 // Create() should be used instead. |
| 201 DebugDaemonClient(); | 203 DebugDaemonClient(); |
| 202 | 204 |
| 203 private: | 205 private: |
| 204 DISALLOW_COPY_AND_ASSIGN(DebugDaemonClient); | 206 DISALLOW_COPY_AND_ASSIGN(DebugDaemonClient); |
| 205 }; | 207 }; |
| 206 | 208 |
| 207 } // namespace chromeos | 209 } // namespace chromeos |
| 208 | 210 |
| 209 #endif // CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_ | 211 #endif // CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_ |
| OLD | NEW |