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 GetLogCallback& 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 GetLogCallback& callback, |
| 644 dbus::Response* response) { |
| 645 std::string result; |
| 646 if (!response || !dbus::MessageReader(response).PopString(&result)) { |
| 647 callback.Run(false, result); |
| 648 return; |
| 649 } |
| 650 callback.Run(true, result); |
| 651 } |
| 652 |
632 void OnBigFeedbackLogsResponse(base::WeakPtr<PipeReaderWrapper> pipe_reader, | 653 void OnBigFeedbackLogsResponse(base::WeakPtr<PipeReaderWrapper> pipe_reader, |
633 dbus::Response* response) { | 654 dbus::Response* response) { |
634 if (!response && pipe_reader.get()) { | 655 if (!response && pipe_reader.get()) { |
635 // We need to terminate the data stream if an error occurred while the | 656 // We need to terminate the data stream if an error occurred while the |
636 // pipe reader is still waiting on read. | 657 // pipe reader is still waiting on read. |
637 pipe_reader->TerminateStream(); | 658 pipe_reader->TerminateStream(); |
638 } | 659 } |
639 } | 660 } |
640 | 661 |
641 // Called when a response for a simple start is received. | 662 // 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() { | 796 DebugDaemonClient::EmptyStopAgentTracingCallback() { |
776 return base::Bind(&EmptyStopAgentTracingCallbackBody); | 797 return base::Bind(&EmptyStopAgentTracingCallbackBody); |
777 } | 798 } |
778 | 799 |
779 // static | 800 // static |
780 DebugDaemonClient* DebugDaemonClient::Create() { | 801 DebugDaemonClient* DebugDaemonClient::Create() { |
781 return new DebugDaemonClientImpl(); | 802 return new DebugDaemonClientImpl(); |
782 } | 803 } |
783 | 804 |
784 } // namespace chromeos | 805 } // namespace chromeos |
OLD | NEW |