Don't preload rarely seen large images
[chromium-blink-merge.git] / chromeos / dbus / fake_debug_daemon_client.cc
blobe7f6ba418e8b34eed8a6bf6f4e674ce4bbd9d786
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::GetScrubbedLogs(const GetLogsCallback& callback) {
91 std::map<std::string, std::string> sample;
92 sample["Sample Scrubbed Log"] = "Your email address is xxxxxxxx";
93 base::ThreadTaskRunnerHandle::Get()->PostTask(
94 FROM_HERE, base::Bind(callback, false, sample));
97 void FakeDebugDaemonClient::GetAllLogs(const GetLogsCallback& callback) {
98 std::map<std::string, std::string> sample;
99 sample["Sample Log"] = "Your email address is abc@abc.com";
100 base::ThreadTaskRunnerHandle::Get()->PostTask(
101 FROM_HERE, base::Bind(callback, false, sample));
104 void FakeDebugDaemonClient::GetUserLogFiles(const GetLogsCallback& callback) {
105 std::map<std::string, std::string> user_logs;
106 user_logs["preferences"] = "Preferences";
107 user_logs["invalid_file"] = "Invalid File";
108 base::ThreadTaskRunnerHandle::Get()->PostTask(
109 FROM_HERE, base::Bind(callback, true, user_logs));
112 void FakeDebugDaemonClient::TestICMP(const std::string& ip_address,
113 const TestICMPCallback& callback) {
114 base::ThreadTaskRunnerHandle::Get()->PostTask(
115 FROM_HERE, base::Bind(callback, false, ""));
118 void FakeDebugDaemonClient::TestICMPWithOptions(
119 const std::string& ip_address,
120 const std::map<std::string, std::string>& options,
121 const TestICMPCallback& callback) {
122 base::ThreadTaskRunnerHandle::Get()->PostTask(
123 FROM_HERE, base::Bind(callback, false, ""));
126 void FakeDebugDaemonClient::UploadCrashes() {
129 void FakeDebugDaemonClient::EnableDebuggingFeatures(
130 const std::string& password,
131 const DebugDaemonClient::EnableDebuggingCallback& callback) {
132 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
133 base::Bind(callback, true));
136 void FakeDebugDaemonClient::QueryDebuggingFeatures(
137 const DebugDaemonClient::QueryDevFeaturesCallback& callback) {
138 bool supported = base::CommandLine::ForCurrentProcess()->HasSwitch(
139 chromeos::switches::kSystemDevMode);
140 base::ThreadTaskRunnerHandle::Get()->PostTask(
141 FROM_HERE,
142 base::Bind(
143 callback, true,
144 static_cast<int>(
145 supported ? featues_mask_
146 : debugd::DevFeatureFlag::DEV_FEATURES_DISABLED)));
149 void FakeDebugDaemonClient::RemoveRootfsVerification(
150 const DebugDaemonClient::EnableDebuggingCallback& callback) {
151 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
152 base::Bind(callback, true));
155 void FakeDebugDaemonClient::WaitForServiceToBeAvailable(
156 const WaitForServiceToBeAvailableCallback& callback) {
157 if (service_is_available_) {
158 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
159 base::Bind(callback, true));
160 } else {
161 pending_wait_for_service_to_be_available_callbacks_.push_back(callback);
165 void FakeDebugDaemonClient::SetDebuggingFeaturesStatus(int featues_mask) {
166 featues_mask_ = featues_mask;
169 void FakeDebugDaemonClient::SetServiceIsAvailable(bool is_available) {
170 service_is_available_ = is_available;
171 if (!is_available)
172 return;
174 std::vector<WaitForServiceToBeAvailableCallback> callbacks;
175 callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
176 for (size_t i = 0; i < callbacks.size(); ++i)
177 callbacks[i].Run(is_available);
180 } // namespace chromeos