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 "chrome/browser/chromeos/cros/cros_network_functions.h" | 5 #include "chrome/browser/chromeos/cros/cros_network_functions.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string_tokenizer.h" | 9 #include "base/string_tokenizer.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/chromeos/cros/sms_watcher.h" | 12 #include "chrome/browser/chromeos/cros/sms_watcher.h" |
13 #include "chromeos/dbus/cashew_client.h" | 13 #include "chromeos/dbus/cashew_client.h" |
14 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
15 #include "chromeos/dbus/shill_device_client.h" | 15 #include "chromeos/dbus/shill_device_client.h" |
16 #include "chromeos/dbus/shill_ipconfig_client.h" | 16 #include "chromeos/dbus/shill_ipconfig_client.h" |
17 #include "chromeos/dbus/shill_manager_client.h" | 17 #include "chromeos/dbus/shill_manager_client.h" |
18 #include "chromeos/dbus/shill_network_client.h" | 18 #include "chromeos/dbus/shill_network_client.h" |
19 #include "chromeos/dbus/shill_profile_client.h" | 19 #include "chromeos/dbus/shill_profile_client.h" |
20 #include "chromeos/dbus/shill_service_client.h" | 20 #include "chromeos/dbus/shill_service_client.h" |
21 #include "dbus/object_path.h" | 21 #include "dbus/object_path.h" |
22 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
23 | 23 |
24 namespace chromeos { | 24 namespace chromeos { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Class to watch network manager's properties without Libcros. | 28 // Class to watch network manager's properties without Libcros. |
29 class NetworkManagerPropertiesWatcher : public CrosNetworkWatcher { | 29 class NetworkManagerPropertiesWatcher |
30 : public CrosNetworkWatcher, | |
31 public ShillManagerClient::PropertyChangedObserver { | |
30 public: | 32 public: |
31 NetworkManagerPropertiesWatcher( | 33 NetworkManagerPropertiesWatcher( |
32 const NetworkPropertiesWatcherCallback& callback) { | 34 const NetworkPropertiesWatcherCallback& callback) |
35 : callback_(callback) { | |
33 DBusThreadManager::Get()->GetShillManagerClient()-> | 36 DBusThreadManager::Get()->GetShillManagerClient()-> |
34 SetPropertyChangedHandler(base::Bind(callback, | 37 AddPropertyChangedObserver(this); |
35 flimflam::kFlimflamServicePath)); | |
36 } | 38 } |
39 | |
37 virtual ~NetworkManagerPropertiesWatcher() { | 40 virtual ~NetworkManagerPropertiesWatcher() { |
38 DBusThreadManager::Get()->GetShillManagerClient()-> | 41 DBusThreadManager::Get()->GetShillManagerClient()-> |
39 ResetPropertyChangedHandler(); | 42 RemovePropertyChangedObserver(this); |
40 } | 43 } |
44 | |
45 virtual void OnPropertyChanged(const std::string& name, | |
46 const base::Value& value) { | |
47 callback_.Run(flimflam::kFlimflamServicePath, name, value); | |
48 } | |
49 private: | |
50 NetworkPropertiesWatcherCallback callback_; | |
41 }; | 51 }; |
42 | 52 |
43 // Class to watch network service's properties without Libcros. | 53 // Class to watch network service's properties without Libcros. |
44 class NetworkServicePropertiesWatcher : public CrosNetworkWatcher { | 54 class NetworkServicePropertiesWatcher |
55 : public CrosNetworkWatcher, | |
56 ShillServiceClient::PropertyChangedObserver | |
hashimoto
2012/09/21 11:52:01
Add public, no new line before '{'
Greg Spencer (Chromium)
2012/09/21 22:03:47
Done.
| |
57 { | |
45 public: | 58 public: |
46 NetworkServicePropertiesWatcher( | 59 NetworkServicePropertiesWatcher( |
47 const NetworkPropertiesWatcherCallback& callback, | 60 const NetworkPropertiesWatcherCallback& callback, |
48 const std::string& service_path) : service_path_(service_path) { | 61 const std::string& service_path) : service_path_(service_path), |
62 callback_(callback) { | |
49 DBusThreadManager::Get()->GetShillServiceClient()-> | 63 DBusThreadManager::Get()->GetShillServiceClient()-> |
50 SetPropertyChangedHandler(dbus::ObjectPath(service_path), | 64 AddPropertyChangedObserver(dbus::ObjectPath(service_path), this); |
51 base::Bind(callback, service_path)); | |
52 } | 65 } |
66 | |
53 virtual ~NetworkServicePropertiesWatcher() { | 67 virtual ~NetworkServicePropertiesWatcher() { |
54 DBusThreadManager::Get()->GetShillServiceClient()-> | 68 DBusThreadManager::Get()->GetShillServiceClient()-> |
55 ResetPropertyChangedHandler(dbus::ObjectPath(service_path_)); | 69 RemovePropertyChangedObserver(dbus::ObjectPath(service_path_), this); |
56 } | 70 } |
57 | 71 |
72 virtual void OnPropertyChanged(const std::string& name, | |
73 const base::Value& value) { | |
74 callback_.Run(service_path_, name, value); | |
75 } | |
58 private: | 76 private: |
hashimoto
2012/09/21 11:52:01
nit: Add new line before 'private'
Greg Spencer (Chromium)
2012/09/21 22:03:47
Done.
| |
59 std::string service_path_; | 77 std::string service_path_; |
78 NetworkPropertiesWatcherCallback callback_; | |
60 }; | 79 }; |
61 | 80 |
62 // Class to watch network device's properties without Libcros. | 81 // Class to watch network device's properties without Libcros. |
63 class NetworkDevicePropertiesWatcher : public CrosNetworkWatcher { | 82 class NetworkDevicePropertiesWatcher |
83 : public CrosNetworkWatcher, | |
84 public ShillDeviceClient::PropertyChangedObserver { | |
64 public: | 85 public: |
65 NetworkDevicePropertiesWatcher( | 86 NetworkDevicePropertiesWatcher( |
66 const NetworkPropertiesWatcherCallback& callback, | 87 const NetworkPropertiesWatcherCallback& callback, |
67 const std::string& device_path) : device_path_(device_path) { | 88 const std::string& device_path) : device_path_(device_path), |
89 callback_(callback) { | |
68 DBusThreadManager::Get()->GetShillDeviceClient()-> | 90 DBusThreadManager::Get()->GetShillDeviceClient()-> |
69 SetPropertyChangedHandler(dbus::ObjectPath(device_path), | 91 AddPropertyChangedObserver(dbus::ObjectPath(device_path), this); |
70 base::Bind(callback, device_path)); | |
71 } | 92 } |
93 | |
72 virtual ~NetworkDevicePropertiesWatcher() { | 94 virtual ~NetworkDevicePropertiesWatcher() { |
73 DBusThreadManager::Get()->GetShillDeviceClient()-> | 95 DBusThreadManager::Get()->GetShillDeviceClient()-> |
74 ResetPropertyChangedHandler(dbus::ObjectPath(device_path_)); | 96 RemovePropertyChangedObserver(dbus::ObjectPath(device_path_), this); |
97 } | |
98 | |
99 virtual void OnPropertyChanged(const std::string& name, | |
100 const base::Value& value) { | |
101 callback_.Run(device_path_, name, value); | |
75 } | 102 } |
76 | 103 |
77 private: | 104 private: |
78 std::string device_path_; | 105 std::string device_path_; |
106 NetworkPropertiesWatcherCallback callback_; | |
79 }; | 107 }; |
80 | 108 |
81 // Converts a string to a CellularDataPlanType. | 109 // Converts a string to a CellularDataPlanType. |
82 CellularDataPlanType ParseCellularDataPlanType(const std::string& type) { | 110 CellularDataPlanType ParseCellularDataPlanType(const std::string& type) { |
83 if (type == cashew::kCellularDataPlanUnlimited) | 111 if (type == cashew::kCellularDataPlanUnlimited) |
84 return CELLULAR_DATA_PLAN_UNLIMITED; | 112 return CELLULAR_DATA_PLAN_UNLIMITED; |
85 if (type == cashew::kCellularDataPlanMeteredPaid) | 113 if (type == cashew::kCellularDataPlanMeteredPaid) |
86 return CELLULAR_DATA_PLAN_METERED_PAID; | 114 return CELLULAR_DATA_PLAN_METERED_PAID; |
87 if (type == cashew::kCellularDataPlanMeteredBase) | 115 if (type == cashew::kCellularDataPlanMeteredBase) |
88 return CELLULAR_DATA_PLAN_METERED_BASE; | 116 return CELLULAR_DATA_PLAN_METERED_BASE; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 &plan->data_bytes_used); | 201 &plan->data_bytes_used); |
174 data_plan_vector->push_back(plan); | 202 data_plan_vector->push_back(plan); |
175 } | 203 } |
176 callback_.Run(service, data_plan_vector); | 204 callback_.Run(service, data_plan_vector); |
177 } | 205 } |
178 | 206 |
179 DataPlanUpdateWatcherCallback callback_; | 207 DataPlanUpdateWatcherCallback callback_; |
180 }; | 208 }; |
181 | 209 |
182 // Does nothing. Used as a callback. | 210 // Does nothing. Used as a callback. |
183 void DoNothing(DBusMethodCallStatus call_status) {} | 211 void DoNothing() {} |
hashimoto
2012/09/21 11:52:01
You can use base::DoNothing() in base/bind_helpers
| |
212 | |
213 // Does nothing. Used as a callback. | |
214 void DoNothingWithCallStatus(DBusMethodCallStatus call_status) {} | |
215 | |
216 // Ignores errors. | |
217 void IgnoreErrors(const std::string& error_name, | |
218 const std::string& error_message) {} | |
184 | 219 |
185 // A callback used to implement CrosRequest*Properties functions. | 220 // A callback used to implement CrosRequest*Properties functions. |
186 void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback, | 221 void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback, |
187 const std::string& path, | 222 const std::string& path, |
188 DBusMethodCallStatus call_status, | 223 DBusMethodCallStatus call_status, |
189 const base::DictionaryValue& value) { | 224 const base::DictionaryValue& value) { |
190 callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL); | 225 callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL); |
191 } | 226 } |
192 | 227 |
228 // A callback used to implement CrosRequest*Properties functions. | |
229 void RunCallbackWithDictionaryValueNoStatus( | |
230 const NetworkPropertiesCallback& callback, | |
231 const std::string& path, | |
232 const base::DictionaryValue& value) { | |
233 callback.Run(path, &value); | |
234 } | |
235 | |
236 // A callback used to implement the error callback for CrosRequest*Properties | |
237 // functions. | |
238 void RunCallbackWithDictionaryValueError( | |
239 const NetworkPropertiesCallback& callback, | |
240 const std::string& path, | |
241 const std::string& error_name, | |
242 const std::string& error_message) { | |
243 callback.Run(path, NULL); | |
244 } | |
245 | |
hashimoto
2012/09/21 11:52:01
nit: Remove this blank line.
| |
246 | |
193 // Used as a callback for ShillManagerClient::GetService | 247 // Used as a callback for ShillManagerClient::GetService |
194 void OnGetService(const NetworkPropertiesCallback& callback, | 248 void OnGetService(const NetworkPropertiesCallback& callback, |
195 DBusMethodCallStatus call_status, | 249 DBusMethodCallStatus call_status, |
196 const dbus::ObjectPath& service_path) { | 250 const dbus::ObjectPath& service_path) { |
197 if (call_status == DBUS_METHOD_CALL_SUCCESS) { | 251 if (call_status == DBUS_METHOD_CALL_SUCCESS) { |
198 VLOG(1) << "OnGetServiceService: " << service_path.value(); | 252 VLOG(1) << "OnGetServiceService: " << service_path.value(); |
199 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( | 253 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( |
200 service_path, base::Bind(&RunCallbackWithDictionaryValue, | 254 service_path, base::Bind(&RunCallbackWithDictionaryValue, |
201 callback, | 255 callback, |
202 service_path.value())); | 256 service_path.value())); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 return DBusThreadManager::Get()->GetShillServiceClient()-> | 363 return DBusThreadManager::Get()->GetShillServiceClient()-> |
310 CallActivateCellularModemAndBlock(dbus::ObjectPath(service_path), | 364 CallActivateCellularModemAndBlock(dbus::ObjectPath(service_path), |
311 carrier); | 365 carrier); |
312 } | 366 } |
313 | 367 |
314 void CrosSetNetworkServiceProperty(const std::string& service_path, | 368 void CrosSetNetworkServiceProperty(const std::string& service_path, |
315 const std::string& property, | 369 const std::string& property, |
316 const base::Value& value) { | 370 const base::Value& value) { |
317 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 371 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
318 dbus::ObjectPath(service_path), property, value, | 372 dbus::ObjectPath(service_path), property, value, |
319 base::Bind(&DoNothing)); | 373 base::Bind(DoNothing), |
374 base::Bind(&IgnoreErrors)); | |
320 } | 375 } |
321 | 376 |
322 void CrosClearNetworkServiceProperty(const std::string& service_path, | 377 void CrosClearNetworkServiceProperty(const std::string& service_path, |
323 const std::string& property) { | 378 const std::string& property) { |
324 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperty( | 379 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperty( |
325 dbus::ObjectPath(service_path), property, base::Bind(&DoNothing)); | 380 dbus::ObjectPath(service_path), property, base::Bind(DoNothing), |
381 base::Bind(&IgnoreErrors)); | |
hashimoto
2012/09/21 11:52:01
nit: align.
| |
326 } | 382 } |
327 | 383 |
328 void CrosSetNetworkDeviceProperty(const std::string& device_path, | 384 void CrosSetNetworkDeviceProperty(const std::string& device_path, |
329 const std::string& property, | 385 const std::string& property, |
330 const base::Value& value) { | 386 const base::Value& value) { |
331 DBusThreadManager::Get()->GetShillDeviceClient()->SetProperty( | 387 DBusThreadManager::Get()->GetShillDeviceClient()->SetProperty( |
332 dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing)); | 388 dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing), |
389 base::Bind(&IgnoreErrors)); | |
333 } | 390 } |
334 | 391 |
335 void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path, | 392 void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path, |
336 const std::string& property, | 393 const std::string& property, |
337 const base::Value& value) { | 394 const base::Value& value) { |
338 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( | 395 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( |
339 dbus::ObjectPath(ipconfig_path), property, value, | 396 dbus::ObjectPath(ipconfig_path), property, value, |
340 base::Bind(&DoNothing)); | 397 base::Bind(&DoNothingWithCallStatus)); |
341 } | 398 } |
342 | 399 |
343 void CrosSetNetworkManagerProperty(const std::string& property, | 400 void CrosSetNetworkManagerProperty(const std::string& property, |
344 const base::Value& value) { | 401 const base::Value& value) { |
345 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty( | 402 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty( |
346 property, value, base::Bind(&DoNothing)); | 403 property, value, base::Bind(&DoNothing), |
404 base::Bind(&IgnoreErrors)); | |
347 } | 405 } |
348 | 406 |
349 void CrosDeleteServiceFromProfile(const std::string& profile_path, | 407 void CrosDeleteServiceFromProfile(const std::string& profile_path, |
350 const std::string& service_path) { | 408 const std::string& service_path) { |
351 DBusThreadManager::Get()->GetShillProfileClient()->DeleteEntry( | 409 DBusThreadManager::Get()->GetShillProfileClient()->DeleteEntry( |
352 dbus::ObjectPath(profile_path), service_path, base::Bind(&DoNothing)); | 410 dbus::ObjectPath(profile_path), |
411 service_path, | |
412 base::Bind(&DoNothing), | |
413 base::Bind(&IgnoreErrors)); | |
353 } | 414 } |
354 | 415 |
355 void CrosRequestCellularDataPlanUpdate(const std::string& modem_service_path) { | 416 void CrosRequestCellularDataPlanUpdate(const std::string& modem_service_path) { |
356 DBusThreadManager::Get()->GetCashewClient()->RequestDataPlansUpdate( | 417 DBusThreadManager::Get()->GetCashewClient()->RequestDataPlansUpdate( |
357 modem_service_path); | 418 modem_service_path); |
358 } | 419 } |
359 | 420 |
360 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties( | 421 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties( |
361 const NetworkPropertiesWatcherCallback& callback) { | 422 const NetworkPropertiesWatcherCallback& callback) { |
362 return new NetworkManagerPropertiesWatcher(callback); | 423 return new NetworkManagerPropertiesWatcher(callback); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties( | 477 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties( |
417 dbus::ObjectPath(device_path), | 478 dbus::ObjectPath(device_path), |
418 base::Bind(&RunCallbackWithDictionaryValue, callback, device_path)); | 479 base::Bind(&RunCallbackWithDictionaryValue, callback, device_path)); |
419 } | 480 } |
420 | 481 |
421 void CrosRequestNetworkProfileProperties( | 482 void CrosRequestNetworkProfileProperties( |
422 const std::string& profile_path, | 483 const std::string& profile_path, |
423 const NetworkPropertiesCallback& callback) { | 484 const NetworkPropertiesCallback& callback) { |
424 DBusThreadManager::Get()->GetShillProfileClient()->GetProperties( | 485 DBusThreadManager::Get()->GetShillProfileClient()->GetProperties( |
425 dbus::ObjectPath(profile_path), | 486 dbus::ObjectPath(profile_path), |
426 base::Bind(&RunCallbackWithDictionaryValue, callback, profile_path)); | 487 base::Bind(&RunCallbackWithDictionaryValueNoStatus, |
488 callback, profile_path), | |
489 base::Bind(RunCallbackWithDictionaryValueError, callback, profile_path)); | |
427 } | 490 } |
428 | 491 |
429 void CrosRequestNetworkProfileEntryProperties( | 492 void CrosRequestNetworkProfileEntryProperties( |
430 const std::string& profile_path, | 493 const std::string& profile_path, |
431 const std::string& profile_entry_path, | 494 const std::string& profile_entry_path, |
432 const NetworkPropertiesCallback& callback) { | 495 const NetworkPropertiesCallback& callback) { |
433 DBusThreadManager::Get()->GetShillProfileClient()->GetEntry( | 496 DBusThreadManager::Get()->GetShillProfileClient()->GetEntry( |
434 dbus::ObjectPath(profile_path), | 497 dbus::ObjectPath(profile_path), |
435 profile_entry_path, | 498 profile_entry_path, |
436 base::Bind(&RunCallbackWithDictionaryValue, | 499 base::Bind(&RunCallbackWithDictionaryValueNoStatus, |
500 callback, | |
501 profile_entry_path), | |
502 base::Bind(RunCallbackWithDictionaryValueError, | |
437 callback, | 503 callback, |
438 profile_entry_path)); | 504 profile_entry_path)); |
439 } | 505 } |
440 | 506 |
441 void CrosRequestHiddenWifiNetworkProperties( | 507 void CrosRequestHiddenWifiNetworkProperties( |
442 const std::string& ssid, | 508 const std::string& ssid, |
443 const std::string& security, | 509 const std::string& security, |
444 const NetworkPropertiesCallback& callback) { | 510 const NetworkPropertiesCallback& callback) { |
445 base::DictionaryValue properties; | 511 base::DictionaryValue properties; |
446 properties.SetWithoutPathExpansion( | 512 properties.SetWithoutPathExpansion( |
447 flimflam::kModeProperty, | 513 flimflam::kModeProperty, |
448 base::Value::CreateStringValue(flimflam::kModeManaged)); | 514 base::Value::CreateStringValue(flimflam::kModeManaged)); |
449 properties.SetWithoutPathExpansion( | 515 properties.SetWithoutPathExpansion( |
450 flimflam::kTypeProperty, | 516 flimflam::kTypeProperty, |
451 base::Value::CreateStringValue(flimflam::kTypeWifi)); | 517 base::Value::CreateStringValue(flimflam::kTypeWifi)); |
452 properties.SetWithoutPathExpansion( | 518 properties.SetWithoutPathExpansion( |
453 flimflam::kSSIDProperty, | 519 flimflam::kSSIDProperty, |
454 base::Value::CreateStringValue(ssid)); | 520 base::Value::CreateStringValue(ssid)); |
455 properties.SetWithoutPathExpansion( | 521 properties.SetWithoutPathExpansion( |
456 flimflam::kSecurityProperty, | 522 flimflam::kSecurityProperty, |
457 base::Value::CreateStringValue(security)); | 523 base::Value::CreateStringValue(security)); |
458 // shill.Manger.GetService() will apply the property changes in | 524 // shill.Manger.GetService() will apply the property changes in |
459 // |properties| and return a new or existing service to OnGetService(). | 525 // |properties| and return a new or existing service to OnGetService(). |
460 // OnGetService will then call GetProperties which will then call callback. | 526 // OnGetService will then call GetProperties which will then call callback. |
461 DBusThreadManager::Get()->GetShillManagerClient()->GetService( | 527 DBusThreadManager::Get()->GetShillManagerClient()->GetService( |
462 properties, base::Bind(&OnGetService, callback)); | 528 properties, base::Bind(&OnGetService, callback), |
529 base::Bind(&IgnoreErrors)); | |
463 } | 530 } |
464 | 531 |
465 void CrosRequestVirtualNetworkProperties( | 532 void CrosRequestVirtualNetworkProperties( |
466 const std::string& service_name, | 533 const std::string& service_name, |
467 const std::string& server_hostname, | 534 const std::string& server_hostname, |
468 const std::string& provider_type, | 535 const std::string& provider_type, |
469 const NetworkPropertiesCallback& callback) { | 536 const NetworkPropertiesCallback& callback) { |
470 base::DictionaryValue properties; | 537 base::DictionaryValue properties; |
471 properties.SetWithoutPathExpansion( | 538 properties.SetWithoutPathExpansion( |
472 flimflam::kTypeProperty, | 539 flimflam::kTypeProperty, |
473 base::Value::CreateStringValue(flimflam::kTypeVPN)); | 540 base::Value::CreateStringValue(flimflam::kTypeVPN)); |
474 properties.SetWithoutPathExpansion( | 541 properties.SetWithoutPathExpansion( |
475 flimflam::kProviderNameProperty, | 542 flimflam::kProviderNameProperty, |
476 base::Value::CreateStringValue(service_name)); | 543 base::Value::CreateStringValue(service_name)); |
477 properties.SetWithoutPathExpansion( | 544 properties.SetWithoutPathExpansion( |
478 flimflam::kProviderHostProperty, | 545 flimflam::kProviderHostProperty, |
479 base::Value::CreateStringValue(server_hostname)); | 546 base::Value::CreateStringValue(server_hostname)); |
480 properties.SetWithoutPathExpansion( | 547 properties.SetWithoutPathExpansion( |
481 flimflam::kProviderTypeProperty, | 548 flimflam::kProviderTypeProperty, |
482 base::Value::CreateStringValue(provider_type)); | 549 base::Value::CreateStringValue(provider_type)); |
483 // The actual value of Domain does not matter, so just use service_name. | 550 // The actual value of Domain does not matter, so just use service_name. |
484 properties.SetWithoutPathExpansion( | 551 properties.SetWithoutPathExpansion( |
485 flimflam::kVPNDomainProperty, | 552 flimflam::kVPNDomainProperty, |
486 base::Value::CreateStringValue(service_name)); | 553 base::Value::CreateStringValue(service_name)); |
487 | 554 |
488 // shill.Manger.GetService() will apply the property changes in | 555 // shill.Manger.GetService() will apply the property changes in |
489 // |properties| and pass a new or existing service to OnGetService(). | 556 // |properties| and pass a new or existing service to OnGetService(). |
490 // OnGetService will then call GetProperties which will then call callback. | 557 // OnGetService will then call GetProperties which will then call callback. |
491 DBusThreadManager::Get()->GetShillManagerClient()->GetService( | 558 DBusThreadManager::Get()->GetShillManagerClient()->GetService( |
492 properties, base::Bind(&OnGetService, callback)); | 559 properties, base::Bind(&OnGetService, callback), |
560 base::Bind(&IgnoreErrors)); | |
493 } | 561 } |
494 | 562 |
495 void CrosRequestNetworkServiceDisconnect(const std::string& service_path) { | 563 void CrosRequestNetworkServiceDisconnect(const std::string& service_path) { |
496 DBusThreadManager::Get()->GetShillServiceClient()->Disconnect( | 564 DBusThreadManager::Get()->GetShillServiceClient()->Disconnect( |
497 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); | 565 dbus::ObjectPath(service_path), base::Bind(DoNothing), |
hashimoto
2012/09/21 11:52:01
nit: Add '&' before DoNothing for consistency.
| |
566 base::Bind(&IgnoreErrors)); | |
498 } | 567 } |
499 | 568 |
500 void CrosRequestRemoveNetworkService(const std::string& service_path) { | 569 void CrosRequestRemoveNetworkService(const std::string& service_path) { |
501 DBusThreadManager::Get()->GetShillServiceClient()->Remove( | 570 DBusThreadManager::Get()->GetShillServiceClient()->Remove( |
502 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); | 571 dbus::ObjectPath(service_path), base::Bind(DoNothing), |
hashimoto
2012/09/21 11:52:01
ditto.
| |
572 base::Bind(&IgnoreErrors)); | |
503 } | 573 } |
504 | 574 |
505 void CrosRequestNetworkScan(const std::string& network_type) { | 575 void CrosRequestNetworkScan(const std::string& network_type) { |
506 DBusThreadManager::Get()->GetShillManagerClient()->RequestScan( | 576 DBusThreadManager::Get()->GetShillManagerClient()->RequestScan( |
507 network_type, base::Bind(&DoNothing)); | 577 network_type, base::Bind(&DoNothing), |
578 base::Bind(&IgnoreErrors)); | |
508 } | 579 } |
509 | 580 |
510 void CrosRequestNetworkDeviceEnable(const std::string& network_type, | 581 void CrosRequestNetworkDeviceEnable(const std::string& network_type, |
511 bool enable) { | 582 bool enable) { |
512 if (enable) { | 583 if (enable) { |
513 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( | 584 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( |
514 network_type, base::Bind(&DoNothing)); | 585 network_type, base::Bind(&DoNothing), |
586 base::Bind(&IgnoreErrors)); | |
515 } else { | 587 } else { |
516 DBusThreadManager::Get()->GetShillManagerClient()->DisableTechnology( | 588 DBusThreadManager::Get()->GetShillManagerClient()->DisableTechnology( |
517 network_type, base::Bind(&DoNothing)); | 589 network_type, base::Bind(&DoNothing), |
590 base::Bind(&IgnoreErrors)); | |
518 } | 591 } |
519 } | 592 } |
520 | 593 |
521 void CrosRequestRequirePin(const std::string& device_path, | 594 void CrosRequestRequirePin(const std::string& device_path, |
522 const std::string& pin, | 595 const std::string& pin, |
523 bool enable, | 596 bool enable, |
524 const NetworkOperationCallback& callback) { | 597 const NetworkOperationCallback& callback) { |
525 DBusThreadManager::Get()->GetShillDeviceClient()->RequirePin( | 598 DBusThreadManager::Get()->GetShillDeviceClient()->RequirePin( |
526 dbus::ObjectPath(device_path), pin, enable, | 599 dbus::ObjectPath(device_path), pin, enable, |
527 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, | 600 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, |
(...skipping 28 matching lines...) Expand all Loading... | |
556 const NetworkOperationCallback& callback) { | 629 const NetworkOperationCallback& callback) { |
557 DBusThreadManager::Get()->GetShillDeviceClient()->ChangePin( | 630 DBusThreadManager::Get()->GetShillDeviceClient()->ChangePin( |
558 dbus::ObjectPath(device_path), old_pin, new_pin, | 631 dbus::ObjectPath(device_path), old_pin, new_pin, |
559 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, | 632 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, |
560 std::string()), | 633 std::string()), |
561 base::Bind(&OnNetworkActionError, callback, device_path)); | 634 base::Bind(&OnNetworkActionError, callback, device_path)); |
562 } | 635 } |
563 | 636 |
564 void CrosProposeScan(const std::string& device_path) { | 637 void CrosProposeScan(const std::string& device_path) { |
565 DBusThreadManager::Get()->GetShillDeviceClient()->ProposeScan( | 638 DBusThreadManager::Get()->GetShillDeviceClient()->ProposeScan( |
566 dbus::ObjectPath(device_path), base::Bind(&DoNothing)); | 639 dbus::ObjectPath(device_path), base::Bind(&DoNothingWithCallStatus)); |
567 } | 640 } |
568 | 641 |
569 void CrosRequestCellularRegister(const std::string& device_path, | 642 void CrosRequestCellularRegister(const std::string& device_path, |
570 const std::string& network_id, | 643 const std::string& network_id, |
571 const NetworkOperationCallback& callback) { | 644 const NetworkOperationCallback& callback) { |
572 DBusThreadManager::Get()->GetShillDeviceClient()->Register( | 645 DBusThreadManager::Get()->GetShillDeviceClient()->Register( |
573 dbus::ObjectPath(device_path), network_id, | 646 dbus::ObjectPath(device_path), network_id, |
574 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, | 647 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, |
575 std::string()), | 648 std::string()), |
576 base::Bind(&OnNetworkActionError, callback, device_path)); | 649 base::Bind(&OnNetworkActionError, callback, device_path)); |
577 } | 650 } |
578 | 651 |
579 bool CrosSetOfflineMode(bool offline) { | 652 bool CrosSetOfflineMode(bool offline) { |
580 base::FundamentalValue value(offline); | 653 base::FundamentalValue value(offline); |
581 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty( | 654 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty( |
582 flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing)); | 655 flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing), |
656 base::Bind(&IgnoreErrors)); | |
583 return true; | 657 return true; |
584 } | 658 } |
585 | 659 |
586 bool CrosListIPConfigs(const std::string& device_path, | 660 bool CrosListIPConfigs(const std::string& device_path, |
587 NetworkIPConfigVector* ipconfig_vector, | 661 NetworkIPConfigVector* ipconfig_vector, |
588 std::vector<std::string>* ipconfig_paths, | 662 std::vector<std::string>* ipconfig_paths, |
589 std::string* hardware_address) { | 663 std::string* hardware_address) { |
590 if (hardware_address) | 664 if (hardware_address) |
591 hardware_address->clear(); | 665 hardware_address->clear(); |
592 const dbus::ObjectPath device_object_path(device_path); | 666 const dbus::ObjectPath device_object_path(device_path); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 } | 734 } |
661 | 735 |
662 bool CrosRemoveIPConfig(const std::string& ipconfig_path) { | 736 bool CrosRemoveIPConfig(const std::string& ipconfig_path) { |
663 return DBusThreadManager::Get()->GetShillIPConfigClient()-> | 737 return DBusThreadManager::Get()->GetShillIPConfigClient()-> |
664 CallRemoveAndBlock(dbus::ObjectPath(ipconfig_path)); | 738 CallRemoveAndBlock(dbus::ObjectPath(ipconfig_path)); |
665 } | 739 } |
666 | 740 |
667 void CrosRequestIPConfigRefresh(const std::string& ipconfig_path) { | 741 void CrosRequestIPConfigRefresh(const std::string& ipconfig_path) { |
668 DBusThreadManager::Get()->GetShillIPConfigClient()->Refresh( | 742 DBusThreadManager::Get()->GetShillIPConfigClient()->Refresh( |
669 dbus::ObjectPath(ipconfig_path), | 743 dbus::ObjectPath(ipconfig_path), |
670 base::Bind(&DoNothing)); | 744 base::Bind(&DoNothingWithCallStatus)); |
671 } | 745 } |
672 | 746 |
673 bool CrosGetWifiAccessPoints(WifiAccessPointVector* result) { | 747 bool CrosGetWifiAccessPoints(WifiAccessPointVector* result) { |
674 scoped_ptr<base::DictionaryValue> manager_properties( | 748 scoped_ptr<base::DictionaryValue> manager_properties( |
675 DBusThreadManager::Get()->GetShillManagerClient()-> | 749 DBusThreadManager::Get()->GetShillManagerClient()-> |
676 CallGetPropertiesAndBlock()); | 750 CallGetPropertiesAndBlock()); |
677 if (!manager_properties.get()) { | 751 if (!manager_properties.get()) { |
678 LOG(WARNING) << "Couldn't read managers's properties"; | 752 LOG(WARNING) << "Couldn't read managers's properties"; |
679 return false; | 753 return false; |
680 } | 754 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
751 result->push_back(ap); | 825 result->push_back(ap); |
752 } | 826 } |
753 } | 827 } |
754 if (!found_at_least_one_device) | 828 if (!found_at_least_one_device) |
755 return false; // No powered device found that has a 'Networks' array. | 829 return false; // No powered device found that has a 'Networks' array. |
756 return true; | 830 return true; |
757 } | 831 } |
758 | 832 |
759 void CrosConfigureService(const base::DictionaryValue& properties) { | 833 void CrosConfigureService(const base::DictionaryValue& properties) { |
760 DBusThreadManager::Get()->GetShillManagerClient()->ConfigureService( | 834 DBusThreadManager::Get()->GetShillManagerClient()->ConfigureService( |
761 properties, base::Bind(&DoNothing)); | 835 properties, base::Bind(&DoNothing), |
836 base::Bind(&IgnoreErrors)); | |
762 } | 837 } |
763 | 838 |
764 std::string CrosPrefixLengthToNetmask(int32 prefix_length) { | 839 std::string CrosPrefixLengthToNetmask(int32 prefix_length) { |
765 std::string netmask; | 840 std::string netmask; |
766 // Return the empty string for invalid inputs. | 841 // Return the empty string for invalid inputs. |
767 if (prefix_length < 0 || prefix_length > 32) | 842 if (prefix_length < 0 || prefix_length > 32) |
768 return netmask; | 843 return netmask; |
769 for (int i = 0; i < 4; i++) { | 844 for (int i = 0; i < 4; i++) { |
770 int remainder = 8; | 845 int remainder = 8; |
771 if (prefix_length >= 8) { | 846 if (prefix_length >= 8) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 return -1; | 896 return -1; |
822 } | 897 } |
823 count++; | 898 count++; |
824 } | 899 } |
825 if (count < 4) | 900 if (count < 4) |
826 return -1; | 901 return -1; |
827 return prefix_length; | 902 return prefix_length; |
828 } | 903 } |
829 | 904 |
830 } // namespace chromeos | 905 } // namespace chromeos |
OLD | NEW |