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 #include "chromeos/dbus/debug_daemon_client.h" | 5 #include "chromeos/dbus/debug_daemon_client.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 dbus::MethodCall method_call(debugd::kDebugdInterface, | 274 dbus::MethodCall method_call(debugd::kDebugdInterface, |
275 debugd::kGetUserLogFiles); | 275 debugd::kGetUserLogFiles); |
276 debugdaemon_proxy_->CallMethod( | 276 debugdaemon_proxy_->CallMethod( |
277 &method_call, | 277 &method_call, |
278 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 278 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
279 base::Bind(&DebugDaemonClientImpl::OnGetUserLogFiles, | 279 base::Bind(&DebugDaemonClientImpl::OnGetUserLogFiles, |
280 weak_ptr_factory_.GetWeakPtr(), | 280 weak_ptr_factory_.GetWeakPtr(), |
281 callback)); | 281 callback)); |
282 } | 282 } |
283 | 283 |
284 void GetLog(const std::string& log_name, | |
285 const GetLogsCallback& callback) override { | |
286 dbus::MethodCall method_call(debugd::kDebugdInterface, debugd::kGetLog); | |
287 dbus::MessageWriter(&method_call).AppendString(log_name); | |
288 debugdaemon_proxy_->CallMethod( | |
289 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
290 base::Bind(&DebugDaemonClientImpl::OnGetLog, | |
291 weak_ptr_factory_.GetWeakPtr(), log_name, callback)); | |
292 } | |
293 | |
284 // base::trace_event::TracingAgent implementation. | 294 // base::trace_event::TracingAgent implementation. |
285 std::string GetTracingAgentName() override { return kCrOSTracingAgentName; } | 295 std::string GetTracingAgentName() override { return kCrOSTracingAgentName; } |
286 | 296 |
287 std::string GetTraceEventLabel() override { return kCrOSTraceLabel; } | 297 std::string GetTraceEventLabel() override { return kCrOSTraceLabel; } |
288 | 298 |
289 void StartAgentTracing(const base::trace_event::TraceConfig& trace_config, | 299 void StartAgentTracing(const base::trace_event::TraceConfig& trace_config, |
290 const StartAgentTracingCallback& callback) override { | 300 const StartAgentTracingCallback& callback) override { |
291 dbus::MethodCall method_call( | 301 dbus::MethodCall method_call( |
292 debugd::kDebugdInterface, | 302 debugd::kDebugdInterface, |
293 debugd::kSystraceStart); | 303 debugd::kSystraceStart); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 logs[key] = value; | 632 logs[key] = value; |
623 } | 633 } |
624 callback.Run(!sub_reader.HasMoreData() && !broken, logs); | 634 callback.Run(!sub_reader.HasMoreData() && !broken, logs); |
625 } | 635 } |
626 | 636 |
627 void OnGetUserLogFiles(const GetLogsCallback& callback, | 637 void OnGetUserLogFiles(const GetLogsCallback& callback, |
628 dbus::Response* response) { | 638 dbus::Response* response) { |
629 return OnGetAllLogs(callback, response); | 639 return OnGetAllLogs(callback, response); |
630 } | 640 } |
631 | 641 |
642 void OnGetLog(const std::string& log_name, | |
643 const GetLogsCallback& callback, | |
644 dbus::Response* response) { | |
645 std::map<std::string, std::string> result; | |
646 std::string result_string; | |
647 if (!response || !dbus::MessageReader(response).PopString(&result_string)) { | |
648 callback.Run(false, result); | |
649 return; | |
650 } | |
651 result[log_name] = result_string; | |
Daniel Erat
2017/06/23 01:04:27
returning a single-entry map feels a bit hacky. wo
Simon Que
2017/06/23 01:15:10
Done.
| |
652 callback.Run(true, result); | |
653 } | |
654 | |
632 void OnBigFeedbackLogsResponse(base::WeakPtr<PipeReaderWrapper> pipe_reader, | 655 void OnBigFeedbackLogsResponse(base::WeakPtr<PipeReaderWrapper> pipe_reader, |
633 dbus::Response* response) { | 656 dbus::Response* response) { |
634 if (!response && pipe_reader.get()) { | 657 if (!response && pipe_reader.get()) { |
635 // We need to terminate the data stream if an error occurred while the | 658 // We need to terminate the data stream if an error occurred while the |
636 // pipe reader is still waiting on read. | 659 // pipe reader is still waiting on read. |
637 pipe_reader->TerminateStream(); | 660 pipe_reader->TerminateStream(); |
638 } | 661 } |
639 } | 662 } |
640 | 663 |
641 // Called when a response for a simple start is received. | 664 // Called when a response for a simple start is received. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 DebugDaemonClient::EmptyStopAgentTracingCallback() { | 798 DebugDaemonClient::EmptyStopAgentTracingCallback() { |
776 return base::Bind(&EmptyStopAgentTracingCallbackBody); | 799 return base::Bind(&EmptyStopAgentTracingCallbackBody); |
777 } | 800 } |
778 | 801 |
779 // static | 802 // static |
780 DebugDaemonClient* DebugDaemonClient::Create() { | 803 DebugDaemonClient* DebugDaemonClient::Create() { |
781 return new DebugDaemonClientImpl(); | 804 return new DebugDaemonClientImpl(); |
782 } | 805 } |
783 | 806 |
784 } // namespace chromeos | 807 } // namespace chromeos |
OLD | NEW |