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"
11 #include "base/bind.h"
12 #include "base/callback.h"
13 #include "base/command_line.h"
14 #include "base/location.h"
15 #include "base/message_loop/message_loop.h"
16 #include "chromeos/chromeos_switches.h"
20 FakeDebugDaemonClient::FakeDebugDaemonClient()
21 : featues_mask_(DebugDaemonClient::DEV_FEATURE_NONE
) {
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::SetDebuggingFeaturesStatus(int featues_mask
) {
135 featues_mask_
= featues_mask
;
138 void FakeDebugDaemonClient::QueryDebuggingFeatures(
139 const DebugDaemonClient::QueryDevFeaturesCallback
& callback
) {
140 bool supported
= base::CommandLine::ForCurrentProcess()->HasSwitch(
141 chromeos::switches::kSystemDevMode
);
142 base::MessageLoop::current()->PostTask(
147 supported
? featues_mask_
:
148 DebugDaemonClient::DEV_FEATURES_DISABLED
)));
151 void FakeDebugDaemonClient::RemoveRootfsVerification(
152 const DebugDaemonClient::EnableDebuggingCallback
& callback
) {
153 base::MessageLoop::current()->PostTask(FROM_HERE
,
154 base::Bind(callback
, true));
157 } // namespace chromeos