| 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/flimflam_client_helper.h" | 5 #include "chromeos/dbus/flimflam_client_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "dbus/message.h" | 9 #include "dbus/message.h" |
| 10 #include "dbus/object_proxy.h" | 10 #include "dbus/object_proxy.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 void FlimflamClientHelper::CallDictionaryValueMethod( | 64 void FlimflamClientHelper::CallDictionaryValueMethod( |
| 65 dbus::MethodCall* method_call, | 65 dbus::MethodCall* method_call, |
| 66 const DictionaryValueCallback& callback) { | 66 const DictionaryValueCallback& callback) { |
| 67 proxy_->CallMethod(method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 67 proxy_->CallMethod(method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 68 base::Bind(&FlimflamClientHelper::OnDictionaryValueMethod, | 68 base::Bind(&FlimflamClientHelper::OnDictionaryValueMethod, |
| 69 weak_ptr_factory_.GetWeakPtr(), | 69 weak_ptr_factory_.GetWeakPtr(), |
| 70 callback)); | 70 callback)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 dbus::ObjectPath FlimflamClientHelper::CallObjectPathMethodAndBlock( |
| 74 dbus::MethodCall* method_call) { |
| 75 scoped_ptr<dbus::Response> response( |
| 76 blocking_method_caller_.CallMethodAndBlock(method_call)); |
| 77 if (!response.get()) |
| 78 return dbus::ObjectPath(); |
| 79 |
| 80 dbus::MessageReader reader(response.get()); |
| 81 dbus::ObjectPath result; |
| 82 if (!reader.PopObjectPath(&result)) |
| 83 return dbus::ObjectPath(); |
| 84 |
| 85 return result; |
| 86 } |
| 87 |
| 73 base::DictionaryValue* FlimflamClientHelper::CallDictionaryValueMethodAndBlock( | 88 base::DictionaryValue* FlimflamClientHelper::CallDictionaryValueMethodAndBlock( |
| 74 dbus::MethodCall* method_call) { | 89 dbus::MethodCall* method_call) { |
| 75 scoped_ptr<dbus::Response> response( | 90 scoped_ptr<dbus::Response> response( |
| 76 blocking_method_caller_.CallMethodAndBlock(method_call)); | 91 blocking_method_caller_.CallMethodAndBlock(method_call)); |
| 77 if (!response.get()) | 92 if (!response.get()) |
| 78 return NULL; | 93 return NULL; |
| 79 | 94 |
| 80 dbus::MessageReader reader(response.get()); | 95 dbus::MessageReader reader(response.get()); |
| 81 base::Value* value = dbus::PopDataAsValue(&reader); | 96 base::Value* value = dbus::PopDataAsValue(&reader); |
| 82 base::DictionaryValue* result = NULL; | 97 base::DictionaryValue* result = NULL; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 base::DictionaryValue* result = NULL; | 203 base::DictionaryValue* result = NULL; |
| 189 if (!value.get() || !value->GetAsDictionary(&result)) { | 204 if (!value.get() || !value->GetAsDictionary(&result)) { |
| 190 base::DictionaryValue result; | 205 base::DictionaryValue result; |
| 191 callback.Run(DBUS_METHOD_CALL_FAILURE, result); | 206 callback.Run(DBUS_METHOD_CALL_FAILURE, result); |
| 192 return; | 207 return; |
| 193 } | 208 } |
| 194 callback.Run(DBUS_METHOD_CALL_SUCCESS, *result); | 209 callback.Run(DBUS_METHOD_CALL_SUCCESS, *result); |
| 195 } | 210 } |
| 196 | 211 |
| 197 } // namespace chromeos | 212 } // namespace chromeos |
| OLD | NEW |