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

Side by Side Diff: chrome/browser/chromeos/cros/cros_network_functions.cc

Issue 10949030: This converts the Shill clients to allow propagation of shill errors (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix bad merge Created 8 years, 2 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 | « no previous file | chrome/browser/chromeos/cros/cros_network_functions_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 "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/bind_helpers.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/string_tokenizer.h" 10 #include "base/string_tokenizer.h"
10 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/chromeos/cros/sms_watcher.h" 13 #include "chrome/browser/chromeos/cros/sms_watcher.h"
13 #include "chromeos/dbus/cashew_client.h" 14 #include "chromeos/dbus/cashew_client.h"
14 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "chromeos/dbus/shill_device_client.h" 16 #include "chromeos/dbus/shill_device_client.h"
16 #include "chromeos/dbus/shill_ipconfig_client.h" 17 #include "chromeos/dbus/shill_ipconfig_client.h"
17 #include "chromeos/dbus/shill_manager_client.h" 18 #include "chromeos/dbus/shill_manager_client.h"
18 #include "chromeos/dbus/shill_network_client.h" 19 #include "chromeos/dbus/shill_network_client.h"
19 #include "chromeos/dbus/shill_profile_client.h" 20 #include "chromeos/dbus/shill_profile_client.h"
20 #include "chromeos/dbus/shill_property_changed_observer.h" 21 #include "chromeos/dbus/shill_property_changed_observer.h"
21 #include "chromeos/dbus/shill_service_client.h" 22 #include "chromeos/dbus/shill_service_client.h"
22 #include "dbus/object_path.h" 23 #include "dbus/object_path.h"
23 #include "third_party/cros_system_api/dbus/service_constants.h" 24 #include "third_party/cros_system_api/dbus/service_constants.h"
24 25
26 using base::DoNothing;
27
25 namespace chromeos { 28 namespace chromeos {
26 29
27 namespace { 30 namespace {
28 31
29 // Class to watch network manager's properties without Libcros. 32 // Class to watch network manager's properties without Libcros.
30 class NetworkManagerPropertiesWatcher 33 class NetworkManagerPropertiesWatcher
31 : public CrosNetworkWatcher, 34 : public CrosNetworkWatcher,
32 public ShillPropertyChangedObserver { 35 public ShillPropertyChangedObserver {
33 public: 36 public:
34 NetworkManagerPropertiesWatcher( 37 NetworkManagerPropertiesWatcher(
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 &plan->data_bytes_used); 205 &plan->data_bytes_used);
203 data_plan_vector->push_back(plan); 206 data_plan_vector->push_back(plan);
204 } 207 }
205 callback_.Run(service, data_plan_vector); 208 callback_.Run(service, data_plan_vector);
206 } 209 }
207 210
208 DataPlanUpdateWatcherCallback callback_; 211 DataPlanUpdateWatcherCallback callback_;
209 }; 212 };
210 213
211 // Does nothing. Used as a callback. 214 // Does nothing. Used as a callback.
212 void DoNothing(DBusMethodCallStatus call_status) {} 215 void DoNothingWithCallStatus(DBusMethodCallStatus call_status) {}
216
217 // Ignores errors.
218 void IgnoreErrors(const std::string& error_name,
219 const std::string& error_message) {}
213 220
214 // A callback used to implement CrosRequest*Properties functions. 221 // A callback used to implement CrosRequest*Properties functions.
215 void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback, 222 void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback,
216 const std::string& path, 223 const std::string& path,
217 DBusMethodCallStatus call_status, 224 DBusMethodCallStatus call_status,
218 const base::DictionaryValue& value) { 225 const base::DictionaryValue& value) {
219 callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL); 226 callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL);
220 } 227 }
221 228
229 // A callback used to implement CrosRequest*Properties functions.
230 void RunCallbackWithDictionaryValueNoStatus(
231 const NetworkPropertiesCallback& callback,
232 const std::string& path,
233 const base::DictionaryValue& value) {
234 callback.Run(path, &value);
235 }
236
237 // A callback used to implement the error callback for CrosRequest*Properties
238 // functions.
239 void RunCallbackWithDictionaryValueError(
240 const NetworkPropertiesCallback& callback,
241 const std::string& path,
242 const std::string& error_name,
243 const std::string& error_message) {
244 callback.Run(path, NULL);
245 }
246
222 // Used as a callback for ShillManagerClient::GetService 247 // Used as a callback for ShillManagerClient::GetService
223 void OnGetService(const NetworkPropertiesCallback& callback, 248 void OnGetService(const NetworkPropertiesCallback& callback,
224 DBusMethodCallStatus call_status,
225 const dbus::ObjectPath& service_path) { 249 const dbus::ObjectPath& service_path) {
226 if (call_status == DBUS_METHOD_CALL_SUCCESS) { 250 VLOG(1) << "OnGetServiceService: " << service_path.value();
227 VLOG(1) << "OnGetServiceService: " << service_path.value(); 251 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties(
228 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( 252 service_path, base::Bind(&RunCallbackWithDictionaryValue,
229 service_path, base::Bind(&RunCallbackWithDictionaryValue, 253 callback,
230 callback, 254 service_path.value()));
231 service_path.value()));
232 }
233 } 255 }
234 256
235 // A callback used to call a NetworkOperationCallback on error. 257 // A callback used to call a NetworkOperationCallback on error.
236 void OnNetworkActionError(const NetworkOperationCallback& callback, 258 void OnNetworkActionError(const NetworkOperationCallback& callback,
237 const std::string& path, 259 const std::string& path,
238 const std::string& error_name, 260 const std::string& error_name,
239 const std::string& error_message) { 261 const std::string& error_message) {
240 if (error_name.empty()) 262 if (error_name.empty())
241 callback.Run(path, NETWORK_METHOD_ERROR_LOCAL, ""); 263 callback.Run(path, NETWORK_METHOD_ERROR_LOCAL, "");
242 else 264 else
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 return DBusThreadManager::Get()->GetShillServiceClient()-> 360 return DBusThreadManager::Get()->GetShillServiceClient()->
339 CallActivateCellularModemAndBlock(dbus::ObjectPath(service_path), 361 CallActivateCellularModemAndBlock(dbus::ObjectPath(service_path),
340 carrier); 362 carrier);
341 } 363 }
342 364
343 void CrosSetNetworkServiceProperty(const std::string& service_path, 365 void CrosSetNetworkServiceProperty(const std::string& service_path,
344 const std::string& property, 366 const std::string& property,
345 const base::Value& value) { 367 const base::Value& value) {
346 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( 368 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
347 dbus::ObjectPath(service_path), property, value, 369 dbus::ObjectPath(service_path), property, value,
348 base::Bind(&DoNothing)); 370 base::Bind(&DoNothing),
371 base::Bind(&IgnoreErrors));
349 } 372 }
350 373
351 void CrosClearNetworkServiceProperty(const std::string& service_path, 374 void CrosClearNetworkServiceProperty(const std::string& service_path,
352 const std::string& property) { 375 const std::string& property) {
353 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperty( 376 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperty(
354 dbus::ObjectPath(service_path), property, base::Bind(&DoNothing)); 377 dbus::ObjectPath(service_path), property, base::Bind(&DoNothing),
378 base::Bind(&IgnoreErrors));
355 } 379 }
356 380
357 void CrosSetNetworkDeviceProperty(const std::string& device_path, 381 void CrosSetNetworkDeviceProperty(const std::string& device_path,
358 const std::string& property, 382 const std::string& property,
359 const base::Value& value) { 383 const base::Value& value) {
360 DBusThreadManager::Get()->GetShillDeviceClient()->SetProperty( 384 DBusThreadManager::Get()->GetShillDeviceClient()->SetProperty(
361 dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing)); 385 dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing),
386 base::Bind(&IgnoreErrors));
362 } 387 }
363 388
364 void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path, 389 void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path,
365 const std::string& property, 390 const std::string& property,
366 const base::Value& value) { 391 const base::Value& value) {
367 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( 392 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty(
368 dbus::ObjectPath(ipconfig_path), property, value, 393 dbus::ObjectPath(ipconfig_path), property, value,
369 base::Bind(&DoNothing)); 394 base::Bind(&DoNothingWithCallStatus));
370 } 395 }
371 396
372 void CrosSetNetworkManagerProperty(const std::string& property, 397 void CrosSetNetworkManagerProperty(const std::string& property,
373 const base::Value& value) { 398 const base::Value& value) {
374 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty( 399 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty(
375 property, value, base::Bind(&DoNothing)); 400 property, value, base::Bind(&DoNothing),
401 base::Bind(&IgnoreErrors));
376 } 402 }
377 403
378 void CrosDeleteServiceFromProfile(const std::string& profile_path, 404 void CrosDeleteServiceFromProfile(const std::string& profile_path,
379 const std::string& service_path) { 405 const std::string& service_path) {
380 DBusThreadManager::Get()->GetShillProfileClient()->DeleteEntry( 406 DBusThreadManager::Get()->GetShillProfileClient()->DeleteEntry(
381 dbus::ObjectPath(profile_path), service_path, base::Bind(&DoNothing)); 407 dbus::ObjectPath(profile_path),
408 service_path,
409 base::Bind(&DoNothing),
410 base::Bind(&IgnoreErrors));
382 } 411 }
383 412
384 void CrosRequestCellularDataPlanUpdate(const std::string& modem_service_path) { 413 void CrosRequestCellularDataPlanUpdate(const std::string& modem_service_path) {
385 DBusThreadManager::Get()->GetCashewClient()->RequestDataPlansUpdate( 414 DBusThreadManager::Get()->GetCashewClient()->RequestDataPlansUpdate(
386 modem_service_path); 415 modem_service_path);
387 } 416 }
388 417
389 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties( 418 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties(
390 const NetworkPropertiesWatcherCallback& callback) { 419 const NetworkPropertiesWatcherCallback& callback) {
391 return new NetworkManagerPropertiesWatcher(callback); 420 return new NetworkManagerPropertiesWatcher(callback);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties( 474 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties(
446 dbus::ObjectPath(device_path), 475 dbus::ObjectPath(device_path),
447 base::Bind(&RunCallbackWithDictionaryValue, callback, device_path)); 476 base::Bind(&RunCallbackWithDictionaryValue, callback, device_path));
448 } 477 }
449 478
450 void CrosRequestNetworkProfileProperties( 479 void CrosRequestNetworkProfileProperties(
451 const std::string& profile_path, 480 const std::string& profile_path,
452 const NetworkPropertiesCallback& callback) { 481 const NetworkPropertiesCallback& callback) {
453 DBusThreadManager::Get()->GetShillProfileClient()->GetProperties( 482 DBusThreadManager::Get()->GetShillProfileClient()->GetProperties(
454 dbus::ObjectPath(profile_path), 483 dbus::ObjectPath(profile_path),
455 base::Bind(&RunCallbackWithDictionaryValue, callback, profile_path)); 484 base::Bind(&RunCallbackWithDictionaryValueNoStatus,
485 callback, profile_path),
486 base::Bind(&RunCallbackWithDictionaryValueError, callback, profile_path));
456 } 487 }
457 488
458 void CrosRequestNetworkProfileEntryProperties( 489 void CrosRequestNetworkProfileEntryProperties(
459 const std::string& profile_path, 490 const std::string& profile_path,
460 const std::string& profile_entry_path, 491 const std::string& profile_entry_path,
461 const NetworkPropertiesCallback& callback) { 492 const NetworkPropertiesCallback& callback) {
462 DBusThreadManager::Get()->GetShillProfileClient()->GetEntry( 493 DBusThreadManager::Get()->GetShillProfileClient()->GetEntry(
463 dbus::ObjectPath(profile_path), 494 dbus::ObjectPath(profile_path),
464 profile_entry_path, 495 profile_entry_path,
465 base::Bind(&RunCallbackWithDictionaryValue, 496 base::Bind(&RunCallbackWithDictionaryValueNoStatus,
497 callback,
498 profile_entry_path),
499 base::Bind(&RunCallbackWithDictionaryValueError,
466 callback, 500 callback,
467 profile_entry_path)); 501 profile_entry_path));
468 } 502 }
469 503
470 void CrosRequestHiddenWifiNetworkProperties( 504 void CrosRequestHiddenWifiNetworkProperties(
471 const std::string& ssid, 505 const std::string& ssid,
472 const std::string& security, 506 const std::string& security,
473 const NetworkPropertiesCallback& callback) { 507 const NetworkPropertiesCallback& callback) {
474 base::DictionaryValue properties; 508 base::DictionaryValue properties;
475 properties.SetWithoutPathExpansion( 509 properties.SetWithoutPathExpansion(
476 flimflam::kModeProperty, 510 flimflam::kModeProperty,
477 base::Value::CreateStringValue(flimflam::kModeManaged)); 511 base::Value::CreateStringValue(flimflam::kModeManaged));
478 properties.SetWithoutPathExpansion( 512 properties.SetWithoutPathExpansion(
479 flimflam::kTypeProperty, 513 flimflam::kTypeProperty,
480 base::Value::CreateStringValue(flimflam::kTypeWifi)); 514 base::Value::CreateStringValue(flimflam::kTypeWifi));
481 properties.SetWithoutPathExpansion( 515 properties.SetWithoutPathExpansion(
482 flimflam::kSSIDProperty, 516 flimflam::kSSIDProperty,
483 base::Value::CreateStringValue(ssid)); 517 base::Value::CreateStringValue(ssid));
484 properties.SetWithoutPathExpansion( 518 properties.SetWithoutPathExpansion(
485 flimflam::kSecurityProperty, 519 flimflam::kSecurityProperty,
486 base::Value::CreateStringValue(security)); 520 base::Value::CreateStringValue(security));
487 // shill.Manger.GetService() will apply the property changes in 521 // shill.Manger.GetService() will apply the property changes in
488 // |properties| and return a new or existing service to OnGetService(). 522 // |properties| and return a new or existing service to OnGetService().
489 // OnGetService will then call GetProperties which will then call callback. 523 // OnGetService will then call GetProperties which will then call callback.
490 DBusThreadManager::Get()->GetShillManagerClient()->GetService( 524 DBusThreadManager::Get()->GetShillManagerClient()->GetService(
491 properties, base::Bind(&OnGetService, callback)); 525 properties, base::Bind(&OnGetService, callback),
526 base::Bind(&IgnoreErrors));
492 } 527 }
493 528
494 void CrosRequestVirtualNetworkProperties( 529 void CrosRequestVirtualNetworkProperties(
495 const std::string& service_name, 530 const std::string& service_name,
496 const std::string& server_hostname, 531 const std::string& server_hostname,
497 const std::string& provider_type, 532 const std::string& provider_type,
498 const NetworkPropertiesCallback& callback) { 533 const NetworkPropertiesCallback& callback) {
499 base::DictionaryValue properties; 534 base::DictionaryValue properties;
500 properties.SetWithoutPathExpansion( 535 properties.SetWithoutPathExpansion(
501 flimflam::kTypeProperty, 536 flimflam::kTypeProperty,
502 base::Value::CreateStringValue(flimflam::kTypeVPN)); 537 base::Value::CreateStringValue(flimflam::kTypeVPN));
503 properties.SetWithoutPathExpansion( 538 properties.SetWithoutPathExpansion(
504 flimflam::kProviderNameProperty, 539 flimflam::kProviderNameProperty,
505 base::Value::CreateStringValue(service_name)); 540 base::Value::CreateStringValue(service_name));
506 properties.SetWithoutPathExpansion( 541 properties.SetWithoutPathExpansion(
507 flimflam::kProviderHostProperty, 542 flimflam::kProviderHostProperty,
508 base::Value::CreateStringValue(server_hostname)); 543 base::Value::CreateStringValue(server_hostname));
509 properties.SetWithoutPathExpansion( 544 properties.SetWithoutPathExpansion(
510 flimflam::kProviderTypeProperty, 545 flimflam::kProviderTypeProperty,
511 base::Value::CreateStringValue(provider_type)); 546 base::Value::CreateStringValue(provider_type));
512 // The actual value of Domain does not matter, so just use service_name. 547 // The actual value of Domain does not matter, so just use service_name.
513 properties.SetWithoutPathExpansion( 548 properties.SetWithoutPathExpansion(
514 flimflam::kVPNDomainProperty, 549 flimflam::kVPNDomainProperty,
515 base::Value::CreateStringValue(service_name)); 550 base::Value::CreateStringValue(service_name));
516 551
517 // shill.Manger.GetService() will apply the property changes in 552 // shill.Manger.GetService() will apply the property changes in
518 // |properties| and pass a new or existing service to OnGetService(). 553 // |properties| and pass a new or existing service to OnGetService().
519 // OnGetService will then call GetProperties which will then call callback. 554 // OnGetService will then call GetProperties which will then call callback.
520 DBusThreadManager::Get()->GetShillManagerClient()->GetService( 555 DBusThreadManager::Get()->GetShillManagerClient()->GetService(
521 properties, base::Bind(&OnGetService, callback)); 556 properties, base::Bind(&OnGetService, callback),
557 base::Bind(&IgnoreErrors));
522 } 558 }
523 559
524 void CrosRequestNetworkServiceDisconnect(const std::string& service_path) { 560 void CrosRequestNetworkServiceDisconnect(const std::string& service_path) {
525 DBusThreadManager::Get()->GetShillServiceClient()->Disconnect( 561 DBusThreadManager::Get()->GetShillServiceClient()->Disconnect(
526 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); 562 dbus::ObjectPath(service_path), base::Bind(&DoNothing),
563 base::Bind(&IgnoreErrors));
527 } 564 }
528 565
529 void CrosRequestRemoveNetworkService(const std::string& service_path) { 566 void CrosRequestRemoveNetworkService(const std::string& service_path) {
530 DBusThreadManager::Get()->GetShillServiceClient()->Remove( 567 DBusThreadManager::Get()->GetShillServiceClient()->Remove(
531 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); 568 dbus::ObjectPath(service_path), base::Bind(&DoNothing),
569 base::Bind(&IgnoreErrors));
532 } 570 }
533 571
534 void CrosRequestNetworkScan(const std::string& network_type) { 572 void CrosRequestNetworkScan(const std::string& network_type) {
535 DBusThreadManager::Get()->GetShillManagerClient()->RequestScan( 573 DBusThreadManager::Get()->GetShillManagerClient()->RequestScan(
536 network_type, base::Bind(&DoNothing)); 574 network_type, base::Bind(&DoNothing),
575 base::Bind(&IgnoreErrors));
537 } 576 }
538 577
539 void CrosRequestNetworkDeviceEnable(const std::string& network_type, 578 void CrosRequestNetworkDeviceEnable(const std::string& network_type,
540 bool enable) { 579 bool enable) {
541 if (enable) { 580 if (enable) {
542 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( 581 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology(
543 network_type, base::Bind(&DoNothing)); 582 network_type, base::Bind(&DoNothing),
583 base::Bind(&IgnoreErrors));
544 } else { 584 } else {
545 DBusThreadManager::Get()->GetShillManagerClient()->DisableTechnology( 585 DBusThreadManager::Get()->GetShillManagerClient()->DisableTechnology(
546 network_type, base::Bind(&DoNothing)); 586 network_type, base::Bind(&DoNothing),
587 base::Bind(&IgnoreErrors));
547 } 588 }
548 } 589 }
549 590
550 void CrosRequestRequirePin(const std::string& device_path, 591 void CrosRequestRequirePin(const std::string& device_path,
551 const std::string& pin, 592 const std::string& pin,
552 bool enable, 593 bool enable,
553 const NetworkOperationCallback& callback) { 594 const NetworkOperationCallback& callback) {
554 DBusThreadManager::Get()->GetShillDeviceClient()->RequirePin( 595 DBusThreadManager::Get()->GetShillDeviceClient()->RequirePin(
555 dbus::ObjectPath(device_path), pin, enable, 596 dbus::ObjectPath(device_path), pin, enable,
556 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, 597 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE,
(...skipping 28 matching lines...) Expand all
585 const NetworkOperationCallback& callback) { 626 const NetworkOperationCallback& callback) {
586 DBusThreadManager::Get()->GetShillDeviceClient()->ChangePin( 627 DBusThreadManager::Get()->GetShillDeviceClient()->ChangePin(
587 dbus::ObjectPath(device_path), old_pin, new_pin, 628 dbus::ObjectPath(device_path), old_pin, new_pin,
588 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, 629 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE,
589 std::string()), 630 std::string()),
590 base::Bind(&OnNetworkActionError, callback, device_path)); 631 base::Bind(&OnNetworkActionError, callback, device_path));
591 } 632 }
592 633
593 void CrosProposeScan(const std::string& device_path) { 634 void CrosProposeScan(const std::string& device_path) {
594 DBusThreadManager::Get()->GetShillDeviceClient()->ProposeScan( 635 DBusThreadManager::Get()->GetShillDeviceClient()->ProposeScan(
595 dbus::ObjectPath(device_path), base::Bind(&DoNothing)); 636 dbus::ObjectPath(device_path), base::Bind(&DoNothingWithCallStatus));
596 } 637 }
597 638
598 void CrosRequestCellularRegister(const std::string& device_path, 639 void CrosRequestCellularRegister(const std::string& device_path,
599 const std::string& network_id, 640 const std::string& network_id,
600 const NetworkOperationCallback& callback) { 641 const NetworkOperationCallback& callback) {
601 DBusThreadManager::Get()->GetShillDeviceClient()->Register( 642 DBusThreadManager::Get()->GetShillDeviceClient()->Register(
602 dbus::ObjectPath(device_path), network_id, 643 dbus::ObjectPath(device_path), network_id,
603 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, 644 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE,
604 std::string()), 645 std::string()),
605 base::Bind(&OnNetworkActionError, callback, device_path)); 646 base::Bind(&OnNetworkActionError, callback, device_path));
606 } 647 }
607 648
608 bool CrosSetOfflineMode(bool offline) { 649 bool CrosSetOfflineMode(bool offline) {
609 base::FundamentalValue value(offline); 650 base::FundamentalValue value(offline);
610 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty( 651 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty(
611 flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing)); 652 flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing),
653 base::Bind(&IgnoreErrors));
612 return true; 654 return true;
613 } 655 }
614 656
615 bool CrosListIPConfigs(const std::string& device_path, 657 bool CrosListIPConfigs(const std::string& device_path,
616 NetworkIPConfigVector* ipconfig_vector, 658 NetworkIPConfigVector* ipconfig_vector,
617 std::vector<std::string>* ipconfig_paths, 659 std::vector<std::string>* ipconfig_paths,
618 std::string* hardware_address) { 660 std::string* hardware_address) {
619 if (hardware_address) 661 if (hardware_address)
620 hardware_address->clear(); 662 hardware_address->clear();
621 const dbus::ObjectPath device_object_path(device_path); 663 const dbus::ObjectPath device_object_path(device_path);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 731 }
690 732
691 bool CrosRemoveIPConfig(const std::string& ipconfig_path) { 733 bool CrosRemoveIPConfig(const std::string& ipconfig_path) {
692 return DBusThreadManager::Get()->GetShillIPConfigClient()-> 734 return DBusThreadManager::Get()->GetShillIPConfigClient()->
693 CallRemoveAndBlock(dbus::ObjectPath(ipconfig_path)); 735 CallRemoveAndBlock(dbus::ObjectPath(ipconfig_path));
694 } 736 }
695 737
696 void CrosRequestIPConfigRefresh(const std::string& ipconfig_path) { 738 void CrosRequestIPConfigRefresh(const std::string& ipconfig_path) {
697 DBusThreadManager::Get()->GetShillIPConfigClient()->Refresh( 739 DBusThreadManager::Get()->GetShillIPConfigClient()->Refresh(
698 dbus::ObjectPath(ipconfig_path), 740 dbus::ObjectPath(ipconfig_path),
699 base::Bind(&DoNothing)); 741 base::Bind(&DoNothingWithCallStatus));
700 } 742 }
701 743
702 bool CrosGetWifiAccessPoints(WifiAccessPointVector* result) { 744 bool CrosGetWifiAccessPoints(WifiAccessPointVector* result) {
703 scoped_ptr<base::DictionaryValue> manager_properties( 745 scoped_ptr<base::DictionaryValue> manager_properties(
704 DBusThreadManager::Get()->GetShillManagerClient()-> 746 DBusThreadManager::Get()->GetShillManagerClient()->
705 CallGetPropertiesAndBlock()); 747 CallGetPropertiesAndBlock());
706 if (!manager_properties.get()) { 748 if (!manager_properties.get()) {
707 LOG(WARNING) << "Couldn't read managers's properties"; 749 LOG(WARNING) << "Couldn't read managers's properties";
708 return false; 750 return false;
709 } 751 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 result->push_back(ap); 822 result->push_back(ap);
781 } 823 }
782 } 824 }
783 if (!found_at_least_one_device) 825 if (!found_at_least_one_device)
784 return false; // No powered device found that has a 'Networks' array. 826 return false; // No powered device found that has a 'Networks' array.
785 return true; 827 return true;
786 } 828 }
787 829
788 void CrosConfigureService(const base::DictionaryValue& properties) { 830 void CrosConfigureService(const base::DictionaryValue& properties) {
789 DBusThreadManager::Get()->GetShillManagerClient()->ConfigureService( 831 DBusThreadManager::Get()->GetShillManagerClient()->ConfigureService(
790 properties, base::Bind(&DoNothing)); 832 properties, base::Bind(&DoNothing),
833 base::Bind(&IgnoreErrors));
791 } 834 }
792 835
793 std::string CrosPrefixLengthToNetmask(int32 prefix_length) { 836 std::string CrosPrefixLengthToNetmask(int32 prefix_length) {
794 std::string netmask; 837 std::string netmask;
795 // Return the empty string for invalid inputs. 838 // Return the empty string for invalid inputs.
796 if (prefix_length < 0 || prefix_length > 32) 839 if (prefix_length < 0 || prefix_length > 32)
797 return netmask; 840 return netmask;
798 for (int i = 0; i < 4; i++) { 841 for (int i = 0; i < 4; i++) {
799 int remainder = 8; 842 int remainder = 8;
800 if (prefix_length >= 8) { 843 if (prefix_length >= 8) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 const std::string& carrier, 904 const std::string& carrier,
862 const NetworkOperationCallback& callback) { 905 const NetworkOperationCallback& callback) {
863 DBusThreadManager::Get()->GetShillDeviceClient()->SetCarrier( 906 DBusThreadManager::Get()->GetShillDeviceClient()->SetCarrier(
864 dbus::ObjectPath(device_path), carrier, 907 dbus::ObjectPath(device_path), carrier,
865 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, 908 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE,
866 std::string()), 909 std::string()),
867 base::Bind(&OnNetworkActionError, callback, device_path)); 910 base::Bind(&OnNetworkActionError, callback, device_path));
868 } 911 }
869 912
870 } // namespace chromeos 913 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/cros_network_functions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698