Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: chromeos/dbus/flimflam_service_client.cc

Issue 10134028: Reimplement ActivateCellularModem without Libcros (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add crosbug.com URLs to TODO comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 virtual void ActivateCellularModem(const dbus::ObjectPath& service_path, 101 virtual void ActivateCellularModem(const dbus::ObjectPath& service_path,
102 const std::string& carrier, 102 const std::string& carrier,
103 const VoidCallback& callback) OVERRIDE { 103 const VoidCallback& callback) OVERRIDE {
104 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, 104 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
105 flimflam::kActivateCellularModemFunction); 105 flimflam::kActivateCellularModemFunction);
106 dbus::MessageWriter writer(&method_call); 106 dbus::MessageWriter writer(&method_call);
107 writer.AppendString(carrier); 107 writer.AppendString(carrier);
108 GetHelper(service_path)->CallVoidMethod(&method_call, callback); 108 GetHelper(service_path)->CallVoidMethod(&method_call, callback);
109 } 109 }
110 110
111 // FlimflamServiceClient override.
112 virtual bool CallActivateCellularModemAndBlock(
113 const dbus::ObjectPath& service_path,
114 const std::string& carrier) OVERRIDE {
115 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
116 flimflam::kActivateCellularModemFunction);
117 dbus::MessageWriter writer(&method_call);
118 writer.AppendString(carrier);
119 return GetHelper(service_path)->CallVoidMethodAndBlock(&method_call);
120 }
121
111 private: 122 private:
112 typedef std::map<std::string, FlimflamClientHelper*> HelperMap; 123 typedef std::map<std::string, FlimflamClientHelper*> HelperMap;
113 124
114 // Returns the corresponding FlimflamClientHelper for the profile. 125 // Returns the corresponding FlimflamClientHelper for the profile.
115 FlimflamClientHelper* GetHelper(const dbus::ObjectPath& service_path) { 126 FlimflamClientHelper* GetHelper(const dbus::ObjectPath& service_path) {
116 HelperMap::iterator it = helpers_.find(service_path.value()); 127 HelperMap::iterator it = helpers_.find(service_path.value());
117 if (it != helpers_.end()) 128 if (it != helpers_.end())
118 return it->second; 129 return it->second;
119 130
120 // There is no helper for the profile, create it. 131 // There is no helper for the profile, create it.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 PostSuccessVoidCallback(callback); 204 PostSuccessVoidCallback(callback);
194 } 205 }
195 206
196 // FlimflamServiceClient override. 207 // FlimflamServiceClient override.
197 virtual void ActivateCellularModem(const dbus::ObjectPath& service_path, 208 virtual void ActivateCellularModem(const dbus::ObjectPath& service_path,
198 const std::string& carrier, 209 const std::string& carrier,
199 const VoidCallback& callback) OVERRIDE { 210 const VoidCallback& callback) OVERRIDE {
200 PostSuccessVoidCallback(callback); 211 PostSuccessVoidCallback(callback);
201 } 212 }
202 213
214 // FlimflamServiceClient override.
215 virtual bool CallActivateCellularModemAndBlock(
216 const dbus::ObjectPath& service_path,
217 const std::string& carrier) OVERRIDE {
218 return true;
219 }
220
203 private: 221 private:
204 void PassEmptyDictionaryValue(const DictionaryValueCallback& callback) const { 222 void PassEmptyDictionaryValue(const DictionaryValueCallback& callback) const {
205 base::DictionaryValue dictionary; 223 base::DictionaryValue dictionary;
206 callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary); 224 callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary);
207 } 225 }
208 226
209 // Posts a task to run a void callback with success status code. 227 // Posts a task to run a void callback with success status code.
210 void PostSuccessVoidCallback(const VoidCallback& callback) { 228 void PostSuccessVoidCallback(const VoidCallback& callback) {
211 MessageLoop::current()->PostTask(FROM_HERE, 229 MessageLoop::current()->PostTask(FROM_HERE,
212 base::Bind(callback, 230 base::Bind(callback,
(...skipping 15 matching lines...) Expand all
228 FlimflamServiceClient* FlimflamServiceClient::Create( 246 FlimflamServiceClient* FlimflamServiceClient::Create(
229 DBusClientImplementationType type, 247 DBusClientImplementationType type,
230 dbus::Bus* bus) { 248 dbus::Bus* bus) {
231 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 249 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
232 return new FlimflamServiceClientImpl(bus); 250 return new FlimflamServiceClientImpl(bus);
233 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 251 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
234 return new FlimflamServiceClientStubImpl(); 252 return new FlimflamServiceClientStubImpl();
235 } 253 }
236 254
237 } // namespace chromeos 255 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/flimflam_service_client.h ('k') | chromeos/dbus/flimflam_service_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698