| 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_service_client.h" | 5 #include "chromeos/dbus/flimflam_service_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/chromeos/chromeos_version.h" | 8 #include "base/chromeos/chromeos_version.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 virtual void ActivateCellularModem(const dbus::ObjectPath& service_path, | 99 virtual void ActivateCellularModem(const dbus::ObjectPath& service_path, |
| 100 const std::string& carrier, | 100 const std::string& carrier, |
| 101 const VoidCallback& callback) OVERRIDE { | 101 const VoidCallback& callback) OVERRIDE { |
| 102 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, | 102 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 103 flimflam::kActivateCellularModemFunction); | 103 flimflam::kActivateCellularModemFunction); |
| 104 dbus::MessageWriter writer(&method_call); | 104 dbus::MessageWriter writer(&method_call); |
| 105 writer.AppendString(carrier); | 105 writer.AppendString(carrier); |
| 106 GetHelper(service_path)->CallVoidMethod(&method_call, callback); | 106 GetHelper(service_path)->CallVoidMethod(&method_call, callback); |
| 107 } | 107 } |
| 108 | 108 |
| 109 // FlimflamServiceClient override. |
| 110 virtual bool CallActivateCellularModemAndBlock( |
| 111 const dbus::ObjectPath& service_path, |
| 112 const std::string& carrier) OVERRIDE { |
| 113 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 114 flimflam::kActivateCellularModemFunction); |
| 115 dbus::MessageWriter writer(&method_call); |
| 116 writer.AppendString(carrier); |
| 117 return GetHelper(service_path)->CallVoidMethodAndBlock(&method_call); |
| 118 } |
| 119 |
| 109 private: | 120 private: |
| 110 typedef std::map<std::string, FlimflamClientHelper*> HelperMap; | 121 typedef std::map<std::string, FlimflamClientHelper*> HelperMap; |
| 111 | 122 |
| 112 // Returns the corresponding FlimflamClientHelper for the profile. | 123 // Returns the corresponding FlimflamClientHelper for the profile. |
| 113 FlimflamClientHelper* GetHelper(const dbus::ObjectPath& service_path) { | 124 FlimflamClientHelper* GetHelper(const dbus::ObjectPath& service_path) { |
| 114 HelperMap::iterator it = helpers_.find(service_path.value()); | 125 HelperMap::iterator it = helpers_.find(service_path.value()); |
| 115 if (it != helpers_.end()) | 126 if (it != helpers_.end()) |
| 116 return it->second; | 127 return it->second; |
| 117 | 128 |
| 118 // There is no helper for the profile, create it. | 129 // There is no helper for the profile, create it. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 PostSuccessVoidCallback(callback); | 201 PostSuccessVoidCallback(callback); |
| 191 } | 202 } |
| 192 | 203 |
| 193 // FlimflamServiceClient override. | 204 // FlimflamServiceClient override. |
| 194 virtual void ActivateCellularModem(const dbus::ObjectPath& service_path, | 205 virtual void ActivateCellularModem(const dbus::ObjectPath& service_path, |
| 195 const std::string& carrier, | 206 const std::string& carrier, |
| 196 const VoidCallback& callback) OVERRIDE { | 207 const VoidCallback& callback) OVERRIDE { |
| 197 PostSuccessVoidCallback(callback); | 208 PostSuccessVoidCallback(callback); |
| 198 } | 209 } |
| 199 | 210 |
| 211 // FlimflamServiceClient override. |
| 212 virtual bool CallActivateCellularModemAndBlock( |
| 213 const dbus::ObjectPath& service_path, |
| 214 const std::string& carrier) OVERRIDE { |
| 215 return true; |
| 216 } |
| 217 |
| 200 private: | 218 private: |
| 201 void PassEmptyDictionaryValue(const DictionaryValueCallback& callback) const { | 219 void PassEmptyDictionaryValue(const DictionaryValueCallback& callback) const { |
| 202 base::DictionaryValue dictionary; | 220 base::DictionaryValue dictionary; |
| 203 callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary); | 221 callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary); |
| 204 } | 222 } |
| 205 | 223 |
| 206 // Posts a task to run a void callback with success status code. | 224 // Posts a task to run a void callback with success status code. |
| 207 void PostSuccessVoidCallback(const VoidCallback& callback) { | 225 void PostSuccessVoidCallback(const VoidCallback& callback) { |
| 208 MessageLoop::current()->PostTask(FROM_HERE, | 226 MessageLoop::current()->PostTask(FROM_HERE, |
| 209 base::Bind(callback, | 227 base::Bind(callback, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 225 FlimflamServiceClient* FlimflamServiceClient::Create( | 243 FlimflamServiceClient* FlimflamServiceClient::Create( |
| 226 DBusClientImplementationType type, | 244 DBusClientImplementationType type, |
| 227 dbus::Bus* bus) { | 245 dbus::Bus* bus) { |
| 228 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 246 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 229 return new FlimflamServiceClientImpl(bus); | 247 return new FlimflamServiceClientImpl(bus); |
| 230 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 248 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 231 return new FlimflamServiceClientStubImpl(); | 249 return new FlimflamServiceClientStubImpl(); |
| 232 } | 250 } |
| 233 | 251 |
| 234 } // namespace chromeos | 252 } // namespace chromeos |
| OLD | NEW |