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 <fcntl.h> | 5 #include <fcntl.h> |
6 #include <unistd.h> | 6 #include <unistd.h> |
7 | 7 |
8 #include "chromeos/dbus/debug_daemon_client.h" | 8 #include "chromeos/dbus/debug_daemon_client.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 dbus::MethodCall method_call( | 302 dbus::MethodCall method_call( |
303 debugd::kDebugdInterface, | 303 debugd::kDebugdInterface, |
304 debugd::kSystraceStart); | 304 debugd::kSystraceStart); |
305 dbus::MessageWriter writer(&method_call); | 305 dbus::MessageWriter writer(&method_call); |
306 writer.AppendString("all"); // TODO(sleffler) parameterize category list | 306 writer.AppendString("all"); // TODO(sleffler) parameterize category list |
307 | 307 |
308 DVLOG(1) << "Requesting a systrace start"; | 308 DVLOG(1) << "Requesting a systrace start"; |
309 debugdaemon_proxy_->CallMethod( | 309 debugdaemon_proxy_->CallMethod( |
310 &method_call, | 310 &method_call, |
311 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 311 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
312 base::Bind(&DebugDaemonClientImpl::OnStartSystemTracing, | 312 base::Bind(&DebugDaemonClientImpl::OnStartMethod, |
313 weak_ptr_factory_.GetWeakPtr())); | 313 weak_ptr_factory_.GetWeakPtr())); |
314 } | 314 } |
315 | 315 |
316 virtual bool RequestStopSystemTracing(const StopSystemTracingCallback& | 316 virtual bool RequestStopSystemTracing(const StopSystemTracingCallback& |
317 callback) OVERRIDE { | 317 callback) OVERRIDE { |
318 if (pipe_reader_ != NULL) { | 318 if (pipe_reader_ != NULL) { |
319 LOG(ERROR) << "Busy doing StopSystemTracing"; | 319 LOG(ERROR) << "Busy doing StopSystemTracing"; |
320 return false; | 320 return false; |
321 } | 321 } |
322 | 322 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 389 |
390 // Call the function. | 390 // Call the function. |
391 debugdaemon_proxy_->CallMethod( | 391 debugdaemon_proxy_->CallMethod( |
392 &method_call, | 392 &method_call, |
393 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 393 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
394 base::Bind(&DebugDaemonClientImpl::OnTestICMP, | 394 base::Bind(&DebugDaemonClientImpl::OnTestICMP, |
395 weak_ptr_factory_.GetWeakPtr(), | 395 weak_ptr_factory_.GetWeakPtr(), |
396 callback)); | 396 callback)); |
397 } | 397 } |
398 | 398 |
| 399 virtual void UploadCrashes() OVERRIDE { |
| 400 dbus::MethodCall method_call(debugd::kDebugdInterface, |
| 401 debugd::kUploadCrashes); |
| 402 debugdaemon_proxy_->CallMethod( |
| 403 &method_call, |
| 404 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 405 base::Bind(&DebugDaemonClientImpl::OnStartMethod, |
| 406 weak_ptr_factory_.GetWeakPtr())); |
| 407 } |
| 408 |
399 protected: | 409 protected: |
400 virtual void Init(dbus::Bus* bus) OVERRIDE { | 410 virtual void Init(dbus::Bus* bus) OVERRIDE { |
401 debugdaemon_proxy_ = | 411 debugdaemon_proxy_ = |
402 bus->GetObjectProxy(debugd::kDebugdServiceName, | 412 bus->GetObjectProxy(debugd::kDebugdServiceName, |
403 dbus::ObjectPath(debugd::kDebugdServicePath)); | 413 dbus::ObjectPath(debugd::kDebugdServicePath)); |
404 } | 414 } |
405 | 415 |
406 private: | 416 private: |
407 // Called to check descriptor validity on a thread where i/o is permitted. | 417 // Called to check descriptor validity on a thread where i/o is permitted. |
408 static void CheckValidity(dbus::FileDescriptor* file_descriptor) { | 418 static void CheckValidity(dbus::FileDescriptor* file_descriptor) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 logs[key] = value; | 554 logs[key] = value; |
545 } | 555 } |
546 callback.Run(!sub_reader.HasMoreData() && !broken, logs); | 556 callback.Run(!sub_reader.HasMoreData() && !broken, logs); |
547 } | 557 } |
548 | 558 |
549 void OnGetUserLogFiles(const GetLogsCallback& callback, | 559 void OnGetUserLogFiles(const GetLogsCallback& callback, |
550 dbus::Response* response) { | 560 dbus::Response* response) { |
551 return OnGetAllLogs(callback, response); | 561 return OnGetAllLogs(callback, response); |
552 } | 562 } |
553 | 563 |
554 // Called when a response for StartSystemTracing() is received. | 564 // Called when a response for a simple start is received. |
555 void OnStartSystemTracing(dbus::Response* response) { | 565 void OnStartMethod(dbus::Response* response) { |
556 if (!response) { | 566 if (!response) { |
557 LOG(ERROR) << "Failed to request systrace start"; | 567 LOG(ERROR) << "Failed to request start"; |
558 return; | 568 return; |
559 } | 569 } |
560 } | 570 } |
561 | 571 |
562 // Called when a CheckValidity response is received. | 572 // Called when a CheckValidity response is received. |
563 void OnCheckValidityRequestStopSystem( | 573 void OnCheckValidityRequestStopSystem( |
564 dbus::FileDescriptor* file_descriptor, | 574 dbus::FileDescriptor* file_descriptor, |
565 const StopSystemTracingCallback& callback) { | 575 const StopSystemTracingCallback& callback) { |
566 // Issue the dbus request to stop system tracing | 576 // Issue the dbus request to stop system tracing |
567 dbus::MethodCall method_call( | 577 dbus::MethodCall method_call( |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 FROM_HERE, base::Bind(callback, false, sample)); | 691 FROM_HERE, base::Bind(callback, false, sample)); |
682 } | 692 } |
683 virtual void GetUserLogFiles(const GetLogsCallback& callback) OVERRIDE { | 693 virtual void GetUserLogFiles(const GetLogsCallback& callback) OVERRIDE { |
684 std::map<std::string, std::string> user_logs; | 694 std::map<std::string, std::string> user_logs; |
685 user_logs["preferences"] = "Preferences"; | 695 user_logs["preferences"] = "Preferences"; |
686 user_logs["invalid_file"] = "Invalid File"; | 696 user_logs["invalid_file"] = "Invalid File"; |
687 base::MessageLoop::current()->PostTask( | 697 base::MessageLoop::current()->PostTask( |
688 FROM_HERE, | 698 FROM_HERE, |
689 base::Bind(callback, true, user_logs)); | 699 base::Bind(callback, true, user_logs)); |
690 } | 700 } |
691 | |
692 virtual void TestICMP(const std::string& ip_address, | 701 virtual void TestICMP(const std::string& ip_address, |
693 const TestICMPCallback& callback) OVERRIDE { | 702 const TestICMPCallback& callback) OVERRIDE { |
694 base::MessageLoop::current()->PostTask(FROM_HERE, | 703 base::MessageLoop::current()->PostTask(FROM_HERE, |
695 base::Bind(callback, false, "")); | 704 base::Bind(callback, false, "")); |
696 } | 705 } |
697 | |
698 virtual void TestICMPWithOptions( | 706 virtual void TestICMPWithOptions( |
699 const std::string& ip_address, | 707 const std::string& ip_address, |
700 const std::map<std::string, std::string>& options, | 708 const std::map<std::string, std::string>& options, |
701 const TestICMPCallback& callback) OVERRIDE { | 709 const TestICMPCallback& callback) OVERRIDE { |
702 base::MessageLoop::current()->PostTask(FROM_HERE, | 710 base::MessageLoop::current()->PostTask(FROM_HERE, |
703 base::Bind(callback, false, "")); | 711 base::Bind(callback, false, "")); |
704 } | 712 } |
| 713 virtual void UploadCrashes() OVERRIDE {} |
705 }; | 714 }; |
706 | 715 |
707 DebugDaemonClient::DebugDaemonClient() { | 716 DebugDaemonClient::DebugDaemonClient() { |
708 } | 717 } |
709 | 718 |
710 DebugDaemonClient::~DebugDaemonClient() { | 719 DebugDaemonClient::~DebugDaemonClient() { |
711 } | 720 } |
712 | 721 |
713 // static | 722 // static |
714 DebugDaemonClient::StopSystemTracingCallback | 723 DebugDaemonClient::StopSystemTracingCallback |
715 DebugDaemonClient::EmptyStopSystemTracingCallback() { | 724 DebugDaemonClient::EmptyStopSystemTracingCallback() { |
716 return base::Bind(&EmptyStopSystemTracingCallbackBody); | 725 return base::Bind(&EmptyStopSystemTracingCallbackBody); |
717 } | 726 } |
718 | 727 |
719 // static | 728 // static |
720 DebugDaemonClient* DebugDaemonClient::Create( | 729 DebugDaemonClient* DebugDaemonClient::Create( |
721 DBusClientImplementationType type) { | 730 DBusClientImplementationType type) { |
722 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 731 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
723 return new DebugDaemonClientImpl(); | 732 return new DebugDaemonClientImpl(); |
724 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 733 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
725 return new DebugDaemonClientStubImpl(); | 734 return new DebugDaemonClientStubImpl(); |
726 } | 735 } |
727 | 736 |
728 } // namespace chromeos | 737 } // namespace chromeos |
OLD | NEW |