Chromium Code Reviews| 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. |
| 39 virtual void DumpDebugLogs(bool is_compressed, | 38 virtual void DumpDebugLogs(bool is_compressed, |
| 40 base::File file, | 39 int file_descriptor, |
|
satorux1
2016/08/23 04:43:37
How about taking ownership of the file descriptor
hashimoto
2016/08/23 06:38:50
Here we want to avoid owning the given FD because
satorux1
2016/08/23 07:02:02
Makes sense. In that case, could you add a comment
hashimoto
2016/08/23 07:41:27
Added a comment about FD duplication.
| |
| 41 scoped_refptr<base::TaskRunner> task_runner, | |
| 42 const GetDebugLogsCallback& callback) = 0; | 40 const GetDebugLogsCallback& callback) = 0; |
| 43 | 41 |
| 44 // Called once SetDebugMode() is complete. Takes one parameter: | 42 // Called once SetDebugMode() is complete. Takes one parameter: |
| 45 // - succeeded: debug mode was changed successfully. | 43 // - succeeded: debug mode was changed successfully. |
| 46 typedef base::Callback<void(bool succeeded)> SetDebugModeCallback; | 44 typedef base::Callback<void(bool succeeded)> SetDebugModeCallback; |
| 47 | 45 |
| 48 // Requests to change debug mode to given |subsystem| and calls | 46 // Requests to change debug mode to given |subsystem| and calls |
| 49 // |callback| when completed. |subsystem| should be one of the | 47 // |callback| when completed. |subsystem| should be one of the |
| 50 // following: "wifi", "ethernet", "cellular" or "none". | 48 // following: "wifi", "ethernet", "cellular" or "none". |
| 51 virtual void SetDebugMode(const std::string& subsystem, | 49 virtual void SetDebugMode(const std::string& subsystem, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 const std::string& error_message)>; | 93 const std::string& error_message)>; |
| 96 | 94 |
| 97 // Runs perf (via quipper) with arguments for |duration| (converted to | 95 // Runs perf (via quipper) with arguments for |duration| (converted to |
| 98 // seconds) and returns data collected over the passed |file_descriptor|. | 96 // seconds) and returns data collected over the passed |file_descriptor|. |
| 99 // |error_callback| is called if there is an error with the DBus call. | 97 // |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 | 98 // Note that quipper failures may occur after successfully running the DBus |
| 101 // method. Such errors can be detected by |file_descriptor| being closed with | 99 // method. Such errors can be detected by |file_descriptor| being closed with |
| 102 // no data written. | 100 // no data written. |
| 103 virtual void GetPerfOutput(base::TimeDelta duration, | 101 virtual void GetPerfOutput(base::TimeDelta duration, |
| 104 const std::vector<std::string>& perf_args, | 102 const std::vector<std::string>& perf_args, |
| 105 dbus::ScopedFileDescriptor file_descriptor, | 103 int file_descriptor, |
|
satorux1
2016/08/23 04:43:37
ditto. maybe take ownership?
hashimoto
2016/08/23 06:38:50
Acknowledged.
satorux1
2016/08/23 07:02:02
ditto. a comment about file_descriptor ownership w
hashimoto
2016/08/23 07:41:27
Done.
| |
| 106 const DBusMethodErrorCallback& error_callback) = 0; | 104 const DBusMethodErrorCallback& error_callback) = 0; |
| 107 | 105 |
| 108 // Callback type for GetScrubbedLogs(), GetAllLogs() or GetUserLogFiles(). | 106 // Callback type for GetScrubbedLogs(), GetAllLogs() or GetUserLogFiles(). |
| 109 using GetLogsCallback = | 107 using GetLogsCallback = |
| 110 base::Callback<void(bool succeeded, | 108 base::Callback<void(bool succeeded, |
| 111 const std::map<std::string, std::string>& logs)>; | 109 const std::map<std::string, std::string>& logs)>; |
| 112 | 110 |
| 113 // Gets scrubbed logs from debugd. | 111 // Gets scrubbed logs from debugd. |
| 114 virtual void GetScrubbedLogs(const GetLogsCallback& callback) = 0; | 112 virtual void GetScrubbedLogs(const GetLogsCallback& callback) = 0; |
| 115 | 113 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 // Create() should be used instead. | 198 // Create() should be used instead. |
| 201 DebugDaemonClient(); | 199 DebugDaemonClient(); |
| 202 | 200 |
| 203 private: | 201 private: |
| 204 DISALLOW_COPY_AND_ASSIGN(DebugDaemonClient); | 202 DISALLOW_COPY_AND_ASSIGN(DebugDaemonClient); |
| 205 }; | 203 }; |
| 206 | 204 |
| 207 } // namespace chromeos | 205 } // namespace chromeos |
| 208 | 206 |
| 209 #endif // CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_ | 207 #endif // CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_ |
| OLD | NEW |