Update V8 to version 4.6.54.
[chromium-blink-merge.git] / chromeos / dbus / fake_debug_daemon_client.cc
blob8b2124d0a0dd8bdd5430ff29f9488e63601b51e2
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"
7 #include <map>
8 #include <string>
10 #include "base/bind.h"
11 #include "base/callback.h"
12 #include "base/command_line.h"
13 #include "base/location.h"
14 #include "base/single_thread_task_runner.h"
15 #include "base/thread_task_runner_handle.h"
16 #include "chromeos/chromeos_switches.h"
18 namespace chromeos {
20 FakeDebugDaemonClient::FakeDebugDaemonClient()
21 : featues_mask_(DebugDaemonClient::DEV_FEATURE_NONE),
22 service_is_available_(true) {
25 FakeDebugDaemonClient::~FakeDebugDaemonClient() {}
27 void FakeDebugDaemonClient::Init(dbus::Bus* bus) {}
29 void FakeDebugDaemonClient::DumpDebugLogs(
30 bool is_compressed,
31 base::File file,
32 scoped_refptr<base::TaskRunner> task_runner,
33 const GetDebugLogsCallback& callback) {
34 callback.Run(true);
37 void FakeDebugDaemonClient::SetDebugMode(const std::string& subsystem,
38 const SetDebugModeCallback& callback) {
39 callback.Run(false);
41 void FakeDebugDaemonClient::StartSystemTracing() {}
43 bool FakeDebugDaemonClient::RequestStopSystemTracing(
44 scoped_refptr<base::TaskRunner> task_runner,
45 const StopSystemTracingCallback& callback) {
46 std::string no_data;
47 callback.Run(base::RefCountedString::TakeString(&no_data));
48 return true;
51 void FakeDebugDaemonClient::GetRoutes(bool numeric,
52 bool ipv6,
53 const GetRoutesCallback& callback) {
54 std::vector<std::string> empty;
55 base::ThreadTaskRunnerHandle::Get()->PostTask(
56 FROM_HERE, base::Bind(callback, false, empty));
59 void FakeDebugDaemonClient::GetNetworkStatus(
60 const GetNetworkStatusCallback& callback) {
61 base::ThreadTaskRunnerHandle::Get()->PostTask(
62 FROM_HERE, base::Bind(callback, false, ""));
65 void FakeDebugDaemonClient::GetModemStatus(
66 const GetModemStatusCallback& callback) {
67 base::ThreadTaskRunnerHandle::Get()->PostTask(
68 FROM_HERE, base::Bind(callback, false, ""));
71 void FakeDebugDaemonClient::GetWiMaxStatus(
72 const GetWiMaxStatusCallback& callback) {
73 base::ThreadTaskRunnerHandle::Get()->PostTask(
74 FROM_HERE, base::Bind(callback, false, ""));
77 void FakeDebugDaemonClient::GetNetworkInterfaces(
78 const GetNetworkInterfacesCallback& callback) {
79 base::ThreadTaskRunnerHandle::Get()->PostTask(
80 FROM_HERE, base::Bind(callback, false, ""));
83 void FakeDebugDaemonClient::GetPerfData(uint32_t duration,
84 const GetPerfDataCallback& callback) {
85 std::vector<uint8> data;
86 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
87 base::Bind(callback, data));
90 void FakeDebugDaemonClient::GetPerfOutput(
91 uint32_t duration,
92 const GetPerfOutputCallback& callback) {
93 int status = 0;
94 std::vector<uint8> perf_data;
95 std::vector<uint8> perf_stat;
96 base::ThreadTaskRunnerHandle::Get()->PostTask(
97 FROM_HERE, base::Bind(callback, status, perf_data, perf_stat));
100 void FakeDebugDaemonClient::GetScrubbedLogs(const GetLogsCallback& callback) {
101 std::map<std::string, std::string> sample;
102 sample["Sample Scrubbed Log"] = "Your email address is xxxxxxxx";
103 base::ThreadTaskRunnerHandle::Get()->PostTask(
104 FROM_HERE, base::Bind(callback, false, sample));
107 void FakeDebugDaemonClient::GetAllLogs(const GetLogsCallback& callback) {
108 std::map<std::string, std::string> sample;
109 sample["Sample Log"] = "Your email address is abc@abc.com";
110 base::ThreadTaskRunnerHandle::Get()->PostTask(
111 FROM_HERE, base::Bind(callback, false, sample));
114 void FakeDebugDaemonClient::GetUserLogFiles(const GetLogsCallback& callback) {
115 std::map<std::string, std::string> user_logs;
116 user_logs["preferences"] = "Preferences";
117 user_logs["invalid_file"] = "Invalid File";
118 base::ThreadTaskRunnerHandle::Get()->PostTask(
119 FROM_HERE, base::Bind(callback, true, user_logs));
122 void FakeDebugDaemonClient::TestICMP(const std::string& ip_address,
123 const TestICMPCallback& callback) {
124 base::ThreadTaskRunnerHandle::Get()->PostTask(
125 FROM_HERE, base::Bind(callback, false, ""));
128 void FakeDebugDaemonClient::TestICMPWithOptions(
129 const std::string& ip_address,
130 const std::map<std::string, std::string>& options,
131 const TestICMPCallback& callback) {
132 base::ThreadTaskRunnerHandle::Get()->PostTask(
133 FROM_HERE, base::Bind(callback, false, ""));
136 void FakeDebugDaemonClient::UploadCrashes() {
139 void FakeDebugDaemonClient::EnableDebuggingFeatures(
140 const std::string& password,
141 const DebugDaemonClient::EnableDebuggingCallback& callback) {
142 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
143 base::Bind(callback, true));
146 void FakeDebugDaemonClient::QueryDebuggingFeatures(
147 const DebugDaemonClient::QueryDevFeaturesCallback& callback) {
148 bool supported = base::CommandLine::ForCurrentProcess()->HasSwitch(
149 chromeos::switches::kSystemDevMode);
150 base::ThreadTaskRunnerHandle::Get()->PostTask(
151 FROM_HERE,
152 base::Bind(
153 callback, true,
154 static_cast<int>(
155 supported ? featues_mask_
156 : debugd::DevFeatureFlag::DEV_FEATURES_DISABLED)));
159 void FakeDebugDaemonClient::RemoveRootfsVerification(
160 const DebugDaemonClient::EnableDebuggingCallback& callback) {
161 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
162 base::Bind(callback, true));
165 void FakeDebugDaemonClient::WaitForServiceToBeAvailable(
166 const WaitForServiceToBeAvailableCallback& callback) {
167 if (service_is_available_) {
168 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
169 base::Bind(callback, true));
170 } else {
171 pending_wait_for_service_to_be_available_callbacks_.push_back(callback);
175 void FakeDebugDaemonClient::SetDebuggingFeaturesStatus(int featues_mask) {
176 featues_mask_ = featues_mask;
179 void FakeDebugDaemonClient::SetServiceIsAvailable(bool is_available) {
180 service_is_available_ = is_available;
181 if (!is_available)
182 return;
184 std::vector<WaitForServiceToBeAvailableCallback> callbacks;
185 callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
186 for (size_t i = 0; i < callbacks.size(); ++i)
187 callbacks[i].Run(is_available);
190 } // namespace chromeos