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

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

Issue 10915106: Renaming instances of "flimflam" with "shill", now that we're only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Upload after merge Created 8 years, 3 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
« no previous file with comments | « chromeos/dbus/shill_device_client.h ('k') | chromeos/dbus/shill_device_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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"
11 #include "dbus/bus.h" 11 #include "dbus/bus.h"
12 #include "dbus/message.h" 12 #include "dbus/message.h"
13 #include "dbus/object_path.h" 13 #include "dbus/object_path.h"
14 #include "dbus/object_proxy.h" 14 #include "dbus/object_proxy.h"
15 #include "dbus/values_util.h" 15 #include "dbus/values_util.h"
16 #include "third_party/cros_system_api/dbus/service_constants.h" 16 #include "third_party/cros_system_api/dbus/service_constants.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 namespace { 20 namespace {
21 21
22 // The FlimflamDeviceClient implementation. 22 // The ShillDeviceClient implementation.
23 class FlimflamDeviceClientImpl : public FlimflamDeviceClient { 23 class ShillDeviceClientImpl : public ShillDeviceClient {
24 public: 24 public:
25 explicit FlimflamDeviceClientImpl(dbus::Bus* bus) 25 explicit ShillDeviceClientImpl(dbus::Bus* bus)
26 : bus_(bus), 26 : bus_(bus),
27 helpers_deleter_(&helpers_) { 27 helpers_deleter_(&helpers_) {
28 } 28 }
29 29
30 /////////////////////////////////////// 30 ///////////////////////////////////////
31 // FlimflamDeviceClient overrides. 31 // ShillDeviceClient overrides.
32 virtual void SetPropertyChangedHandler( 32 virtual void SetPropertyChangedHandler(
33 const dbus::ObjectPath& device_path, 33 const dbus::ObjectPath& device_path,
34 const PropertyChangedHandler& handler) OVERRIDE { 34 const PropertyChangedHandler& handler) OVERRIDE {
35 GetHelper(device_path)->SetPropertyChangedHandler(handler); 35 GetHelper(device_path)->SetPropertyChangedHandler(handler);
36 } 36 }
37 37
38 virtual void ResetPropertyChangedHandler( 38 virtual void ResetPropertyChangedHandler(
39 const dbus::ObjectPath& device_path) OVERRIDE { 39 const dbus::ObjectPath& device_path) OVERRIDE {
40 GetHelper(device_path)->ResetPropertyChangedHandler(); 40 GetHelper(device_path)->ResetPropertyChangedHandler();
41 } 41 }
(...skipping 21 matching lines...) Expand all
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 VoidDBusMethodCallback& callback) OVERRIDE {
69 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, 69 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface,
70 flimflam::kSetPropertyFunction); 70 flimflam::kSetPropertyFunction);
71 dbus::MessageWriter writer(&method_call); 71 dbus::MessageWriter writer(&method_call);
72 writer.AppendString(name); 72 writer.AppendString(name);
73 FlimflamClientHelper::AppendValueDataAsVariant(&writer, value); 73 ShillClientHelper::AppendValueDataAsVariant(&writer, value);
74 GetHelper(device_path)->CallVoidMethod(&method_call, callback); 74 GetHelper(device_path)->CallVoidMethod(&method_call, callback);
75 } 75 }
76 76
77 virtual void ClearProperty(const dbus::ObjectPath& device_path, 77 virtual void ClearProperty(const dbus::ObjectPath& device_path,
78 const std::string& name, 78 const std::string& name,
79 const VoidDBusMethodCallback& callback) OVERRIDE { 79 const VoidDBusMethodCallback& callback) OVERRIDE {
80 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, 80 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface,
81 flimflam::kClearPropertyFunction); 81 flimflam::kClearPropertyFunction);
82 dbus::MessageWriter writer(&method_call); 82 dbus::MessageWriter writer(&method_call);
83 writer.AppendString(name); 83 writer.AppendString(name);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 const ErrorCallback& error_callback) OVERRIDE { 165 const ErrorCallback& error_callback) OVERRIDE {
166 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, 166 dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface,
167 flimflam::kRegisterFunction); 167 flimflam::kRegisterFunction);
168 dbus::MessageWriter writer(&method_call); 168 dbus::MessageWriter writer(&method_call);
169 writer.AppendString(network_id); 169 writer.AppendString(network_id);
170 GetHelper(device_path)->CallVoidMethodWithErrorCallback( 170 GetHelper(device_path)->CallVoidMethodWithErrorCallback(
171 &method_call, callback, error_callback); 171 &method_call, callback, error_callback);
172 } 172 }
173 173
174 private: 174 private:
175 typedef std::map<std::string, FlimflamClientHelper*> HelperMap; 175 typedef std::map<std::string, ShillClientHelper*> HelperMap;
176 176
177 // Returns the corresponding FlimflamClientHelper for the profile. 177 // Returns the corresponding ShillClientHelper for the profile.
178 FlimflamClientHelper* GetHelper(const dbus::ObjectPath& device_path) { 178 ShillClientHelper* GetHelper(const dbus::ObjectPath& device_path) {
179 HelperMap::iterator it = helpers_.find(device_path.value()); 179 HelperMap::iterator it = helpers_.find(device_path.value());
180 if (it != helpers_.end()) 180 if (it != helpers_.end())
181 return it->second; 181 return it->second;
182 182
183 // There is no helper for the profile, create it. 183 // There is no helper for the profile, create it.
184 dbus::ObjectProxy* object_proxy = 184 dbus::ObjectProxy* object_proxy =
185 bus_->GetObjectProxy(flimflam::kFlimflamServiceName, device_path); 185 bus_->GetObjectProxy(flimflam::kFlimflamServiceName, device_path);
186 FlimflamClientHelper* helper = new FlimflamClientHelper(bus_, object_proxy); 186 ShillClientHelper* helper = new ShillClientHelper(bus_, object_proxy);
187 helper->MonitorPropertyChanged(flimflam::kFlimflamDeviceInterface); 187 helper->MonitorPropertyChanged(flimflam::kFlimflamDeviceInterface);
188 helpers_.insert(HelperMap::value_type(device_path.value(), helper)); 188 helpers_.insert(HelperMap::value_type(device_path.value(), helper));
189 return helper; 189 return helper;
190 } 190 }
191 191
192 dbus::Bus* bus_; 192 dbus::Bus* bus_;
193 HelperMap helpers_; 193 HelperMap helpers_;
194 STLValueDeleter<HelperMap> helpers_deleter_; 194 STLValueDeleter<HelperMap> helpers_deleter_;
195 195
196 DISALLOW_COPY_AND_ASSIGN(FlimflamDeviceClientImpl); 196 DISALLOW_COPY_AND_ASSIGN(ShillDeviceClientImpl);
197 }; 197 };
198 198
199 // A stub implementation of FlimflamDeviceClient. 199 // A stub implementation of ShillDeviceClient.
200 // Implemented: Stub cellular device for SMS testing. 200 // Implemented: Stub cellular device for SMS testing.
201 class FlimflamDeviceClientStubImpl : public FlimflamDeviceClient { 201 class ShillDeviceClientStubImpl : public ShillDeviceClient {
202 public: 202 public:
203 FlimflamDeviceClientStubImpl() : weak_ptr_factory_(this) { 203 ShillDeviceClientStubImpl() : weak_ptr_factory_(this) {
204 // Add a cellular device for SMS. Note: name matches Manager entry. 204 // Add a cellular device for SMS. Note: name matches Manager entry.
205 const char kStubCellular1[] = "stub_cellular1"; 205 const char kStubCellular1[] = "stub_cellular1";
206 base::DictionaryValue* cellular_properties = new base::DictionaryValue; 206 base::DictionaryValue* cellular_properties = new base::DictionaryValue;
207 cellular_properties->SetWithoutPathExpansion( 207 cellular_properties->SetWithoutPathExpansion(
208 flimflam::kTypeProperty, 208 flimflam::kTypeProperty,
209 base::Value::CreateStringValue(flimflam::kTypeCellular)); 209 base::Value::CreateStringValue(flimflam::kTypeCellular));
210 cellular_properties->SetWithoutPathExpansion( 210 cellular_properties->SetWithoutPathExpansion(
211 flimflam::kDBusConnectionProperty, 211 flimflam::kDBusConnectionProperty,
212 base::Value::CreateStringValue("/stub")); 212 base::Value::CreateStringValue("/stub"));
213 cellular_properties->SetWithoutPathExpansion( 213 cellular_properties->SetWithoutPathExpansion(
(...skipping 12 matching lines...) Expand all
226 cellular_properties->SetWithoutPathExpansion( 226 cellular_properties->SetWithoutPathExpansion(
227 flimflam::kDBusConnectionProperty, 227 flimflam::kDBusConnectionProperty,
228 base::Value::CreateStringValue(":stub.0")); 228 base::Value::CreateStringValue(":stub.0"));
229 cellular_properties->SetWithoutPathExpansion( 229 cellular_properties->SetWithoutPathExpansion(
230 flimflam::kDBusObjectProperty, 230 flimflam::kDBusObjectProperty,
231 base::Value::CreateStringValue( 231 base::Value::CreateStringValue(
232 "/org/freedesktop/ModemManager1/stub/0")); 232 "/org/freedesktop/ModemManager1/stub/0"));
233 stub_devices_.Set(kStubCellular2, cellular_properties); 233 stub_devices_.Set(kStubCellular2, cellular_properties);
234 } 234 }
235 235
236 virtual ~FlimflamDeviceClientStubImpl() {} 236 virtual ~ShillDeviceClientStubImpl() {}
237 237
238 // FlimflamDeviceClient override. 238 // ShillDeviceClient override.
239 virtual void SetPropertyChangedHandler( 239 virtual void SetPropertyChangedHandler(
240 const dbus::ObjectPath& device_path, 240 const dbus::ObjectPath& device_path,
241 const PropertyChangedHandler& handler) OVERRIDE {} 241 const PropertyChangedHandler& handler) OVERRIDE {}
242 242
243 // FlimflamDeviceClient override. 243 // ShillDeviceClient override.
244 virtual void ResetPropertyChangedHandler( 244 virtual void ResetPropertyChangedHandler(
245 const dbus::ObjectPath& device_path) OVERRIDE {} 245 const dbus::ObjectPath& device_path) OVERRIDE {}
246 246
247 // FlimflamDeviceClient override. 247 // ShillDeviceClient override.
248 virtual void GetProperties(const dbus::ObjectPath& device_path, 248 virtual void GetProperties(const dbus::ObjectPath& device_path,
249 const DictionaryValueCallback& callback) OVERRIDE { 249 const DictionaryValueCallback& callback) OVERRIDE {
250 MessageLoop::current()->PostTask( 250 MessageLoop::current()->PostTask(
251 FROM_HERE, 251 FROM_HERE,
252 base::Bind(&FlimflamDeviceClientStubImpl::PassStubDevicePrperties, 252 base::Bind(&ShillDeviceClientStubImpl::PassStubDevicePrperties,
253 weak_ptr_factory_.GetWeakPtr(), 253 weak_ptr_factory_.GetWeakPtr(),
254 device_path, callback)); 254 device_path, callback));
255 } 255 }
256 256
257 // FlimflamDeviceClient override. 257 // ShillDeviceClient override.
258 virtual base::DictionaryValue* CallGetPropertiesAndBlock( 258 virtual base::DictionaryValue* CallGetPropertiesAndBlock(
259 const dbus::ObjectPath& device_path) OVERRIDE { 259 const dbus::ObjectPath& device_path) OVERRIDE {
260 return new base::DictionaryValue; 260 return new base::DictionaryValue;
261 } 261 }
262 262
263 // FlimflamProfileClient override. 263 // ShillProfileClient override.
264 virtual void ProposeScan(const dbus::ObjectPath& device_path, 264 virtual void ProposeScan(const dbus::ObjectPath& device_path,
265 const VoidDBusMethodCallback& callback) OVERRIDE { 265 const VoidDBusMethodCallback& callback) OVERRIDE {
266 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); 266 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS);
267 } 267 }
268 268
269 // FlimflamDeviceClient override. 269 // ShillDeviceClient override.
270 virtual void SetProperty(const dbus::ObjectPath& device_path, 270 virtual void SetProperty(const dbus::ObjectPath& device_path,
271 const std::string& name, 271 const std::string& name,
272 const base::Value& value, 272 const base::Value& value,
273 const VoidDBusMethodCallback& callback) OVERRIDE { 273 const VoidDBusMethodCallback& callback) OVERRIDE {
274 base::DictionaryValue* device_properties = NULL; 274 base::DictionaryValue* device_properties = NULL;
275 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { 275 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) {
276 PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE); 276 PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE);
277 return; 277 return;
278 } 278 }
279 device_properties->Set(name, value.DeepCopy()); 279 device_properties->Set(name, value.DeepCopy());
280 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); 280 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS);
281 } 281 }
282 282
283 // FlimflamDeviceClient override. 283 // ShillDeviceClient override.
284 virtual void ClearProperty(const dbus::ObjectPath& device_path, 284 virtual void ClearProperty(const dbus::ObjectPath& device_path,
285 const std::string& name, 285 const std::string& name,
286 const VoidDBusMethodCallback& callback) OVERRIDE { 286 const VoidDBusMethodCallback& callback) OVERRIDE {
287 base::DictionaryValue* device_properties = NULL; 287 base::DictionaryValue* device_properties = NULL;
288 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { 288 if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) {
289 PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE); 289 PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE);
290 return; 290 return;
291 } 291 }
292 device_properties->Remove(name, NULL); 292 device_properties->Remove(name, NULL);
293 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); 293 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS);
294 } 294 }
295 295
296 // FlimflamDeviceClient override. 296 // ShillDeviceClient override.
297 virtual void AddIPConfig( 297 virtual void AddIPConfig(
298 const dbus::ObjectPath& device_path, 298 const dbus::ObjectPath& device_path,
299 const std::string& method, 299 const std::string& method,
300 const ObjectPathDBusMethodCallback& callback) OVERRIDE { 300 const ObjectPathDBusMethodCallback& callback) OVERRIDE {
301 MessageLoop::current()->PostTask(FROM_HERE, 301 MessageLoop::current()->PostTask(FROM_HERE,
302 base::Bind(callback, 302 base::Bind(callback,
303 DBUS_METHOD_CALL_SUCCESS, 303 DBUS_METHOD_CALL_SUCCESS,
304 dbus::ObjectPath())); 304 dbus::ObjectPath()));
305 } 305 }
306 306
307 // FlimflamDeviceClient override. 307 // ShillDeviceClient override.
308 virtual dbus::ObjectPath CallAddIPConfigAndBlock( 308 virtual dbus::ObjectPath CallAddIPConfigAndBlock(
309 const dbus::ObjectPath& device_path, 309 const dbus::ObjectPath& device_path,
310 const std::string& method) OVERRIDE { 310 const std::string& method) OVERRIDE {
311 return dbus::ObjectPath(); 311 return dbus::ObjectPath();
312 } 312 }
313 313
314 // FlimflamDeviceClient override. 314 // ShillDeviceClient override.
315 virtual void RequirePin(const dbus::ObjectPath& device_path, 315 virtual void RequirePin(const dbus::ObjectPath& device_path,
316 const std::string& pin, 316 const std::string& pin,
317 bool require, 317 bool require,
318 const base::Closure& callback, 318 const base::Closure& callback,
319 const ErrorCallback& error_callback) OVERRIDE { 319 const ErrorCallback& error_callback) OVERRIDE {
320 MessageLoop::current()->PostTask(FROM_HERE, callback); 320 MessageLoop::current()->PostTask(FROM_HERE, callback);
321 } 321 }
322 322
323 // FlimflamDeviceClient override. 323 // ShillDeviceClient override.
324 virtual void EnterPin(const dbus::ObjectPath& device_path, 324 virtual void EnterPin(const dbus::ObjectPath& device_path,
325 const std::string& pin, 325 const std::string& pin,
326 const base::Closure& callback, 326 const base::Closure& callback,
327 const ErrorCallback& error_callback) OVERRIDE { 327 const ErrorCallback& error_callback) OVERRIDE {
328 MessageLoop::current()->PostTask(FROM_HERE, callback); 328 MessageLoop::current()->PostTask(FROM_HERE, callback);
329 } 329 }
330 330
331 // FlimflamDeviceClient override. 331 // ShillDeviceClient override.
332 virtual void UnblockPin(const dbus::ObjectPath& device_path, 332 virtual void UnblockPin(const dbus::ObjectPath& device_path,
333 const std::string& puk, 333 const std::string& puk,
334 const std::string& pin, 334 const std::string& pin,
335 const base::Closure& callback, 335 const base::Closure& callback,
336 const ErrorCallback& error_callback) OVERRIDE { 336 const ErrorCallback& error_callback) OVERRIDE {
337 MessageLoop::current()->PostTask(FROM_HERE, callback); 337 MessageLoop::current()->PostTask(FROM_HERE, callback);
338 } 338 }
339 339
340 // FlimflamDeviceClient override. 340 // ShillDeviceClient override.
341 virtual void ChangePin(const dbus::ObjectPath& device_path, 341 virtual void ChangePin(const dbus::ObjectPath& device_path,
342 const std::string& old_pin, 342 const std::string& old_pin,
343 const std::string& new_pin, 343 const std::string& new_pin,
344 const base::Closure& callback, 344 const base::Closure& callback,
345 const ErrorCallback& error_callback) OVERRIDE { 345 const ErrorCallback& error_callback) OVERRIDE {
346 MessageLoop::current()->PostTask(FROM_HERE, callback); 346 MessageLoop::current()->PostTask(FROM_HERE, callback);
347 } 347 }
348 348
349 // FlimflamDeviceClient override. 349 // ShillDeviceClient override.
350 virtual void Register(const dbus::ObjectPath& device_path, 350 virtual void Register(const dbus::ObjectPath& device_path,
351 const std::string& network_id, 351 const std::string& network_id,
352 const base::Closure& callback, 352 const base::Closure& callback,
353 const ErrorCallback& error_callback) OVERRIDE { 353 const ErrorCallback& error_callback) OVERRIDE {
354 MessageLoop::current()->PostTask(FROM_HERE, callback); 354 MessageLoop::current()->PostTask(FROM_HERE, callback);
355 } 355 }
356 356
357 private: 357 private:
358 void PassStubDevicePrperties(const dbus::ObjectPath& device_path, 358 void PassStubDevicePrperties(const dbus::ObjectPath& device_path,
359 const DictionaryValueCallback& callback) const { 359 const DictionaryValueCallback& callback) const {
(...skipping 11 matching lines...) Expand all
371 DBusMethodCallStatus status) { 371 DBusMethodCallStatus status) {
372 MessageLoop::current()->PostTask(FROM_HERE, 372 MessageLoop::current()->PostTask(FROM_HERE,
373 base::Bind(callback, status)); 373 base::Bind(callback, status));
374 } 374 }
375 375
376 // Dictionary of <device_name, Dictionary>. 376 // Dictionary of <device_name, Dictionary>.
377 base::DictionaryValue stub_devices_; 377 base::DictionaryValue stub_devices_;
378 378
379 // Note: This should remain the last member so it'll be destroyed and 379 // Note: This should remain the last member so it'll be destroyed and
380 // invalidate its weak pointers before any other members are destroyed. 380 // invalidate its weak pointers before any other members are destroyed.
381 base::WeakPtrFactory<FlimflamDeviceClientStubImpl> weak_ptr_factory_; 381 base::WeakPtrFactory<ShillDeviceClientStubImpl> weak_ptr_factory_;
382 382
383 DISALLOW_COPY_AND_ASSIGN(FlimflamDeviceClientStubImpl); 383 DISALLOW_COPY_AND_ASSIGN(ShillDeviceClientStubImpl);
384 }; 384 };
385 385
386 } // namespace 386 } // namespace
387 387
388 FlimflamDeviceClient::FlimflamDeviceClient() {} 388 ShillDeviceClient::ShillDeviceClient() {}
389 389
390 FlimflamDeviceClient::~FlimflamDeviceClient() {} 390 ShillDeviceClient::~ShillDeviceClient() {}
391 391
392 // static 392 // static
393 FlimflamDeviceClient* FlimflamDeviceClient::Create( 393 ShillDeviceClient* ShillDeviceClient::Create(
394 DBusClientImplementationType type, 394 DBusClientImplementationType type,
395 dbus::Bus* bus) { 395 dbus::Bus* bus) {
396 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 396 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
397 return new FlimflamDeviceClientImpl(bus); 397 return new ShillDeviceClientImpl(bus);
398 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 398 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
399 return new FlimflamDeviceClientStubImpl(); 399 return new ShillDeviceClientStubImpl();
400 } 400 }
401 401
402 } // namespace chromeos 402 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_device_client.h ('k') | chromeos/dbus/shill_device_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698