Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: chromeos/dbus/fake_shill_device_client.cc

Issue 156353002: Implement networkingPrivate.setWifiTDLSEnabledState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable TDLS tests on non-chromeos Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/fake_shill_device_client.h ('k') | chromeos/dbus/fake_shill_manager_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/dbus/fake_shill_device_client.h" 5 #include "chromeos/dbus/fake_shill_device_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 14 matching lines...) Expand all
25 25
26 void ErrorFunction(const std::string& device_path, 26 void ErrorFunction(const std::string& device_path,
27 const std::string& error_name, 27 const std::string& error_name,
28 const std::string& error_message) { 28 const std::string& error_message) {
29 LOG(ERROR) << "Shill Error for: " << device_path 29 LOG(ERROR) << "Shill Error for: " << device_path
30 << ": " << error_name << " : " << error_message; 30 << ": " << error_name << " : " << error_message;
31 } 31 }
32 32
33 void PostDeviceNotFoundError( 33 void PostDeviceNotFoundError(
34 const ShillDeviceClient::ErrorCallback& error_callback) { 34 const ShillDeviceClient::ErrorCallback& error_callback) {
35 std::string error_name("org.chromium.flimflam.Error.Failure");
36 std::string error_message("Failed"); 35 std::string error_message("Failed");
37 base::MessageLoop::current()->PostTask( 36 base::MessageLoop::current()->PostTask(
38 FROM_HERE, base::Bind(error_callback, error_name, error_message)); 37 FROM_HERE,
38 base::Bind(error_callback, shill::kErrorResultNotFound, error_message));
39 } 39 }
40 40
41 } // namespace 41 } // namespace
42 42
43 FakeShillDeviceClient::FakeShillDeviceClient() : weak_ptr_factory_(this) { 43 FakeShillDeviceClient::FakeShillDeviceClient()
44 : tdls_busy_count_(0),
45 weak_ptr_factory_(this) {
44 } 46 }
45 47
46 FakeShillDeviceClient::~FakeShillDeviceClient() { 48 FakeShillDeviceClient::~FakeShillDeviceClient() {
47 STLDeleteContainerPairSecondPointers( 49 STLDeleteContainerPairSecondPointers(
48 observer_list_.begin(), observer_list_.end()); 50 observer_list_.begin(), observer_list_.end());
49 } 51 }
50 52
51 // ShillDeviceClient overrides. 53 // ShillDeviceClient overrides.
52 54
53 void FakeShillDeviceClient::Init(dbus::Bus* bus) {} 55 void FakeShillDeviceClient::Init(dbus::Bus* bus) {}
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path, 197 void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path,
196 const base::Closure& callback, 198 const base::Closure& callback,
197 const ErrorCallback& error_callback) { 199 const ErrorCallback& error_callback) {
198 if (!stub_devices_.HasKey(device_path.value())) { 200 if (!stub_devices_.HasKey(device_path.value())) {
199 PostDeviceNotFoundError(error_callback); 201 PostDeviceNotFoundError(error_callback);
200 return; 202 return;
201 } 203 }
202 base::MessageLoop::current()->PostTask(FROM_HERE, callback); 204 base::MessageLoop::current()->PostTask(FROM_HERE, callback);
203 } 205 }
204 206
207 void FakeShillDeviceClient::PerformTDLSOperation(
208 const dbus::ObjectPath& device_path,
209 const std::string& operation,
210 const std::string& peer,
211 const StringCallback& callback,
212 const ErrorCallback& error_callback) {
213 if (!stub_devices_.HasKey(device_path.value())) {
214 PostDeviceNotFoundError(error_callback);
215 return;
216 }
217 if (tdls_busy_count_) {
218 --tdls_busy_count_;
219 std::string error_message("In-Progress");
220 base::MessageLoop::current()->PostTask(
221 FROM_HERE,
222 base::Bind(error_callback,
223 shill::kErrorResultInProgress, error_message));
224 return;
225 }
226 std::string result;
227 if (operation == shill::kTDLSStatusOperation)
228 result = shill::kTDLSConnectedState;
229 base::MessageLoop::current()->PostTask(FROM_HERE,
230 base::Bind(callback, result));
231 }
232
205 ShillDeviceClient::TestInterface* FakeShillDeviceClient::GetTestInterface() { 233 ShillDeviceClient::TestInterface* FakeShillDeviceClient::GetTestInterface() {
206 return this; 234 return this;
207 } 235 }
208 236
209 // ShillDeviceClient::TestInterface overrides. 237 // ShillDeviceClient::TestInterface overrides.
210 238
211 void FakeShillDeviceClient::AddDevice(const std::string& device_path, 239 void FakeShillDeviceClient::AddDevice(const std::string& device_path,
212 const std::string& type, 240 const std::string& type,
213 const std::string& object_path) { 241 const std::string& object_path) {
214 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 242 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = 354 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter =
327 observer_list_.find(device_path); 355 observer_list_.find(device_path);
328 if (iter != observer_list_.end()) 356 if (iter != observer_list_.end())
329 return *(iter->second); 357 return *(iter->second);
330 PropertyObserverList* observer_list = new PropertyObserverList(); 358 PropertyObserverList* observer_list = new PropertyObserverList();
331 observer_list_[device_path] = observer_list; 359 observer_list_[device_path] = observer_list;
332 return *observer_list; 360 return *observer_list;
333 } 361 }
334 362
335 } // namespace chromeos 363 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_shill_device_client.h ('k') | chromeos/dbus/fake_shill_manager_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698