| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/fake_shill_manager_client.h" | 5 #include "chromeos/dbus/fake_shill_manager_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 const base::Value* first_; | 38 const base::Value* first_; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // Appends string entries from |service_list_in| whose entries in ServiceClient | 41 // Appends string entries from |service_list_in| whose entries in ServiceClient |
| 42 // have Type |match_type| to either an active list or an inactive list | 42 // have Type |match_type| to either an active list or an inactive list |
| 43 // based on the entry's State. | 43 // based on the entry's State. |
| 44 void AppendServicesForType( | 44 void AppendServicesForType( |
| 45 const base::ListValue* service_list_in, | 45 const base::ListValue* service_list_in, |
| 46 const char* match_type, | 46 const char* match_type, |
| 47 bool technology_enabled, |
| 47 std::vector<std::string>* active_service_list_out, | 48 std::vector<std::string>* active_service_list_out, |
| 48 std::vector<std::string>* inactive_service_list_out) { | 49 std::vector<std::string>* inactive_service_list_out, |
| 50 std::vector<std::string>* disabled_service_list_out) { |
| 49 ShillServiceClient::TestInterface* service_client = | 51 ShillServiceClient::TestInterface* service_client = |
| 50 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 52 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
| 51 for (base::ListValue::const_iterator iter = service_list_in->begin(); | 53 for (base::ListValue::const_iterator iter = service_list_in->begin(); |
| 52 iter != service_list_in->end(); ++iter) { | 54 iter != service_list_in->end(); ++iter) { |
| 53 std::string service_path; | 55 std::string service_path; |
| 54 if (!(*iter)->GetAsString(&service_path)) | 56 if (!(*iter)->GetAsString(&service_path)) |
| 55 continue; | 57 continue; |
| 56 const base::DictionaryValue* properties = | 58 const base::DictionaryValue* properties = |
| 57 service_client->GetServiceProperties(service_path); | 59 service_client->GetServiceProperties(service_path); |
| 58 if (!properties) { | 60 if (!properties) { |
| 59 LOG(ERROR) << "Properties not found for service: " << service_path; | 61 LOG(ERROR) << "Properties not found for service: " << service_path; |
| 60 continue; | 62 continue; |
| 61 } | 63 } |
| 62 std::string type; | 64 std::string type; |
| 63 properties->GetString(shill::kTypeProperty, &type); | 65 properties->GetString(shill::kTypeProperty, &type); |
| 64 if (type != match_type) | 66 if (type != match_type) |
| 65 continue; | 67 continue; |
| 68 bool visible = false; |
| 69 if (technology_enabled) |
| 70 properties->GetBoolean(shill::kVisibleProperty, &visible); |
| 71 if (!visible) { |
| 72 disabled_service_list_out->push_back(service_path); |
| 73 continue; |
| 74 } |
| 66 std::string state; | 75 std::string state; |
| 67 properties->GetString(shill::kStateProperty, &state); | 76 properties->GetString(shill::kStateProperty, &state); |
| 68 if (state == shill::kStateOnline || | 77 if (state == shill::kStateOnline || |
| 69 state == shill::kStateAssociation || | 78 state == shill::kStateAssociation || |
| 70 state == shill::kStateConfiguration || | 79 state == shill::kStateConfiguration || |
| 71 state == shill::kStatePortal || | 80 state == shill::kStatePortal || |
| 72 state == shill::kStateReady) { | 81 state == shill::kStateReady) { |
| 73 active_service_list_out->push_back(service_path); | 82 active_service_list_out->push_back(service_path); |
| 74 } else { | 83 } else { |
| 75 inactive_service_list_out->push_back(service_path); | 84 inactive_service_list_out->push_back(service_path); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 observer_list_.AddObserver(observer); | 129 observer_list_.AddObserver(observer); |
| 121 } | 130 } |
| 122 | 131 |
| 123 void FakeShillManagerClient::RemovePropertyChangedObserver( | 132 void FakeShillManagerClient::RemovePropertyChangedObserver( |
| 124 ShillPropertyChangedObserver* observer) { | 133 ShillPropertyChangedObserver* observer) { |
| 125 observer_list_.RemoveObserver(observer); | 134 observer_list_.RemoveObserver(observer); |
| 126 } | 135 } |
| 127 | 136 |
| 128 void FakeShillManagerClient::GetProperties( | 137 void FakeShillManagerClient::GetProperties( |
| 129 const DictionaryValueCallback& callback) { | 138 const DictionaryValueCallback& callback) { |
| 139 DVLOG(1) << "Manager.GetProperties"; |
| 130 base::MessageLoop::current()->PostTask( | 140 base::MessageLoop::current()->PostTask( |
| 131 FROM_HERE, base::Bind( | 141 FROM_HERE, base::Bind( |
| 132 &FakeShillManagerClient::PassStubProperties, | 142 &FakeShillManagerClient::PassStubProperties, |
| 133 weak_ptr_factory_.GetWeakPtr(), | 143 weak_ptr_factory_.GetWeakPtr(), |
| 134 callback)); | 144 callback)); |
| 135 } | 145 } |
| 136 | 146 |
| 137 void FakeShillManagerClient::GetNetworksForGeolocation( | 147 void FakeShillManagerClient::GetNetworksForGeolocation( |
| 138 const DictionaryValueCallback& callback) { | 148 const DictionaryValueCallback& callback) { |
| 139 base::MessageLoop::current()->PostTask( | 149 base::MessageLoop::current()->PostTask( |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 void FakeShillManagerClient::ClearProperties() { | 449 void FakeShillManagerClient::ClearProperties() { |
| 440 stub_properties_.Clear(); | 450 stub_properties_.Clear(); |
| 441 } | 451 } |
| 442 | 452 |
| 443 void FakeShillManagerClient::SetManagerProperty(const std::string& key, | 453 void FakeShillManagerClient::SetManagerProperty(const std::string& key, |
| 444 const base::Value& value) { | 454 const base::Value& value) { |
| 445 SetProperty(key, value, | 455 SetProperty(key, value, |
| 446 base::Bind(&base::DoNothing), base::Bind(&LogErrorCallback)); | 456 base::Bind(&base::DoNothing), base::Bind(&LogErrorCallback)); |
| 447 } | 457 } |
| 448 | 458 |
| 449 void FakeShillManagerClient::AddManagerService(const std::string& service_path, | 459 void FakeShillManagerClient::AddManagerService( |
| 450 bool add_to_visible_list) { | 460 const std::string& service_path) { |
| 451 DVLOG(2) << "AddManagerService: " << service_path | 461 DVLOG(2) << "AddManagerService: " << service_path; |
| 452 << " Visible: " << add_to_visible_list; | |
| 453 // Always add to ServiceCompleteListProperty. | |
| 454 GetListProperty(shill::kServiceCompleteListProperty)->AppendIfNotPresent( | 462 GetListProperty(shill::kServiceCompleteListProperty)->AppendIfNotPresent( |
| 455 base::Value::CreateStringValue(service_path)); | 463 base::Value::CreateStringValue(service_path)); |
| 456 // If visible, add to Services and notify if new. | 464 SortManagerServices(false); |
| 457 if (add_to_visible_list && | 465 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); |
| 458 GetListProperty(shill::kServicesProperty)->AppendIfNotPresent( | 466 // SortManagerServices will add the service to Services if it is visible. |
| 459 base::Value::CreateStringValue(service_path))) { | 467 const base::ListValue* services = GetListProperty(shill::kServicesProperty); |
| 468 if (services->Find(base::StringValue(service_path)) |
| 469 != services->end()) { |
| 460 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 470 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
| 461 } | 471 } |
| 462 } | 472 } |
| 463 | 473 |
| 464 void FakeShillManagerClient::RemoveManagerService( | 474 void FakeShillManagerClient::RemoveManagerService( |
| 465 const std::string& service_path, | 475 const std::string& service_path) { |
| 466 bool remove_from_complete_list) { | |
| 467 DVLOG(2) << "RemoveManagerService: " << service_path; | 476 DVLOG(2) << "RemoveManagerService: " << service_path; |
| 468 base::StringValue service_path_value(service_path); | 477 base::StringValue service_path_value(service_path); |
| 469 if (remove_from_complete_list) { | 478 GetListProperty(shill::kServiceCompleteListProperty)->Remove( |
| 470 GetListProperty(shill::kServiceCompleteListProperty)->Remove( | 479 service_path_value, NULL); |
| 471 service_path_value, NULL); | 480 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); |
| 472 } | |
| 473 if (GetListProperty(shill::kServicesProperty)->Remove( | 481 if (GetListProperty(shill::kServicesProperty)->Remove( |
| 474 service_path_value, NULL)) { | 482 service_path_value, NULL)) { |
| 475 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 483 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
| 476 } | 484 } |
| 477 } | 485 } |
| 478 | 486 |
| 479 void FakeShillManagerClient::ClearManagerServices() { | 487 void FakeShillManagerClient::ClearManagerServices() { |
| 480 DVLOG(1) << "ClearManagerServices"; | 488 DVLOG(1) << "ClearManagerServices"; |
| 481 GetListProperty(shill::kServiceCompleteListProperty)->Clear(); | 489 GetListProperty(shill::kServiceCompleteListProperty)->Clear(); |
| 482 GetListProperty(shill::kServicesProperty)->Clear(); | 490 GetListProperty(shill::kServicesProperty)->Clear(); |
| 491 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); |
| 483 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 492 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
| 484 } | 493 } |
| 485 | 494 |
| 486 void FakeShillManagerClient::ServiceStateChanged( | 495 void FakeShillManagerClient::ServiceStateChanged( |
| 487 const std::string& service_path, | 496 const std::string& service_path, |
| 488 const std::string& state) { | 497 const std::string& state) { |
| 489 if (service_path == default_service_ && !IsConnectedState(state)) { | 498 if (service_path == default_service_ && !IsConnectedState(state)) { |
| 490 // Default service is no longer connected; clear. | 499 // Default service is no longer connected; clear. |
| 491 default_service_.clear(); | 500 default_service_.clear(); |
| 492 base::StringValue default_service_value(default_service_); | 501 base::StringValue default_service_value(default_service_); |
| 493 SetManagerProperty(shill::kDefaultServiceProperty, default_service_value); | 502 SetManagerProperty(shill::kDefaultServiceProperty, default_service_value); |
| 494 } | 503 } |
| 495 } | 504 } |
| 496 | 505 |
| 497 void FakeShillManagerClient::SortManagerServices() { | 506 void FakeShillManagerClient::SortManagerServices(bool notify) { |
| 498 DVLOG(1) << "SortManagerServices"; | 507 DVLOG(1) << "SortManagerServices"; |
| 499 SortServiceList(shill::kServicesProperty); | 508 static const char* ordered_types[] = {shill::kTypeEthernet, |
| 500 SortServiceList(shill::kServiceCompleteListProperty); | 509 shill::kTypeWifi, |
| 501 } | 510 shill::kTypeCellular, |
| 511 shill::kTypeWimax, |
| 512 shill::kTypeVPN}; |
| 502 | 513 |
| 503 void FakeShillManagerClient::SortServiceList(const std::string& property) { | 514 base::ListValue* service_list = GetListProperty(shill::kServicesProperty); |
| 504 static const char* ordered_types[] = { | 515 scoped_ptr<base::ListValue> prev_service_list(service_list->DeepCopy()); |
| 505 shill::kTypeEthernet, | 516 base::ListValue* complete_list = |
| 506 shill::kTypeWifi, | 517 GetListProperty(shill::kServiceCompleteListProperty); |
| 507 shill::kTypeCellular, | 518 if (!complete_list || complete_list->empty()) |
| 508 shill::kTypeWimax, | 519 return; |
| 509 shill::kTypeVPN | 520 scoped_ptr<base::ListValue> prev_complete_list(complete_list->DeepCopy()); |
| 510 }; | |
| 511 | 521 |
| 512 base::ListValue* service_list = GetListProperty(property); | |
| 513 scoped_ptr<base::ListValue> prev_service_list(service_list->DeepCopy()); | |
| 514 std::vector<std::string> active_services; | 522 std::vector<std::string> active_services; |
| 515 std::vector<std::string> inactive_services; | 523 std::vector<std::string> inactive_services; |
| 516 if (service_list && !service_list->empty()) { | 524 std::vector<std::string> disabled_services; |
| 517 for (size_t i = 0; i < arraysize(ordered_types); ++i) { | 525 for (size_t i = 0; i < arraysize(ordered_types); ++i) { |
| 518 AppendServicesForType(service_list, ordered_types[i], | 526 AppendServicesForType(complete_list, |
| 519 &active_services, &inactive_services); | 527 ordered_types[i], |
| 520 } | 528 TechnologyEnabled(ordered_types[i]), |
| 521 service_list->Clear(); | 529 &active_services, |
| 522 for (size_t i = 0; i < active_services.size(); ++i) | 530 &inactive_services, |
| 523 service_list->AppendString(active_services[i]); | 531 &disabled_services); |
| 524 for (size_t i = 0; i < inactive_services.size(); ++i) | 532 } |
| 525 service_list->AppendString(inactive_services[i]); | 533 service_list->Clear(); |
| 534 complete_list->Clear(); |
| 535 for (size_t i = 0; i < active_services.size(); ++i) { |
| 536 complete_list->AppendString(active_services[i]); |
| 537 service_list->AppendString(active_services[i]); |
| 538 } |
| 539 for (size_t i = 0; i < inactive_services.size(); ++i) { |
| 540 complete_list->AppendString(inactive_services[i]); |
| 541 service_list->AppendString(inactive_services[i]); |
| 542 } |
| 543 for (size_t i = 0; i < disabled_services.size(); ++i) { |
| 544 complete_list->AppendString(disabled_services[i]); |
| 526 } | 545 } |
| 527 | 546 |
| 528 if (property != shill::kServicesProperty) | 547 if (notify) { |
| 529 return; | 548 if (!service_list->Equals(prev_service_list.get())) |
| 530 | 549 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
| 531 if (!service_list->Equals(prev_service_list.get())) | 550 if (!complete_list->Equals(prev_complete_list.get())) |
| 532 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 551 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); |
| 552 } |
| 533 | 553 |
| 534 // Set the first active service as the Default service. | 554 // Set the first active service as the Default service. |
| 535 std::string new_default_service; | 555 std::string new_default_service; |
| 536 if (!active_services.empty()) { | 556 if (!active_services.empty()) { |
| 537 ShillServiceClient::TestInterface* service_client = | 557 ShillServiceClient::TestInterface* service_client = |
| 538 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 558 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
| 539 std::string service_path = active_services[0]; | 559 std::string service_path = active_services[0]; |
| 540 const base::DictionaryValue* properties = | 560 const base::DictionaryValue* properties = |
| 541 service_client->GetServiceProperties(service_path); | 561 service_client->GetServiceProperties(service_path); |
| 542 if (!properties) { | 562 if (!properties) { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 796 |
| 777 services->AddService("/service/vpn2", | 797 services->AddService("/service/vpn2", |
| 778 "vpn2", | 798 "vpn2", |
| 779 shill::kTypeVPN, | 799 shill::kTypeVPN, |
| 780 shill::kStateIdle, | 800 shill::kStateIdle, |
| 781 add_to_visible); | 801 add_to_visible); |
| 782 services->SetServiceProperty( | 802 services->SetServiceProperty( |
| 783 "/service/vpn2", shill::kProviderProperty, provider_properties); | 803 "/service/vpn2", shill::kProviderProperty, provider_properties); |
| 784 } | 804 } |
| 785 | 805 |
| 786 SortManagerServices(); | 806 SortManagerServices(true); |
| 787 } | 807 } |
| 788 | 808 |
| 789 // Private methods | 809 // Private methods |
| 790 | 810 |
| 791 void FakeShillManagerClient::PassStubProperties( | 811 void FakeShillManagerClient::PassStubProperties( |
| 792 const DictionaryValueCallback& callback) const { | 812 const DictionaryValueCallback& callback) const { |
| 793 scoped_ptr<base::DictionaryValue> stub_properties( | 813 scoped_ptr<base::DictionaryValue> stub_properties( |
| 794 stub_properties_.DeepCopy()); | 814 stub_properties_.DeepCopy()); |
| 795 // Remove disabled services from the list. | |
| 796 stub_properties->SetWithoutPathExpansion( | |
| 797 shill::kServicesProperty, | |
| 798 GetEnabledServiceList(shill::kServicesProperty)); | |
| 799 callback.Run(DBUS_METHOD_CALL_SUCCESS, *stub_properties); | 815 callback.Run(DBUS_METHOD_CALL_SUCCESS, *stub_properties); |
| 800 } | 816 } |
| 801 | 817 |
| 802 void FakeShillManagerClient::PassStubGeoNetworks( | 818 void FakeShillManagerClient::PassStubGeoNetworks( |
| 803 const DictionaryValueCallback& callback) const { | 819 const DictionaryValueCallback& callback) const { |
| 804 callback.Run(DBUS_METHOD_CALL_SUCCESS, stub_geo_networks_); | 820 callback.Run(DBUS_METHOD_CALL_SUCCESS, stub_geo_networks_); |
| 805 } | 821 } |
| 806 | 822 |
| 807 void FakeShillManagerClient::CallNotifyObserversPropertyChanged( | 823 void FakeShillManagerClient::CallNotifyObserversPropertyChanged( |
| 808 const std::string& property) { | 824 const std::string& property) { |
| 809 // Avoid unnecessary delayed task if we have no observers (e.g. during | 825 // Avoid unnecessary delayed task if we have no observers (e.g. during |
| 810 // initial setup). | 826 // initial setup). |
| 811 if (!observer_list_.might_have_observers()) | 827 if (!observer_list_.might_have_observers()) |
| 812 return; | 828 return; |
| 813 base::MessageLoop::current()->PostTask( | 829 base::MessageLoop::current()->PostTask( |
| 814 FROM_HERE, | 830 FROM_HERE, |
| 815 base::Bind(&FakeShillManagerClient::NotifyObserversPropertyChanged, | 831 base::Bind(&FakeShillManagerClient::NotifyObserversPropertyChanged, |
| 816 weak_ptr_factory_.GetWeakPtr(), | 832 weak_ptr_factory_.GetWeakPtr(), |
| 817 property)); | 833 property)); |
| 818 } | 834 } |
| 819 | 835 |
| 820 void FakeShillManagerClient::NotifyObserversPropertyChanged( | 836 void FakeShillManagerClient::NotifyObserversPropertyChanged( |
| 821 const std::string& property) { | 837 const std::string& property) { |
| 822 DVLOG(1) << "NotifyObserversPropertyChanged: " << property; | 838 DVLOG(1) << "NotifyObserversPropertyChanged: " << property; |
| 823 if (property == shill::kServicesProperty) { | |
| 824 scoped_ptr<base::ListValue> services(GetEnabledServiceList(property)); | |
| 825 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, | |
| 826 observer_list_, | |
| 827 OnPropertyChanged(property, *(services.get()))); | |
| 828 return; | |
| 829 } | |
| 830 if (property == shill::kDevicesProperty) { | |
| 831 base::ListValue* devices = NULL; | |
| 832 if (stub_properties_.GetListWithoutPathExpansion( | |
| 833 shill::kDevicesProperty, &devices)) { | |
| 834 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, | |
| 835 observer_list_, | |
| 836 OnPropertyChanged(property, *devices)); | |
| 837 } | |
| 838 return; | |
| 839 } | |
| 840 base::Value* value = NULL; | 839 base::Value* value = NULL; |
| 841 if (!stub_properties_.GetWithoutPathExpansion(property, &value)) { | 840 if (!stub_properties_.GetWithoutPathExpansion(property, &value)) { |
| 842 LOG(ERROR) << "Notify for unknown property: " << property; | 841 LOG(ERROR) << "Notify for unknown property: " << property; |
| 843 return; | 842 return; |
| 844 } | 843 } |
| 845 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, | 844 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, |
| 846 observer_list_, | 845 observer_list_, |
| 847 OnPropertyChanged(property, *value)); | 846 OnPropertyChanged(property, *value)); |
| 848 } | 847 } |
| 849 | 848 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 878 bool enabled) { | 877 bool enabled) { |
| 879 base::ListValue* enabled_list = | 878 base::ListValue* enabled_list = |
| 880 GetListProperty(shill::kEnabledTechnologiesProperty); | 879 GetListProperty(shill::kEnabledTechnologiesProperty); |
| 881 if (enabled) | 880 if (enabled) |
| 882 enabled_list->AppendIfNotPresent(new base::StringValue(type)); | 881 enabled_list->AppendIfNotPresent(new base::StringValue(type)); |
| 883 else | 882 else |
| 884 enabled_list->Remove(base::StringValue(type), NULL); | 883 enabled_list->Remove(base::StringValue(type), NULL); |
| 885 CallNotifyObserversPropertyChanged( | 884 CallNotifyObserversPropertyChanged( |
| 886 shill::kEnabledTechnologiesProperty); | 885 shill::kEnabledTechnologiesProperty); |
| 887 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 886 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
| 888 // May affect available services | 887 // May affect available services. |
| 889 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 888 SortManagerServices(true); |
| 890 } | |
| 891 | |
| 892 base::ListValue* FakeShillManagerClient::GetEnabledServiceList( | |
| 893 const std::string& property) const { | |
| 894 base::ListValue* new_service_list = new base::ListValue; | |
| 895 const base::ListValue* service_list; | |
| 896 if (stub_properties_.GetListWithoutPathExpansion(property, &service_list)) { | |
| 897 ShillServiceClient::TestInterface* service_client = | |
| 898 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | |
| 899 for (base::ListValue::const_iterator iter = service_list->begin(); | |
| 900 iter != service_list->end(); ++iter) { | |
| 901 std::string service_path; | |
| 902 if (!(*iter)->GetAsString(&service_path)) | |
| 903 continue; | |
| 904 const base::DictionaryValue* properties = | |
| 905 service_client->GetServiceProperties(service_path); | |
| 906 if (!properties) { | |
| 907 LOG(ERROR) << "Properties not found for service: " << service_path; | |
| 908 continue; | |
| 909 } | |
| 910 std::string type; | |
| 911 properties->GetString(shill::kTypeProperty, &type); | |
| 912 if (TechnologyEnabled(type)) | |
| 913 new_service_list->Append((*iter)->DeepCopy()); | |
| 914 } | |
| 915 } | |
| 916 return new_service_list; | |
| 917 } | 889 } |
| 918 | 890 |
| 919 void FakeShillManagerClient::ScanCompleted(const std::string& device_path, | 891 void FakeShillManagerClient::ScanCompleted(const std::string& device_path, |
| 920 const base::Closure& callback) { | 892 const base::Closure& callback) { |
| 921 if (!device_path.empty()) { | 893 if (!device_path.empty()) { |
| 922 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> | 894 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> |
| 923 SetDeviceProperty(device_path, | 895 SetDeviceProperty(device_path, |
| 924 shill::kScanningProperty, | 896 shill::kScanningProperty, |
| 925 base::FundamentalValue(false)); | 897 base::FundamentalValue(false)); |
| 926 } | 898 } |
| 927 DVLOG(2) << "ScanCompleted"; | 899 DVLOG(2) << "ScanCompleted"; |
| 928 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 900 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); |
| 929 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 901 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
| 930 } | 902 } |
| 931 | 903 |
| 932 void FakeShillManagerClient::ParseCommandLineSwitch() { | 904 void FakeShillManagerClient::ParseCommandLineSwitch() { |
| 933 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 905 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 934 if (command_line->HasSwitch(switches::kShillStub)) { | 906 if (command_line->HasSwitch(switches::kShillStub)) { |
| 935 std::string option_str = | 907 std::string option_str = |
| 936 command_line->GetSwitchValueASCII(switches::kShillStub); | 908 command_line->GetSwitchValueASCII(switches::kShillStub); |
| 937 base::StringPairs string_pairs; | 909 base::StringPairs string_pairs; |
| 938 base::SplitStringIntoKeyValuePairs(option_str, '=', ',', &string_pairs); | 910 base::SplitStringIntoKeyValuePairs(option_str, '=', ',', &string_pairs); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 *enabled = true; | 1010 *enabled = true; |
| 1039 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || | 1011 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || |
| 1040 (state == kNetworkActivated && type != shill::kTypeCellular)) { | 1012 (state == kNetworkActivated && type != shill::kTypeCellular)) { |
| 1041 LOG(WARNING) << "Invalid state: " << state << " for " << type; | 1013 LOG(WARNING) << "Invalid state: " << state << " for " << type; |
| 1042 return shill::kStateIdle; | 1014 return shill::kStateIdle; |
| 1043 } | 1015 } |
| 1044 return state; | 1016 return state; |
| 1045 } | 1017 } |
| 1046 | 1018 |
| 1047 } // namespace chromeos | 1019 } // namespace chromeos |
| OLD | NEW |