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" |
| 6 |
5 #include <fcntl.h> | 7 #include <fcntl.h> |
6 #include <unistd.h> | 8 #include <unistd.h> |
7 | 9 #include <string> |
8 #include "chromeos/dbus/debug_daemon_client.h" | 10 #include <vector> |
9 | 11 |
10 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/location.h" |
12 #include "base/memory/ref_counted_memory.h" | 16 #include "base/memory/ref_counted_memory.h" |
13 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
14 #include "base/platform_file.h" | 18 #include "base/platform_file.h" |
15 #include "base/posix/eintr_wrapper.h" | 19 #include "base/posix/eintr_wrapper.h" |
16 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
17 #include "base/threading/worker_pool.h" | 21 #include "base/threading/worker_pool.h" |
18 #include "dbus/bus.h" | 22 #include "dbus/bus.h" |
19 #include "dbus/message.h" | 23 #include "dbus/message.h" |
20 #include "dbus/object_path.h" | 24 #include "dbus/object_path.h" |
21 #include "dbus/object_proxy.h" | 25 #include "dbus/object_proxy.h" |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 613 } |
610 | 614 |
611 dbus::ObjectProxy* debugdaemon_proxy_; | 615 dbus::ObjectProxy* debugdaemon_proxy_; |
612 scoped_ptr<PipeReader> pipe_reader_; | 616 scoped_ptr<PipeReader> pipe_reader_; |
613 StopSystemTracingCallback callback_; | 617 StopSystemTracingCallback callback_; |
614 base::WeakPtrFactory<DebugDaemonClientImpl> weak_ptr_factory_; | 618 base::WeakPtrFactory<DebugDaemonClientImpl> weak_ptr_factory_; |
615 | 619 |
616 DISALLOW_COPY_AND_ASSIGN(DebugDaemonClientImpl); | 620 DISALLOW_COPY_AND_ASSIGN(DebugDaemonClientImpl); |
617 }; | 621 }; |
618 | 622 |
619 // The DebugDaemonClient implementation used on Linux desktop, | |
620 // which does nothing. | |
621 class DebugDaemonClientStubImpl : public DebugDaemonClient { | |
622 // DebugDaemonClient overrides. | |
623 virtual void Init(dbus::Bus* bus) OVERRIDE {} | |
624 virtual void GetDebugLogs(base::PlatformFile file, | |
625 const GetDebugLogsCallback& callback) OVERRIDE { | |
626 callback.Run(false); | |
627 } | |
628 virtual void SetDebugMode(const std::string& subsystem, | |
629 const SetDebugModeCallback& callback) OVERRIDE { | |
630 callback.Run(false); | |
631 } | |
632 virtual void StartSystemTracing() OVERRIDE {} | |
633 virtual bool RequestStopSystemTracing(const StopSystemTracingCallback& | |
634 callback) OVERRIDE { | |
635 std::string no_data; | |
636 callback.Run(base::RefCountedString::TakeString(&no_data)); | |
637 return true; | |
638 } | |
639 virtual void GetRoutes(bool numeric, bool ipv6, | |
640 const GetRoutesCallback& callback) OVERRIDE { | |
641 std::vector<std::string> empty; | |
642 base::MessageLoop::current()->PostTask(FROM_HERE, | |
643 base::Bind(callback, false, empty)); | |
644 } | |
645 virtual void GetNetworkStatus(const GetNetworkStatusCallback& callback) | |
646 OVERRIDE { | |
647 base::MessageLoop::current()->PostTask(FROM_HERE, | |
648 base::Bind(callback, false, "")); | |
649 } | |
650 virtual void GetModemStatus(const GetModemStatusCallback& callback) | |
651 OVERRIDE { | |
652 base::MessageLoop::current()->PostTask(FROM_HERE, | |
653 base::Bind(callback, false, "")); | |
654 } | |
655 virtual void GetWiMaxStatus(const GetWiMaxStatusCallback& callback) | |
656 OVERRIDE { | |
657 base::MessageLoop::current()->PostTask(FROM_HERE, | |
658 base::Bind(callback, false, "")); | |
659 } | |
660 virtual void GetNetworkInterfaces( | |
661 const GetNetworkInterfacesCallback& callback) OVERRIDE { | |
662 base::MessageLoop::current()->PostTask(FROM_HERE, | |
663 base::Bind(callback, false, "")); | |
664 } | |
665 virtual void GetPerfData(uint32_t duration, | |
666 const GetPerfDataCallback& callback) OVERRIDE { | |
667 std::vector<uint8> data; | |
668 base::MessageLoop::current()->PostTask(FROM_HERE, | |
669 base::Bind(callback, data)); | |
670 } | |
671 virtual void GetScrubbedLogs(const GetLogsCallback& callback) OVERRIDE { | |
672 std::map<std::string, std::string> sample; | |
673 sample["Sample Scrubbed Log"] = "Your email address is xxxxxxxx"; | |
674 base::MessageLoop::current()->PostTask( | |
675 FROM_HERE, base::Bind(callback, false, sample)); | |
676 } | |
677 virtual void GetAllLogs(const GetLogsCallback& callback) OVERRIDE { | |
678 std::map<std::string, std::string> sample; | |
679 sample["Sample Log"] = "Your email address is abc@abc.com"; | |
680 base::MessageLoop::current()->PostTask( | |
681 FROM_HERE, base::Bind(callback, false, sample)); | |
682 } | |
683 virtual void GetUserLogFiles(const GetLogsCallback& callback) OVERRIDE { | |
684 std::map<std::string, std::string> user_logs; | |
685 user_logs["preferences"] = "Preferences"; | |
686 user_logs["invalid_file"] = "Invalid File"; | |
687 base::MessageLoop::current()->PostTask( | |
688 FROM_HERE, | |
689 base::Bind(callback, true, user_logs)); | |
690 } | |
691 | |
692 virtual void TestICMP(const std::string& ip_address, | |
693 const TestICMPCallback& callback) OVERRIDE { | |
694 base::MessageLoop::current()->PostTask(FROM_HERE, | |
695 base::Bind(callback, false, "")); | |
696 } | |
697 | |
698 virtual void TestICMPWithOptions( | |
699 const std::string& ip_address, | |
700 const std::map<std::string, std::string>& options, | |
701 const TestICMPCallback& callback) OVERRIDE { | |
702 base::MessageLoop::current()->PostTask(FROM_HERE, | |
703 base::Bind(callback, false, "")); | |
704 } | |
705 }; | |
706 | |
707 DebugDaemonClient::DebugDaemonClient() { | 623 DebugDaemonClient::DebugDaemonClient() { |
708 } | 624 } |
709 | 625 |
710 DebugDaemonClient::~DebugDaemonClient() { | 626 DebugDaemonClient::~DebugDaemonClient() { |
711 } | 627 } |
712 | 628 |
713 // static | 629 // static |
714 DebugDaemonClient::StopSystemTracingCallback | 630 DebugDaemonClient::StopSystemTracingCallback |
715 DebugDaemonClient::EmptyStopSystemTracingCallback() { | 631 DebugDaemonClient::EmptyStopSystemTracingCallback() { |
716 return base::Bind(&EmptyStopSystemTracingCallbackBody); | 632 return base::Bind(&EmptyStopSystemTracingCallbackBody); |
717 } | 633 } |
718 | 634 |
719 // static | 635 // static |
720 DebugDaemonClient* DebugDaemonClient::Create( | 636 DebugDaemonClient* DebugDaemonClient::Create() { |
721 DBusClientImplementationType type) { | 637 return new DebugDaemonClientImpl(); |
722 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | |
723 return new DebugDaemonClientImpl(); | |
724 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | |
725 return new DebugDaemonClientStubImpl(); | |
726 } | 638 } |
727 | 639 |
728 } // namespace chromeos | 640 } // namespace chromeos |
OLD | NEW |