Commit f11d6208 authored by sque's avatar sque Committed by Commit Bot

Add GetLog method call to DebugDaemonClient

This gets an individual log from debugd.

BUG=733846

Review-Url: https://codereview.chromium.org/2944403002
Cr-Commit-Position: refs/heads/master@{#481805}
parent 451b82cd
......@@ -281,6 +281,16 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
callback));
}
void GetLog(const std::string& log_name,
const GetLogCallback& callback) override {
dbus::MethodCall method_call(debugd::kDebugdInterface, debugd::kGetLog);
dbus::MessageWriter(&method_call).AppendString(log_name);
debugdaemon_proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&DebugDaemonClientImpl::OnGetLog,
weak_ptr_factory_.GetWeakPtr(), log_name, callback));
}
// base::trace_event::TracingAgent implementation.
std::string GetTracingAgentName() override { return kCrOSTracingAgentName; }
......@@ -629,6 +639,17 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
return OnGetAllLogs(callback, response);
}
void OnGetLog(const std::string& log_name,
const GetLogCallback& callback,
dbus::Response* response) {
std::string result;
if (!response || !dbus::MessageReader(response).PopString(&result)) {
callback.Run(false, result);
return;
}
callback.Run(true, result);
}
void OnBigFeedbackLogsResponse(base::WeakPtr<PipeReaderWrapper> pipe_reader,
dbus::Response* response) {
if (!response && pipe_reader.get()) {
......
......@@ -114,6 +114,9 @@ class CHROMEOS_EXPORT DebugDaemonClient
using GetLogsCallback =
base::Callback<void(bool succeeded,
const std::map<std::string, std::string>& logs)>;
// Callback type for GetLog().
using GetLogCallback =
base::Callback<void(bool succeeded, const std::string& result)>;
// Gets scrubbed logs from debugd.
virtual void GetScrubbedLogs(const GetLogsCallback& callback) = 0;
......@@ -129,6 +132,10 @@ class CHROMEOS_EXPORT DebugDaemonClient
// Gets list of user log files that must be read by Chrome.
virtual void GetUserLogFiles(const GetLogsCallback& callback) = 0;
// Gets an individual log source provided by debugd.
virtual void GetLog(const std::string& log_name,
const GetLogCallback& callback) = 0;
virtual void SetStopAgentTracingTaskRunner(
scoped_refptr<base::TaskRunner> task_runner) = 0;
......
......@@ -143,6 +143,13 @@ void FakeDebugDaemonClient::GetUserLogFiles(const GetLogsCallback& callback) {
FROM_HERE, base::Bind(callback, true, user_logs));
}
void FakeDebugDaemonClient::GetLog(const std::string& log_name,
const GetLogCallback& callback) {
std::string result = log_name + ": response from GetLog";
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, true, result));
}
void FakeDebugDaemonClient::TestICMP(const std::string& ip_address,
const TestICMPCallback& callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
......
......@@ -54,6 +54,8 @@ class CHROMEOS_EXPORT FakeDebugDaemonClient : public DebugDaemonClient {
void GetScrubbedLogs(const GetLogsCallback& callback) override;
void GetScrubbedBigLogs(const GetLogsCallback& callback) override;
void GetAllLogs(const GetLogsCallback& callback) override;
void GetLog(const std::string& log_name,
const GetLogCallback& callback) override;
void GetUserLogFiles(const GetLogsCallback& callback) override;
void TestICMP(const std::string& ip_address,
const TestICMPCallback& callback) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment