| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shill_device_client.h" | 5 #include "chromeos/dbus/shill_device_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 virtual void ProposeScan(const dbus::ObjectPath& device_path, | 60 virtual void ProposeScan(const dbus::ObjectPath& device_path, |
| 61 const VoidDBusMethodCallback& callback) OVERRIDE { | 61 const VoidDBusMethodCallback& callback) OVERRIDE { |
| 62 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, | 62 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, |
| 63 flimflam::kProposeScanFunction); | 63 flimflam::kProposeScanFunction); |
| 64 GetHelper(device_path)->CallVoidMethod(&method_call, callback); | 64 GetHelper(device_path)->CallVoidMethod(&method_call, callback); |
| 65 } | 65 } |
| 66 | 66 |
| 67 virtual void SetProperty(const dbus::ObjectPath& device_path, | 67 virtual void SetProperty(const dbus::ObjectPath& device_path, |
| 68 const std::string& name, | 68 const std::string& name, |
| 69 const base::Value& value, | 69 const base::Value& value, |
| 70 const VoidDBusMethodCallback& callback) OVERRIDE { | 70 const base::Closure& callback, |
| 71 const ErrorCallback& error_callback) OVERRIDE { |
| 71 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, | 72 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, |
| 72 flimflam::kSetPropertyFunction); | 73 flimflam::kSetPropertyFunction); |
| 73 dbus::MessageWriter writer(&method_call); | 74 dbus::MessageWriter writer(&method_call); |
| 74 writer.AppendString(name); | 75 writer.AppendString(name); |
| 75 ShillClientHelper::AppendValueDataAsVariant(&writer, value); | 76 ShillClientHelper::AppendValueDataAsVariant(&writer, value); |
| 76 GetHelper(device_path)->CallVoidMethod(&method_call, callback); | 77 GetHelper(device_path)->CallVoidMethodWithErrorCallback(&method_call, |
| 78 callback, |
| 79 error_callback); |
| 77 } | 80 } |
| 78 | 81 |
| 79 virtual void ClearProperty(const dbus::ObjectPath& device_path, | 82 virtual void ClearProperty(const dbus::ObjectPath& device_path, |
| 80 const std::string& name, | 83 const std::string& name, |
| 81 const VoidDBusMethodCallback& callback) OVERRIDE { | 84 const VoidDBusMethodCallback& callback) OVERRIDE { |
| 82 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, | 85 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, |
| 83 flimflam::kClearPropertyFunction); | 86 flimflam::kClearPropertyFunction); |
| 84 dbus::MessageWriter writer(&method_call); | 87 dbus::MessageWriter writer(&method_call); |
| 85 writer.AppendString(name); | 88 writer.AppendString(name); |
| 86 GetHelper(device_path)->CallVoidMethod(&method_call, callback); | 89 GetHelper(device_path)->CallVoidMethod(&method_call, callback); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 277 } |
| 275 | 278 |
| 276 virtual void ProposeScan(const dbus::ObjectPath& device_path, | 279 virtual void ProposeScan(const dbus::ObjectPath& device_path, |
| 277 const VoidDBusMethodCallback& callback) OVERRIDE { | 280 const VoidDBusMethodCallback& callback) OVERRIDE { |
| 278 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); | 281 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); |
| 279 } | 282 } |
| 280 | 283 |
| 281 virtual void SetProperty(const dbus::ObjectPath& device_path, | 284 virtual void SetProperty(const dbus::ObjectPath& device_path, |
| 282 const std::string& name, | 285 const std::string& name, |
| 283 const base::Value& value, | 286 const base::Value& value, |
| 284 const VoidDBusMethodCallback& callback) OVERRIDE { | 287 const base::Closure& callback, |
| 288 const ErrorCallback& error_callback) OVERRIDE { |
| 285 base::DictionaryValue* device_properties = NULL; | 289 base::DictionaryValue* device_properties = NULL; |
| 286 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { | 290 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { |
| 287 PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE); | 291 std::string error_name("org.chromium.flimflam.Error.Failure"); |
| 292 std::string error_message("Failed"); |
| 293 MessageLoop::current()->PostTask(FROM_HERE, |
| 294 base::Bind(error_callback, |
| 295 error_name, |
| 296 error_message)); |
| 288 return; | 297 return; |
| 289 } | 298 } |
| 290 device_properties->Set(name, value.DeepCopy()); | 299 device_properties->Set(name, value.DeepCopy()); |
| 291 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); | 300 MessageLoop::current()->PostTask(FROM_HERE, callback); |
| 292 } | 301 } |
| 293 | 302 |
| 294 virtual void ClearProperty(const dbus::ObjectPath& device_path, | 303 virtual void ClearProperty(const dbus::ObjectPath& device_path, |
| 295 const std::string& name, | 304 const std::string& name, |
| 296 const VoidDBusMethodCallback& callback) OVERRIDE { | 305 const VoidDBusMethodCallback& callback) OVERRIDE { |
| 297 base::DictionaryValue* device_properties = NULL; | 306 base::DictionaryValue* device_properties = NULL; |
| 298 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { | 307 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { |
| 299 PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE); | 308 PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE); |
| 300 return; | 309 return; |
| 301 } | 310 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 ShillDeviceClient* ShillDeviceClient::Create( | 413 ShillDeviceClient* ShillDeviceClient::Create( |
| 405 DBusClientImplementationType type, | 414 DBusClientImplementationType type, |
| 406 dbus::Bus* bus) { | 415 dbus::Bus* bus) { |
| 407 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 416 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 408 return new ShillDeviceClientImpl(bus); | 417 return new ShillDeviceClientImpl(bus); |
| 409 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 418 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 410 return new ShillDeviceClientStubImpl(); | 419 return new ShillDeviceClientStubImpl(); |
| 411 } | 420 } |
| 412 | 421 |
| 413 } // namespace chromeos | 422 } // namespace chromeos |
| OLD | NEW |