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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 base::ThreadTaskRunnerHandle::Get()->PostTask( | 178 base::ThreadTaskRunnerHandle::Get()->PostTask( |
179 FROM_HERE, base::Bind(&FakeShillManagerClient::PassStubGeoNetworks, | 179 FROM_HERE, base::Bind(&FakeShillManagerClient::PassStubGeoNetworks, |
180 weak_ptr_factory_.GetWeakPtr(), callback)); | 180 weak_ptr_factory_.GetWeakPtr(), callback)); |
181 } | 181 } |
182 | 182 |
183 void FakeShillManagerClient::SetProperty(const std::string& name, | 183 void FakeShillManagerClient::SetProperty(const std::string& name, |
184 const base::Value& value, | 184 const base::Value& value, |
185 const base::Closure& callback, | 185 const base::Closure& callback, |
186 const ErrorCallback& error_callback) { | 186 const ErrorCallback& error_callback) { |
187 VLOG(2) << "SetProperty: " << name; | 187 VLOG(2) << "SetProperty: " << name; |
188 stub_properties_.SetWithoutPathExpansion(name, value.DeepCopy()); | 188 stub_properties_.SetWithoutPathExpansion(name, value.CreateDeepCopy()); |
189 CallNotifyObserversPropertyChanged(name); | 189 CallNotifyObserversPropertyChanged(name); |
190 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); | 190 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
191 } | 191 } |
192 | 192 |
193 void FakeShillManagerClient::RequestScan(const std::string& type, | 193 void FakeShillManagerClient::RequestScan(const std::string& type, |
194 const base::Closure& callback, | 194 const base::Closure& callback, |
195 const ErrorCallback& error_callback) { | 195 const ErrorCallback& error_callback) { |
196 VLOG(1) << "RequestScan: " << type; | 196 VLOG(1) << "RequestScan: " << type; |
197 // For Stub purposes, default to a Wifi scan. | 197 // For Stub purposes, default to a Wifi scan. |
198 std::string device_type = shill::kTypeWifi; | 198 std::string device_type = shill::kTypeWifi; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 } | 447 } |
448 } | 448 } |
449 } | 449 } |
450 | 450 |
451 void FakeShillManagerClient::AddGeoNetwork( | 451 void FakeShillManagerClient::AddGeoNetwork( |
452 const std::string& technology, | 452 const std::string& technology, |
453 const base::DictionaryValue& network) { | 453 const base::DictionaryValue& network) { |
454 base::ListValue* list_value = NULL; | 454 base::ListValue* list_value = NULL; |
455 if (!stub_geo_networks_.GetListWithoutPathExpansion(technology, | 455 if (!stub_geo_networks_.GetListWithoutPathExpansion(technology, |
456 &list_value)) { | 456 &list_value)) { |
457 list_value = new base::ListValue; | 457 stub_geo_networks_.SetWithoutPathExpansion( |
458 stub_geo_networks_.SetWithoutPathExpansion(technology, list_value); | 458 technology, base::MakeUnique<base::ListValue>()); |
| 459 stub_geo_networks_.GetListWithoutPathExpansion(technology, &list_value); |
459 } | 460 } |
460 list_value->Append(network.CreateDeepCopy()); | 461 list_value->Append(network.CreateDeepCopy()); |
461 } | 462 } |
462 | 463 |
463 void FakeShillManagerClient::AddProfile(const std::string& profile_path) { | 464 void FakeShillManagerClient::AddProfile(const std::string& profile_path) { |
464 const char* key = shill::kProfilesProperty; | 465 const char* key = shill::kProfilesProperty; |
465 if (GetListProperty(key)->AppendIfNotPresent( | 466 if (GetListProperty(key)->AppendIfNotPresent( |
466 base::MakeUnique<base::Value>(profile_path))) { | 467 base::MakeUnique<base::Value>(profile_path))) { |
467 CallNotifyObserversPropertyChanged(key); | 468 CallNotifyObserversPropertyChanged(key); |
468 } | 469 } |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 observer.OnPropertyChanged(property, *(services.get())); | 970 observer.OnPropertyChanged(property, *(services.get())); |
970 return; | 971 return; |
971 } | 972 } |
972 for (auto& observer : observer_list_) | 973 for (auto& observer : observer_list_) |
973 observer.OnPropertyChanged(property, *value); | 974 observer.OnPropertyChanged(property, *value); |
974 } | 975 } |
975 | 976 |
976 base::ListValue* FakeShillManagerClient::GetListProperty( | 977 base::ListValue* FakeShillManagerClient::GetListProperty( |
977 const std::string& property) { | 978 const std::string& property) { |
978 base::ListValue* list_property = NULL; | 979 base::ListValue* list_property = NULL; |
979 if (!stub_properties_.GetListWithoutPathExpansion( | 980 if (!stub_properties_.GetListWithoutPathExpansion(property, &list_property)) { |
980 property, &list_property)) { | 981 stub_properties_.SetWithoutPathExpansion( |
981 list_property = new base::ListValue; | 982 property, base::MakeUnique<base::ListValue>()); |
982 stub_properties_.SetWithoutPathExpansion(property, list_property); | 983 stub_properties_.GetListWithoutPathExpansion(property, &list_property); |
983 } | 984 } |
984 return list_property; | 985 return list_property; |
985 } | 986 } |
986 | 987 |
987 bool FakeShillManagerClient::TechnologyEnabled(const std::string& type) const { | 988 bool FakeShillManagerClient::TechnologyEnabled(const std::string& type) const { |
988 if (type == shill::kTypeVPN) | 989 if (type == shill::kTypeVPN) |
989 return true; // VPN is always "enabled" since there is no associated device | 990 return true; // VPN is always "enabled" since there is no associated device |
990 if (type == shill::kTypeEthernetEap) | 991 if (type == shill::kTypeEthernetEap) |
991 return true; | 992 return true; |
992 bool enabled = false; | 993 bool enabled = false; |
(...skipping 17 matching lines...) Expand all Loading... |
1010 enabled_list->AppendIfNotPresent(base::MakeUnique<base::Value>(type)); | 1011 enabled_list->AppendIfNotPresent(base::MakeUnique<base::Value>(type)); |
1011 else | 1012 else |
1012 enabled_list->Remove(base::Value(type), NULL); | 1013 enabled_list->Remove(base::Value(type), NULL); |
1013 CallNotifyObserversPropertyChanged( | 1014 CallNotifyObserversPropertyChanged( |
1014 shill::kEnabledTechnologiesProperty); | 1015 shill::kEnabledTechnologiesProperty); |
1015 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); | 1016 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
1016 // May affect available services. | 1017 // May affect available services. |
1017 SortManagerServices(true); | 1018 SortManagerServices(true); |
1018 } | 1019 } |
1019 | 1020 |
1020 base::ListValue* FakeShillManagerClient::GetEnabledServiceList( | 1021 std::unique_ptr<base::ListValue> FakeShillManagerClient::GetEnabledServiceList( |
1021 const std::string& property) const { | 1022 const std::string& property) const { |
1022 base::ListValue* new_service_list = new base::ListValue; | 1023 auto new_service_list = base::MakeUnique<base::ListValue>(); |
1023 const base::ListValue* service_list; | 1024 const base::ListValue* service_list; |
1024 if (stub_properties_.GetListWithoutPathExpansion(property, &service_list)) { | 1025 if (stub_properties_.GetListWithoutPathExpansion(property, &service_list)) { |
1025 ShillServiceClient::TestInterface* service_client = | 1026 ShillServiceClient::TestInterface* service_client = |
1026 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 1027 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
1027 for (base::ListValue::const_iterator iter = service_list->begin(); | 1028 for (base::ListValue::const_iterator iter = service_list->begin(); |
1028 iter != service_list->end(); ++iter) { | 1029 iter != service_list->end(); ++iter) { |
1029 std::string service_path; | 1030 std::string service_path; |
1030 if (!iter->GetAsString(&service_path)) | 1031 if (!iter->GetAsString(&service_path)) |
1031 continue; | 1032 continue; |
1032 const base::DictionaryValue* properties = | 1033 const base::DictionaryValue* properties = |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 LOG(WARNING) << "Invalid state: " << state << " for " << type; | 1229 LOG(WARNING) << "Invalid state: " << state << " for " << type; |
1229 result = shill::kStateIdle; | 1230 result = shill::kStateIdle; |
1230 } | 1231 } |
1231 } | 1232 } |
1232 VLOG(1) << "Initial state for: " << type << " = " << result | 1233 VLOG(1) << "Initial state for: " << type << " = " << result |
1233 << " Enabled: " << *enabled; | 1234 << " Enabled: " << *enabled; |
1234 return result; | 1235 return result; |
1235 } | 1236 } |
1236 | 1237 |
1237 } // namespace chromeos | 1238 } // namespace chromeos |
OLD | NEW |