1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromeos/dbus/fake_debug_daemon_client.h"
10 #include "base/bind.h"
11 #include "base/callback.h"
12 #include "base/command_line.h"
13 #include "base/location.h"
14 #include "base/message_loop/message_loop.h"
15 #include "chromeos/chromeos_switches.h"
19 FakeDebugDaemonClient::FakeDebugDaemonClient()
20 : featues_mask_(DebugDaemonClient::DEV_FEATURE_NONE
),
21 service_is_available_(true) {
24 FakeDebugDaemonClient::~FakeDebugDaemonClient() {}
26 void FakeDebugDaemonClient::Init(dbus::Bus
* bus
) {}
28 void FakeDebugDaemonClient::DumpDebugLogs(
31 scoped_refptr
<base::TaskRunner
> task_runner
,
32 const GetDebugLogsCallback
& callback
) {
36 void FakeDebugDaemonClient::SetDebugMode(const std::string
& subsystem
,
37 const SetDebugModeCallback
& callback
) {
40 void FakeDebugDaemonClient::StartSystemTracing() {}
42 bool FakeDebugDaemonClient::RequestStopSystemTracing(
43 scoped_refptr
<base::TaskRunner
> task_runner
,
44 const StopSystemTracingCallback
& callback
) {
46 callback
.Run(base::RefCountedString::TakeString(&no_data
));
50 void FakeDebugDaemonClient::GetRoutes(bool numeric
,
52 const GetRoutesCallback
& callback
) {
53 std::vector
<std::string
> empty
;
54 base::MessageLoop::current()->PostTask(FROM_HERE
,
55 base::Bind(callback
, false, empty
));
58 void FakeDebugDaemonClient::GetNetworkStatus(
59 const GetNetworkStatusCallback
& callback
) {
60 base::MessageLoop::current()->PostTask(FROM_HERE
,
61 base::Bind(callback
, false, ""));
64 void FakeDebugDaemonClient::GetModemStatus(
65 const GetModemStatusCallback
& callback
) {
66 base::MessageLoop::current()->PostTask(FROM_HERE
,
67 base::Bind(callback
, false, ""));
70 void FakeDebugDaemonClient::GetWiMaxStatus(
71 const GetWiMaxStatusCallback
& callback
) {
72 base::MessageLoop::current()->PostTask(FROM_HERE
,
73 base::Bind(callback
, false, ""));
76 void FakeDebugDaemonClient::GetNetworkInterfaces(
77 const GetNetworkInterfacesCallback
& callback
) {
78 base::MessageLoop::current()->PostTask(FROM_HERE
,
79 base::Bind(callback
, false, ""));
82 void FakeDebugDaemonClient::GetPerfData(uint32_t duration
,
83 const GetPerfDataCallback
& callback
) {
84 std::vector
<uint8
> data
;
85 base::MessageLoop::current()->PostTask(FROM_HERE
, base::Bind(callback
, data
));
88 void FakeDebugDaemonClient::GetScrubbedLogs(const GetLogsCallback
& callback
) {
89 std::map
<std::string
, std::string
> sample
;
90 sample
["Sample Scrubbed Log"] = "Your email address is xxxxxxxx";
91 base::MessageLoop::current()->PostTask(FROM_HERE
,
92 base::Bind(callback
, false, sample
));
95 void FakeDebugDaemonClient::GetAllLogs(const GetLogsCallback
& callback
) {
96 std::map
<std::string
, std::string
> sample
;
97 sample
["Sample Log"] = "Your email address is abc@abc.com";
98 base::MessageLoop::current()->PostTask(FROM_HERE
,
99 base::Bind(callback
, false, sample
));
102 void FakeDebugDaemonClient::GetUserLogFiles(const GetLogsCallback
& callback
) {
103 std::map
<std::string
, std::string
> user_logs
;
104 user_logs
["preferences"] = "Preferences";
105 user_logs
["invalid_file"] = "Invalid File";
106 base::MessageLoop::current()->PostTask(FROM_HERE
,
107 base::Bind(callback
, true, user_logs
));
110 void FakeDebugDaemonClient::TestICMP(const std::string
& ip_address
,
111 const TestICMPCallback
& callback
) {
112 base::MessageLoop::current()->PostTask(FROM_HERE
,
113 base::Bind(callback
, false, ""));
116 void FakeDebugDaemonClient::TestICMPWithOptions(
117 const std::string
& ip_address
,
118 const std::map
<std::string
, std::string
>& options
,
119 const TestICMPCallback
& callback
) {
120 base::MessageLoop::current()->PostTask(FROM_HERE
,
121 base::Bind(callback
, false, ""));
124 void FakeDebugDaemonClient::UploadCrashes() {
127 void FakeDebugDaemonClient::EnableDebuggingFeatures(
128 const std::string
& password
,
129 const DebugDaemonClient::EnableDebuggingCallback
& callback
) {
130 base::MessageLoop::current()->PostTask(FROM_HERE
,
131 base::Bind(callback
, true));
134 void FakeDebugDaemonClient::QueryDebuggingFeatures(
135 const DebugDaemonClient::QueryDevFeaturesCallback
& callback
) {
136 bool supported
= base::CommandLine::ForCurrentProcess()->HasSwitch(
137 chromeos::switches::kSystemDevMode
);
138 base::MessageLoop::current()->PostTask(
143 supported
? featues_mask_
144 : debugd::DevFeatureFlag::DEV_FEATURES_DISABLED
)));
147 void FakeDebugDaemonClient::RemoveRootfsVerification(
148 const DebugDaemonClient::EnableDebuggingCallback
& callback
) {
149 base::MessageLoop::current()->PostTask(FROM_HERE
,
150 base::Bind(callback
, true));
153 void FakeDebugDaemonClient::WaitForServiceToBeAvailable(
154 const WaitForServiceToBeAvailableCallback
& callback
) {
155 if (service_is_available_
) {
156 base::MessageLoop::current()->PostTask(FROM_HERE
,
157 base::Bind(callback
, true));
159 pending_wait_for_service_to_be_available_callbacks_
.push_back(callback
);
163 void FakeDebugDaemonClient::SetDebuggingFeaturesStatus(int featues_mask
) {
164 featues_mask_
= featues_mask
;
167 void FakeDebugDaemonClient::SetServiceIsAvailable(bool is_available
) {
168 service_is_available_
= is_available
;
172 std::vector
<WaitForServiceToBeAvailableCallback
> callbacks
;
173 callbacks
.swap(pending_wait_for_service_to_be_available_callbacks_
);
174 for (size_t i
= 0; i
< callbacks
.size(); ++i
)
175 callbacks
[i
].Run(is_available
);
178 } // namespace chromeos