OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 const dbus::ObjectPath& device_path, | 85 const dbus::ObjectPath& device_path, |
86 const VoidDBusMethodCallback& callback) { | 86 const VoidDBusMethodCallback& callback) { |
87 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); | 87 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); |
88 } | 88 } |
89 | 89 |
90 void FakeShillDeviceClient::SetProperty(const dbus::ObjectPath& device_path, | 90 void FakeShillDeviceClient::SetProperty(const dbus::ObjectPath& device_path, |
91 const std::string& name, | 91 const std::string& name, |
92 const base::Value& value, | 92 const base::Value& value, |
93 const base::Closure& callback, | 93 const base::Closure& callback, |
94 const ErrorCallback& error_callback) { | 94 const ErrorCallback& error_callback) { |
| 95 VLOG(1) << "SetProperty: " << device_path.value() << " " << name << "=" |
| 96 << value; |
95 base::DictionaryValue* device_properties = NULL; | 97 base::DictionaryValue* device_properties = NULL; |
96 if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(), | 98 if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(), |
97 &device_properties)) { | 99 &device_properties)) { |
98 PostNotFoundError(error_callback); | 100 PostNotFoundError(error_callback); |
99 return; | 101 return; |
100 } | 102 } |
101 device_properties->SetWithoutPathExpansion(name, value.DeepCopy()); | 103 device_properties->SetWithoutPathExpansion(name, value.DeepCopy()); |
102 base::MessageLoop::current()->PostTask( | 104 base::MessageLoop::current()->PostTask( |
103 FROM_HERE, | 105 FROM_HERE, |
104 base::Bind(&FakeShillDeviceClient::NotifyObserversPropertyChanged, | 106 base::Bind(&FakeShillDeviceClient::NotifyObserversPropertyChanged, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 PostNotFoundError(error_callback); | 220 PostNotFoundError(error_callback); |
219 return; | 221 return; |
220 } | 222 } |
221 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 223 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
222 } | 224 } |
223 | 225 |
224 void FakeShillDeviceClient::SetCarrier(const dbus::ObjectPath& device_path, | 226 void FakeShillDeviceClient::SetCarrier(const dbus::ObjectPath& device_path, |
225 const std::string& carrier, | 227 const std::string& carrier, |
226 const base::Closure& callback, | 228 const base::Closure& callback, |
227 const ErrorCallback& error_callback) { | 229 const ErrorCallback& error_callback) { |
228 if (!stub_devices_.HasKey(device_path.value())) { | 230 SetProperty(device_path, shill::kCarrierProperty, base::StringValue(carrier), |
229 PostNotFoundError(error_callback); | 231 callback, error_callback); |
230 return; | |
231 } | |
232 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | |
233 } | 232 } |
234 | 233 |
235 void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path, | 234 void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path, |
236 const base::Closure& callback, | 235 const base::Closure& callback, |
237 const ErrorCallback& error_callback) { | 236 const ErrorCallback& error_callback) { |
238 if (!stub_devices_.HasKey(device_path.value())) { | 237 if (!stub_devices_.HasKey(device_path.value())) { |
239 PostNotFoundError(error_callback); | 238 PostNotFoundError(error_callback); |
240 return; | 239 return; |
241 } | 240 } |
242 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 241 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = | 471 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = |
473 observer_list_.find(device_path); | 472 observer_list_.find(device_path); |
474 if (iter != observer_list_.end()) | 473 if (iter != observer_list_.end()) |
475 return *(iter->second); | 474 return *(iter->second); |
476 PropertyObserverList* observer_list = new PropertyObserverList(); | 475 PropertyObserverList* observer_list = new PropertyObserverList(); |
477 observer_list_[device_path] = observer_list; | 476 observer_list_[device_path] = observer_list; |
478 return *observer_list; | 477 return *observer_list; |
479 } | 478 } |
480 | 479 |
481 } // namespace chromeos | 480 } // namespace chromeos |
OLD | NEW |