Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chromeos / dbus / fake_debug_daemon_client.cc
blob56f0bb5dd5910229e1e2f88d99fbe5945340ac9e
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::GetPerfOutput(
84 uint32_t duration,
85 const GetPerfOutputCallback& callback) {
86 int status = 0;
87 std::vector<uint8> perf_data;
88 std::vector<uint8> perf_stat;
89 base::ThreadTaskRunnerHandle::Get()->PostTask(
90 FROM_HERE, base::Bind(callback, status, perf_data, perf_stat));
93 void FakeDebugDaemonClient::GetPerfOutput(
94 uint32_t duration,
95 const std::vector<std::string>& perf_args,
96 const GetPerfOutputCallback& callback) {
97 int status = 0;
98 std::vector<uint8> perf_data;
99 std::vector<uint8> perf_stat;
100 base::ThreadTaskRunnerHandle::Get()->PostTask(
101 FROM_HERE, base::Bind(callback, status, perf_data, perf_stat));
104 void FakeDebugDaemonClient::GetScrubbedLogs(const GetLogsCallback& callback) {
105 std::map<std::string, std::string> sample;
106 sample["Sample Scrubbed Log"] = "Your email address is xxxxxxxx";
107 base::ThreadTaskRunnerHandle::Get()->PostTask(
108 FROM_HERE, base::Bind(callback, false, sample));
111 void FakeDebugDaemonClient::GetAllLogs(const GetLogsCallback& callback) {
112 std::map<std::string, std::string> sample;
113 sample["Sample Log"] = "Your email address is abc@abc.com";
114 base::ThreadTaskRunnerHandle::Get()->PostTask(
115 FROM_HERE, base::Bind(callback, false, sample));
118 void FakeDebugDaemonClient::GetUserLogFiles(const GetLogsCallback& callback) {
119 std::map<std::string, std::string> user_logs;
120 user_logs["preferences"] = "Preferences";
121 user_logs["invalid_file"] = "Invalid File";
122 base::ThreadTaskRunnerHandle::Get()->PostTask(
123 FROM_HERE, base::Bind(callback, true, user_logs));
126 void FakeDebugDaemonClient::TestICMP(const std::string& ip_address,
127 const TestICMPCallback& callback) {
128 base::ThreadTaskRunnerHandle::Get()->PostTask(
129 FROM_HERE, base::Bind(callback, false, ""));
132 void FakeDebugDaemonClient::TestICMPWithOptions(
133 const std::string& ip_address,
134 const std::map<std::string, std::string>& options,
135 const TestICMPCallback& callback) {
136 base::ThreadTaskRunnerHandle::Get()->PostTask(
137 FROM_HERE, base::Bind(callback, false, ""));
140 void FakeDebugDaemonClient::UploadCrashes() {
143 void FakeDebugDaemonClient::EnableDebuggingFeatures(
144 const std::string& password,
145 const DebugDaemonClient::EnableDebuggingCallback& callback) {
146 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
147 base::Bind(callback, true));
150 void FakeDebugDaemonClient::QueryDebuggingFeatures(
151 const DebugDaemonClient::QueryDevFeaturesCallback& callback) {
152 bool supported = base::CommandLine::ForCurrentProcess()->HasSwitch(
153 chromeos::switches::kSystemDevMode);
154 base::ThreadTaskRunnerHandle::Get()->PostTask(
155 FROM_HERE,
156 base::Bind(
157 callback, true,
158 static_cast<int>(
159 supported ? featues_mask_
160 : debugd::DevFeatureFlag::DEV_FEATURES_DISABLED)));
163 void FakeDebugDaemonClient::RemoveRootfsVerification(
164 const DebugDaemonClient::EnableDebuggingCallback& callback) {
165 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
166 base::Bind(callback, true));
169 void FakeDebugDaemonClient::WaitForServiceToBeAvailable(
170 const WaitForServiceToBeAvailableCallback& callback) {
171 if (service_is_available_) {
172 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
173 base::Bind(callback, true));
174 } else {
175 pending_wait_for_service_to_be_available_callbacks_.push_back(callback);
179 void FakeDebugDaemonClient::SetDebuggingFeaturesStatus(int featues_mask) {
180 featues_mask_ = featues_mask;
183 void FakeDebugDaemonClient::SetServiceIsAvailable(bool is_available) {
184 service_is_available_ = is_available;
185 if (!is_available)
186 return;
188 std::vector<WaitForServiceToBeAvailableCallback> callbacks;
189 callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
190 for (size_t i = 0; i < callbacks.size(); ++i)
191 callbacks[i].Run(is_available);
194 } // namespace chromeos