| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 virtual void ProposeScan(const dbus::ObjectPath& device_path, | 58 virtual void ProposeScan(const dbus::ObjectPath& device_path, |
| 59 const VoidDBusMethodCallback& callback) OVERRIDE { | 59 const VoidDBusMethodCallback& callback) OVERRIDE { |
| 60 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, | 60 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, |
| 61 flimflam::kProposeScanFunction); | 61 flimflam::kProposeScanFunction); |
| 62 GetHelper(device_path)->CallVoidMethod(&method_call, callback); | 62 GetHelper(device_path)->CallVoidMethod(&method_call, callback); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void SetProperty(const dbus::ObjectPath& device_path, | 65 virtual void SetProperty(const dbus::ObjectPath& device_path, |
| 66 const std::string& name, | 66 const std::string& name, |
| 67 const base::Value& value, | 67 const base::Value& value, |
| 68 const VoidDBusMethodCallback& callback) OVERRIDE { | 68 const base::Closure& callback, |
| 69 const ErrorCallback& error_callback) OVERRIDE { |
| 69 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, | 70 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, |
| 70 flimflam::kSetPropertyFunction); | 71 flimflam::kSetPropertyFunction); |
| 71 dbus::MessageWriter writer(&method_call); | 72 dbus::MessageWriter writer(&method_call); |
| 72 writer.AppendString(name); | 73 writer.AppendString(name); |
| 73 ShillClientHelper::AppendValueDataAsVariant(&writer, value); | 74 ShillClientHelper::AppendValueDataAsVariant(&writer, value); |
| 74 GetHelper(device_path)->CallVoidMethod(&method_call, callback); | 75 GetHelper(device_path)->CallVoidMethodWithErrorCallback(&method_call, |
| 76 callback, |
| 77 error_callback); |
| 75 } | 78 } |
| 76 | 79 |
| 77 virtual void ClearProperty(const dbus::ObjectPath& device_path, | 80 virtual void ClearProperty(const dbus::ObjectPath& device_path, |
| 78 const std::string& name, | 81 const std::string& name, |
| 79 const VoidDBusMethodCallback& callback) OVERRIDE { | 82 const VoidDBusMethodCallback& callback) OVERRIDE { |
| 80 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, | 83 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, |
| 81 flimflam::kClearPropertyFunction); | 84 flimflam::kClearPropertyFunction); |
| 82 dbus::MessageWriter writer(&method_call); | 85 dbus::MessageWriter writer(&method_call); |
| 83 writer.AppendString(name); | 86 writer.AppendString(name); |
| 84 GetHelper(device_path)->CallVoidMethod(&method_call, callback); | 87 GetHelper(device_path)->CallVoidMethod(&method_call, callback); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 // ShillProfileClient override. | 278 // ShillProfileClient override. |
| 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 // ShillDeviceClient override. | 284 // ShillDeviceClient override. |
| 282 virtual void SetProperty(const dbus::ObjectPath& device_path, | 285 virtual void SetProperty(const dbus::ObjectPath& device_path, |
| 283 const std::string& name, | 286 const std::string& name, |
| 284 const base::Value& value, | 287 const base::Value& value, |
| 285 const VoidDBusMethodCallback& callback) OVERRIDE { | 288 const base::Closure& callback, |
| 289 const ErrorCallback& error_callback) OVERRIDE { |
| 286 base::DictionaryValue* device_properties = NULL; | 290 base::DictionaryValue* device_properties = NULL; |
| 287 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { | 291 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { |
| 288 PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE); | 292 std::string error_name("org.chromium.flimflam.Error.Failure"); |
| 293 std::string error_message("Failed"); |
| 294 MessageLoop::current()->PostTask(FROM_HERE, |
| 295 base::Bind(error_callback, |
| 296 error_name, |
| 297 error_message)); |
| 289 return; | 298 return; |
| 290 } | 299 } |
| 291 device_properties->Set(name, value.DeepCopy()); | 300 device_properties->Set(name, value.DeepCopy()); |
| 292 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); | 301 MessageLoop::current()->PostTask(FROM_HERE, callback); |
| 293 } | 302 } |
| 294 | 303 |
| 295 // ShillDeviceClient override. | 304 // ShillDeviceClient override. |
| 296 virtual void ClearProperty(const dbus::ObjectPath& device_path, | 305 virtual void ClearProperty(const dbus::ObjectPath& device_path, |
| 297 const std::string& name, | 306 const std::string& name, |
| 298 const VoidDBusMethodCallback& callback) OVERRIDE { | 307 const VoidDBusMethodCallback& callback) OVERRIDE { |
| 299 base::DictionaryValue* device_properties = NULL; | 308 base::DictionaryValue* device_properties = NULL; |
| 300 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { | 309 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { |
| 301 PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE); | 310 PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE); |
| 302 return; | 311 return; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 ShillDeviceClient* ShillDeviceClient::Create( | 422 ShillDeviceClient* ShillDeviceClient::Create( |
| 414 DBusClientImplementationType type, | 423 DBusClientImplementationType type, |
| 415 dbus::Bus* bus) { | 424 dbus::Bus* bus) { |
| 416 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 425 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 417 return new ShillDeviceClientImpl(bus); | 426 return new ShillDeviceClientImpl(bus); |
| 418 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 427 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 419 return new ShillDeviceClientStubImpl(); | 428 return new ShillDeviceClientStubImpl(); |
| 420 } | 429 } |
| 421 | 430 |
| 422 } // namespace chromeos | 431 } // namespace chromeos |
| OLD | NEW |