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" | |
9 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
10 #include "base/values.h" | 9 #include "base/values.h" |
11 #include "chromeos/chromeos_switches.h" | |
12 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
13 #include "chromeos/dbus/shill_device_client.h" | 11 #include "chromeos/dbus/shill_device_client.h" |
14 #include "chromeos/dbus/shill_profile_client.h" | 12 #include "chromeos/dbus/shill_profile_client.h" |
15 #include "chromeos/dbus/shill_property_changed_observer.h" | 13 #include "chromeos/dbus/shill_property_changed_observer.h" |
16 #include "chromeos/dbus/shill_service_client.h" | 14 #include "chromeos/dbus/shill_service_client.h" |
17 #include "dbus/bus.h" | 15 #include "dbus/bus.h" |
18 #include "dbus/message.h" | 16 #include "dbus/message.h" |
19 #include "dbus/object_path.h" | 17 #include "dbus/object_path.h" |
20 #include "dbus/values_util.h" | 18 #include "dbus/values_util.h" |
21 #include "third_party/cros_system_api/dbus/service_constants.h" | 19 #include "third_party/cros_system_api/dbus/service_constants.h" |
(...skipping 16 matching lines...) Expand all Loading... |
38 // have Type |match_type| to either an active list or an inactive list | 36 // have Type |match_type| to either an active list or an inactive list |
39 // based on the entry's State. | 37 // based on the entry's State. |
40 void AppendServicesForType( | 38 void AppendServicesForType( |
41 const base::ListValue* service_list_in, | 39 const base::ListValue* service_list_in, |
42 const char* match_type, | 40 const char* match_type, |
43 std::vector<std::string>* active_service_list_out, | 41 std::vector<std::string>* active_service_list_out, |
44 std::vector<std::string>* inactive_service_list_out) { | 42 std::vector<std::string>* inactive_service_list_out) { |
45 ShillServiceClient::TestInterface* service_client = | 43 ShillServiceClient::TestInterface* service_client = |
46 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 44 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
47 for (base::ListValue::const_iterator iter = service_list_in->begin(); | 45 for (base::ListValue::const_iterator iter = service_list_in->begin(); |
48 iter != service_list_in->end(); ++iter) { | 46 iter != service_list_in->end(); |
| 47 ++iter) { |
49 std::string service_path; | 48 std::string service_path; |
50 if (!(*iter)->GetAsString(&service_path)) | 49 if (!(*iter)->GetAsString(&service_path)) |
51 continue; | 50 continue; |
52 const base::DictionaryValue* properties = | 51 const base::DictionaryValue* properties = |
53 service_client->GetServiceProperties(service_path); | 52 service_client->GetServiceProperties(service_path); |
54 if (!properties) { | 53 if (!properties) { |
55 LOG(ERROR) << "Properties not found for service: " << service_path; | 54 LOG(ERROR) << "Properties not found for service: " << service_path; |
56 continue; | 55 continue; |
57 } | 56 } |
58 std::string type; | 57 std::string type; |
59 properties->GetString(shill::kTypeProperty, &type); | 58 properties->GetString(shill::kTypeProperty, &type); |
60 if (type != match_type) | 59 if (type != match_type) |
61 continue; | 60 continue; |
62 std::string state; | 61 std::string state; |
63 properties->GetString(shill::kStateProperty, &state); | 62 properties->GetString(shill::kStateProperty, &state); |
64 if (state == shill::kStateOnline || | 63 if (state == shill::kStateOnline || state == shill::kStateAssociation || |
65 state == shill::kStateAssociation || | 64 state == shill::kStateConfiguration || state == shill::kStatePortal || |
66 state == shill::kStateConfiguration || | |
67 state == shill::kStatePortal || | |
68 state == shill::kStateReady) { | 65 state == shill::kStateReady) { |
69 active_service_list_out->push_back(service_path); | 66 active_service_list_out->push_back(service_path); |
70 } else { | 67 } else { |
71 inactive_service_list_out->push_back(service_path); | 68 inactive_service_list_out->push_back(service_path); |
72 } | 69 } |
73 } | 70 } |
74 } | 71 } |
75 | 72 |
76 } // namespace | 73 } // namespace |
77 | 74 |
78 FakeShillManagerClient::FakeShillManagerClient() | 75 FakeShillManagerClient::FakeShillManagerClient() : weak_ptr_factory_(this) {} |
79 : weak_ptr_factory_(this) { | |
80 } | |
81 | 76 |
82 FakeShillManagerClient::~FakeShillManagerClient() {} | 77 FakeShillManagerClient::~FakeShillManagerClient() {} |
83 | 78 |
84 // ShillManagerClient overrides. | 79 // ShillManagerClient overrides. |
85 | 80 |
86 void FakeShillManagerClient::Init(dbus::Bus* bus) {} | 81 void FakeShillManagerClient::Init(dbus::Bus* bus) {} |
87 | 82 |
88 void FakeShillManagerClient::AddPropertyChangedObserver( | 83 void FakeShillManagerClient::AddPropertyChangedObserver( |
89 ShillPropertyChangedObserver* observer) { | 84 ShillPropertyChangedObserver* observer) { |
90 observer_list_.AddObserver(observer); | 85 observer_list_.AddObserver(observer); |
91 } | 86 } |
92 | 87 |
93 void FakeShillManagerClient::RemovePropertyChangedObserver( | 88 void FakeShillManagerClient::RemovePropertyChangedObserver( |
94 ShillPropertyChangedObserver* observer) { | 89 ShillPropertyChangedObserver* observer) { |
95 observer_list_.RemoveObserver(observer); | 90 observer_list_.RemoveObserver(observer); |
96 } | 91 } |
97 | 92 |
98 void FakeShillManagerClient::GetProperties( | 93 void FakeShillManagerClient::GetProperties( |
99 const DictionaryValueCallback& callback) { | 94 const DictionaryValueCallback& callback) { |
100 base::MessageLoop::current()->PostTask( | 95 base::MessageLoop::current()->PostTask( |
101 FROM_HERE, base::Bind( | 96 FROM_HERE, |
102 &FakeShillManagerClient::PassStubProperties, | 97 base::Bind(&FakeShillManagerClient::PassStubProperties, |
103 weak_ptr_factory_.GetWeakPtr(), | 98 weak_ptr_factory_.GetWeakPtr(), |
104 callback)); | 99 callback)); |
105 } | 100 } |
106 | 101 |
107 void FakeShillManagerClient::GetNetworksForGeolocation( | 102 void FakeShillManagerClient::GetNetworksForGeolocation( |
108 const DictionaryValueCallback& callback) { | 103 const DictionaryValueCallback& callback) { |
109 base::MessageLoop::current()->PostTask( | 104 base::MessageLoop::current()->PostTask( |
110 FROM_HERE, base::Bind( | 105 FROM_HERE, |
111 &FakeShillManagerClient::PassStubGeoNetworks, | 106 base::Bind(&FakeShillManagerClient::PassStubGeoNetworks, |
112 weak_ptr_factory_.GetWeakPtr(), | 107 weak_ptr_factory_.GetWeakPtr(), |
113 callback)); | 108 callback)); |
114 } | 109 } |
115 | 110 |
116 void FakeShillManagerClient::SetProperty(const std::string& name, | 111 void FakeShillManagerClient::SetProperty(const std::string& name, |
117 const base::Value& value, | 112 const base::Value& value, |
118 const base::Closure& callback, | 113 const base::Closure& callback, |
119 const ErrorCallback& error_callback) { | 114 const ErrorCallback& error_callback) { |
120 stub_properties_.SetWithoutPathExpansion(name, value.DeepCopy()); | 115 stub_properties_.SetWithoutPathExpansion(name, value.DeepCopy()); |
121 CallNotifyObserversPropertyChanged(name, 0); | 116 CallNotifyObserversPropertyChanged(name); |
122 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 117 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
123 } | 118 } |
124 | 119 |
125 void FakeShillManagerClient::RequestScan(const std::string& type, | 120 void FakeShillManagerClient::RequestScan(const std::string& type, |
126 const base::Closure& callback, | 121 const base::Closure& callback, |
127 const ErrorCallback& error_callback) { | 122 const ErrorCallback& error_callback) { |
128 // For Stub purposes, default to a Wifi scan. | 123 // For Stub purposes, default to a Wifi scan. |
129 std::string device_type = shill::kTypeWifi; | 124 std::string device_type = shill::kTypeWifi; |
130 if (!type.empty()) | 125 if (!type.empty()) |
131 device_type = type; | 126 device_type = type; |
132 ShillDeviceClient::TestInterface* device_client = | 127 ShillDeviceClient::TestInterface* device_client = |
133 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); | 128 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); |
134 std::string device_path = device_client->GetDevicePathForType(device_type); | 129 std::string device_path = device_client->GetDevicePathForType(device_type); |
135 if (!device_path.empty()) { | 130 if (!device_path.empty()) { |
136 device_client->SetDeviceProperty(device_path, | 131 device_client->SetDeviceProperty( |
137 shill::kScanningProperty, | 132 device_path, shill::kScanningProperty, base::FundamentalValue(true)); |
138 base::FundamentalValue(true)); | |
139 } | 133 } |
140 const int kScanDurationSeconds = 3; | 134 int scan_duration_seconds = |
141 int scan_duration_seconds = kScanDurationSeconds; | 135 DBusThreadManager::Get()->GetShillInteractiveDelay(); |
142 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
143 chromeos::switches::kEnableStubInteractive)) { | |
144 scan_duration_seconds = 0; | |
145 } | |
146 base::MessageLoop::current()->PostDelayedTask( | 136 base::MessageLoop::current()->PostDelayedTask( |
147 FROM_HERE, | 137 FROM_HERE, |
148 base::Bind(&FakeShillManagerClient::ScanCompleted, | 138 base::Bind(&FakeShillManagerClient::ScanCompleted, |
149 weak_ptr_factory_.GetWeakPtr(), device_path, callback), | 139 weak_ptr_factory_.GetWeakPtr(), |
| 140 device_path, |
| 141 callback), |
150 base::TimeDelta::FromSeconds(scan_duration_seconds)); | 142 base::TimeDelta::FromSeconds(scan_duration_seconds)); |
151 } | 143 } |
152 | 144 |
153 void FakeShillManagerClient::EnableTechnology( | 145 void FakeShillManagerClient::EnableTechnology( |
154 const std::string& type, | 146 const std::string& type, |
155 const base::Closure& callback, | 147 const base::Closure& callback, |
156 const ErrorCallback& error_callback) { | 148 const ErrorCallback& error_callback) { |
157 base::ListValue* enabled_list = NULL; | 149 base::ListValue* enabled_list = NULL; |
158 if (!stub_properties_.GetListWithoutPathExpansion( | 150 if (!stub_properties_.GetListWithoutPathExpansion( |
159 shill::kEnabledTechnologiesProperty, &enabled_list)) { | 151 shill::kEnabledTechnologiesProperty, &enabled_list)) { |
160 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 152 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
161 base::MessageLoop::current()->PostTask( | 153 base::MessageLoop::current()->PostTask( |
162 FROM_HERE, | 154 FROM_HERE, |
163 base::Bind(error_callback, "StubError", "Property not found")); | 155 base::Bind(error_callback, "StubError", "Property not found")); |
164 return; | 156 return; |
165 } | 157 } |
166 if (CommandLine::ForCurrentProcess()->HasSwitch( | 158 int interactive_delay = DBusThreadManager::Get()->GetShillInteractiveDelay(); |
167 chromeos::switches::kEnableStubInteractive)) { | 159 if (interactive_delay) { |
168 const int kEnableTechnologyDelaySeconds = 3; | |
169 base::MessageLoop::current()->PostDelayedTask( | 160 base::MessageLoop::current()->PostDelayedTask( |
170 FROM_HERE, | 161 FROM_HERE, |
171 base::Bind(&FakeShillManagerClient::SetTechnologyEnabled, | 162 base::Bind(&FakeShillManagerClient::SetTechnologyEnabled, |
172 weak_ptr_factory_.GetWeakPtr(), type, callback, true), | 163 weak_ptr_factory_.GetWeakPtr(), |
173 base::TimeDelta::FromSeconds(kEnableTechnologyDelaySeconds)); | 164 type, |
| 165 callback, |
| 166 true), |
| 167 base::TimeDelta::FromSeconds(interactive_delay)); |
174 } else { | 168 } else { |
175 SetTechnologyEnabled(type, callback, true); | 169 SetTechnologyEnabled(type, callback, true); |
176 } | 170 } |
177 } | 171 } |
178 | 172 |
179 void FakeShillManagerClient::DisableTechnology( | 173 void FakeShillManagerClient::DisableTechnology( |
180 const std::string& type, | 174 const std::string& type, |
181 const base::Closure& callback, | 175 const base::Closure& callback, |
182 const ErrorCallback& error_callback) { | 176 const ErrorCallback& error_callback) { |
183 base::ListValue* enabled_list = NULL; | 177 base::ListValue* enabled_list = NULL; |
184 if (!stub_properties_.GetListWithoutPathExpansion( | 178 if (!stub_properties_.GetListWithoutPathExpansion( |
185 shill::kEnabledTechnologiesProperty, &enabled_list)) { | 179 shill::kEnabledTechnologiesProperty, &enabled_list)) { |
186 base::MessageLoop::current()->PostTask( | 180 base::MessageLoop::current()->PostTask( |
187 FROM_HERE, | 181 FROM_HERE, |
188 base::Bind(error_callback, "StubError", "Property not found")); | 182 base::Bind(error_callback, "StubError", "Property not found")); |
189 return; | 183 return; |
190 } | 184 } |
191 if (CommandLine::ForCurrentProcess()->HasSwitch( | 185 int interactive_delay = DBusThreadManager::Get()->GetShillInteractiveDelay(); |
192 chromeos::switches::kEnableStubInteractive)) { | 186 if (interactive_delay) { |
193 const int kDisableTechnologyDelaySeconds = 3; | |
194 base::MessageLoop::current()->PostDelayedTask( | 187 base::MessageLoop::current()->PostDelayedTask( |
195 FROM_HERE, | 188 FROM_HERE, |
196 base::Bind(&FakeShillManagerClient::SetTechnologyEnabled, | 189 base::Bind(&FakeShillManagerClient::SetTechnologyEnabled, |
197 weak_ptr_factory_.GetWeakPtr(), type, callback, false), | 190 weak_ptr_factory_.GetWeakPtr(), |
198 base::TimeDelta::FromSeconds(kDisableTechnologyDelaySeconds)); | 191 type, |
| 192 callback, |
| 193 false), |
| 194 base::TimeDelta::FromSeconds(interactive_delay)); |
199 } else { | 195 } else { |
200 SetTechnologyEnabled(type, callback, false); | 196 SetTechnologyEnabled(type, callback, false); |
201 } | 197 } |
202 } | 198 } |
203 | 199 |
204 void FakeShillManagerClient::ConfigureService( | 200 void FakeShillManagerClient::ConfigureService( |
205 const base::DictionaryValue& properties, | 201 const base::DictionaryValue& properties, |
206 const ObjectPathCallback& callback, | 202 const ObjectPathCallback& callback, |
207 const ErrorCallback& error_callback) { | 203 const ErrorCallback& error_callback) { |
208 ShillServiceClient::TestInterface* service_client = | 204 ShillServiceClient::TestInterface* service_client = |
(...skipping 18 matching lines...) Expand all Loading... |
227 | 223 |
228 std::string ipconfig_path; | 224 std::string ipconfig_path; |
229 properties.GetString(shill::kIPConfigProperty, &ipconfig_path); | 225 properties.GetString(shill::kIPConfigProperty, &ipconfig_path); |
230 | 226 |
231 // Merge the new properties with existing properties, if any. | 227 // Merge the new properties with existing properties, if any. |
232 const base::DictionaryValue* existing_properties = | 228 const base::DictionaryValue* existing_properties = |
233 service_client->GetServiceProperties(service_path); | 229 service_client->GetServiceProperties(service_path); |
234 if (!existing_properties) { | 230 if (!existing_properties) { |
235 // Add a new service to the service client stub because none exists, yet. | 231 // Add a new service to the service client stub because none exists, yet. |
236 // This calls AddManagerService. | 232 // This calls AddManagerService. |
237 service_client->AddServiceWithIPConfig(service_path, guid, type, | 233 service_client->AddServiceWithIPConfig(service_path, |
238 shill::kStateIdle, ipconfig_path, | 234 guid, |
| 235 type, |
| 236 shill::kStateIdle, |
| 237 ipconfig_path, |
239 true /* visible */, | 238 true /* visible */, |
240 true /* watch */); | 239 true /* watch */); |
241 existing_properties = service_client->GetServiceProperties(service_path); | 240 existing_properties = service_client->GetServiceProperties(service_path); |
242 } | 241 } |
243 | 242 |
244 scoped_ptr<base::DictionaryValue> merged_properties( | 243 scoped_ptr<base::DictionaryValue> merged_properties( |
245 existing_properties->DeepCopy()); | 244 existing_properties->DeepCopy()); |
246 merged_properties->MergeDictionary(&properties); | 245 merged_properties->MergeDictionary(&properties); |
247 | 246 |
248 // Now set all the properties. | 247 // Now set all the properties. |
249 for (base::DictionaryValue::Iterator iter(*merged_properties); | 248 for (base::DictionaryValue::Iterator iter(*merged_properties); |
250 !iter.IsAtEnd(); iter.Advance()) { | 249 !iter.IsAtEnd(); |
| 250 iter.Advance()) { |
251 service_client->SetServiceProperty(service_path, iter.key(), iter.value()); | 251 service_client->SetServiceProperty(service_path, iter.key(), iter.value()); |
252 } | 252 } |
253 | 253 |
254 // If the Profile property is set, add it to ProfileClient. | 254 // If the Profile property is set, add it to ProfileClient. |
255 std::string profile_path; | 255 std::string profile_path; |
256 merged_properties->GetStringWithoutPathExpansion(shill::kProfileProperty, | 256 merged_properties->GetStringWithoutPathExpansion(shill::kProfileProperty, |
257 &profile_path); | 257 &profile_path); |
258 if (!profile_path.empty()) { | 258 if (!profile_path.empty()) { |
259 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()-> | 259 DBusThreadManager::Get() |
260 AddService(profile_path, service_path); | 260 ->GetShillProfileClient() |
| 261 ->GetTestInterface() |
| 262 ->AddService(profile_path, service_path); |
261 } | 263 } |
262 | 264 |
263 base::MessageLoop::current()->PostTask( | 265 base::MessageLoop::current()->PostTask( |
264 FROM_HERE, base::Bind(callback, dbus::ObjectPath(service_path))); | 266 FROM_HERE, base::Bind(callback, dbus::ObjectPath(service_path))); |
265 } | 267 } |
266 | 268 |
267 void FakeShillManagerClient::ConfigureServiceForProfile( | 269 void FakeShillManagerClient::ConfigureServiceForProfile( |
268 const dbus::ObjectPath& profile_path, | 270 const dbus::ObjectPath& profile_path, |
269 const base::DictionaryValue& properties, | 271 const base::DictionaryValue& properties, |
270 const ObjectPathCallback& callback, | 272 const ObjectPathCallback& callback, |
271 const ErrorCallback& error_callback) { | 273 const ErrorCallback& error_callback) { |
272 std::string profile_property; | 274 std::string profile_property; |
273 properties.GetStringWithoutPathExpansion(shill::kProfileProperty, | 275 properties.GetStringWithoutPathExpansion(shill::kProfileProperty, |
274 &profile_property); | 276 &profile_property); |
275 CHECK(profile_property == profile_path.value()); | 277 CHECK(profile_property == profile_path.value()); |
276 ConfigureService(properties, callback, error_callback); | 278 ConfigureService(properties, callback, error_callback); |
277 } | 279 } |
278 | 280 |
279 | 281 void FakeShillManagerClient::GetService(const base::DictionaryValue& properties, |
280 void FakeShillManagerClient::GetService( | 282 const ObjectPathCallback& callback, |
281 const base::DictionaryValue& properties, | 283 const ErrorCallback& error_callback) { |
282 const ObjectPathCallback& callback, | |
283 const ErrorCallback& error_callback) { | |
284 base::MessageLoop::current()->PostTask( | 284 base::MessageLoop::current()->PostTask( |
285 FROM_HERE, base::Bind(callback, dbus::ObjectPath())); | 285 FROM_HERE, base::Bind(callback, dbus::ObjectPath())); |
286 } | 286 } |
287 | 287 |
288 void FakeShillManagerClient::VerifyDestination( | 288 void FakeShillManagerClient::VerifyDestination( |
289 const VerificationProperties& properties, | 289 const VerificationProperties& properties, |
290 const BooleanCallback& callback, | 290 const BooleanCallback& callback, |
291 const ErrorCallback& error_callback) { | 291 const ErrorCallback& error_callback) { |
292 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); | 292 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); |
293 } | 293 } |
294 | 294 |
295 void FakeShillManagerClient::VerifyAndEncryptCredentials( | 295 void FakeShillManagerClient::VerifyAndEncryptCredentials( |
296 const VerificationProperties& properties, | 296 const VerificationProperties& properties, |
297 const std::string& service_path, | 297 const std::string& service_path, |
298 const StringCallback& callback, | 298 const StringCallback& callback, |
299 const ErrorCallback& error_callback) { | 299 const ErrorCallback& error_callback) { |
300 base::MessageLoop::current()->PostTask( | 300 base::MessageLoop::current()->PostTask( |
301 FROM_HERE, base::Bind(callback, "encrypted_credentials")); | 301 FROM_HERE, base::Bind(callback, "encrypted_credentials")); |
302 } | 302 } |
303 | 303 |
304 void FakeShillManagerClient::VerifyAndEncryptData( | 304 void FakeShillManagerClient::VerifyAndEncryptData( |
305 const VerificationProperties& properties, | 305 const VerificationProperties& properties, |
306 const std::string& data, | 306 const std::string& data, |
307 const StringCallback& callback, | 307 const StringCallback& callback, |
308 const ErrorCallback& error_callback) { | 308 const ErrorCallback& error_callback) { |
309 base::MessageLoop::current()->PostTask(FROM_HERE, | 309 base::MessageLoop::current()->PostTask( |
310 base::Bind(callback, "encrypted_data")); | 310 FROM_HERE, base::Bind(callback, "encrypted_data")); |
311 } | 311 } |
312 | 312 |
313 void FakeShillManagerClient::ConnectToBestServices( | 313 void FakeShillManagerClient::ConnectToBestServices( |
314 const base::Closure& callback, | 314 const base::Closure& callback, |
315 const ErrorCallback& error_callback) { | 315 const ErrorCallback& error_callback) {} |
316 } | |
317 | 316 |
318 ShillManagerClient::TestInterface* FakeShillManagerClient::GetTestInterface() { | 317 ShillManagerClient::TestInterface* FakeShillManagerClient::GetTestInterface() { |
319 return this; | 318 return this; |
320 } | 319 } |
321 | 320 |
322 // ShillManagerClient::TestInterface overrides. | 321 // ShillManagerClient::TestInterface overrides. |
323 | 322 |
324 void FakeShillManagerClient::AddDevice(const std::string& device_path) { | 323 void FakeShillManagerClient::AddDevice(const std::string& device_path) { |
325 if (GetListProperty(shill::kDevicesProperty)->AppendIfNotPresent( | 324 if (GetListProperty(shill::kDevicesProperty) |
326 base::Value::CreateStringValue(device_path))) { | 325 ->AppendIfNotPresent(base::Value::CreateStringValue(device_path))) { |
327 CallNotifyObserversPropertyChanged(shill::kDevicesProperty, 0); | 326 CallNotifyObserversPropertyChanged(shill::kDevicesProperty); |
328 } | 327 } |
329 } | 328 } |
330 | 329 |
331 void FakeShillManagerClient::RemoveDevice(const std::string& device_path) { | 330 void FakeShillManagerClient::RemoveDevice(const std::string& device_path) { |
332 base::StringValue device_path_value(device_path); | 331 base::StringValue device_path_value(device_path); |
333 if (GetListProperty(shill::kDevicesProperty)->Remove( | 332 if (GetListProperty(shill::kDevicesProperty) |
334 device_path_value, NULL)) { | 333 ->Remove(device_path_value, NULL)) { |
335 CallNotifyObserversPropertyChanged(shill::kDevicesProperty, 0); | 334 CallNotifyObserversPropertyChanged(shill::kDevicesProperty); |
336 } | 335 } |
337 } | 336 } |
338 | 337 |
339 void FakeShillManagerClient::ClearDevices() { | 338 void FakeShillManagerClient::ClearDevices() { |
340 GetListProperty(shill::kDevicesProperty)->Clear(); | 339 GetListProperty(shill::kDevicesProperty)->Clear(); |
341 CallNotifyObserversPropertyChanged(shill::kDevicesProperty, 0); | 340 CallNotifyObserversPropertyChanged(shill::kDevicesProperty); |
342 } | 341 } |
343 | 342 |
344 void FakeShillManagerClient::AddTechnology(const std::string& type, | 343 void FakeShillManagerClient::AddTechnology(const std::string& type, |
345 bool enabled) { | 344 bool enabled) { |
346 if (GetListProperty(shill::kAvailableTechnologiesProperty)-> | 345 if (GetListProperty(shill::kAvailableTechnologiesProperty) |
347 AppendIfNotPresent(base::Value::CreateStringValue(type))) { | 346 ->AppendIfNotPresent(base::Value::CreateStringValue(type))) { |
348 CallNotifyObserversPropertyChanged( | 347 CallNotifyObserversPropertyChanged(shill::kAvailableTechnologiesProperty); |
349 shill::kAvailableTechnologiesProperty, 0); | |
350 } | 348 } |
351 if (enabled && | 349 if (enabled && |
352 GetListProperty(shill::kEnabledTechnologiesProperty)-> | 350 GetListProperty(shill::kEnabledTechnologiesProperty) |
353 AppendIfNotPresent(base::Value::CreateStringValue(type))) { | 351 ->AppendIfNotPresent(base::Value::CreateStringValue(type))) { |
354 CallNotifyObserversPropertyChanged( | 352 CallNotifyObserversPropertyChanged(shill::kEnabledTechnologiesProperty); |
355 shill::kEnabledTechnologiesProperty, 0); | |
356 } | 353 } |
357 } | 354 } |
358 | 355 |
359 void FakeShillManagerClient::RemoveTechnology(const std::string& type) { | 356 void FakeShillManagerClient::RemoveTechnology(const std::string& type) { |
360 base::StringValue type_value(type); | 357 base::StringValue type_value(type); |
361 if (GetListProperty(shill::kAvailableTechnologiesProperty)->Remove( | 358 if (GetListProperty(shill::kAvailableTechnologiesProperty) |
362 type_value, NULL)) { | 359 ->Remove(type_value, NULL)) { |
363 CallNotifyObserversPropertyChanged( | 360 CallNotifyObserversPropertyChanged(shill::kAvailableTechnologiesProperty); |
364 shill::kAvailableTechnologiesProperty, 0); | |
365 } | 361 } |
366 if (GetListProperty(shill::kEnabledTechnologiesProperty)->Remove( | 362 if (GetListProperty(shill::kEnabledTechnologiesProperty) |
367 type_value, NULL)) { | 363 ->Remove(type_value, NULL)) { |
368 CallNotifyObserversPropertyChanged( | 364 CallNotifyObserversPropertyChanged(shill::kEnabledTechnologiesProperty); |
369 shill::kEnabledTechnologiesProperty, 0); | |
370 } | 365 } |
371 } | 366 } |
372 | 367 |
373 void FakeShillManagerClient::SetTechnologyInitializing(const std::string& type, | 368 void FakeShillManagerClient::SetTechnologyInitializing(const std::string& type, |
374 bool initializing) { | 369 bool initializing) { |
375 if (initializing) { | 370 if (initializing) { |
376 if (GetListProperty(shill::kUninitializedTechnologiesProperty)-> | 371 if (GetListProperty(shill::kUninitializedTechnologiesProperty) |
377 AppendIfNotPresent(base::Value::CreateStringValue(type))) { | 372 ->AppendIfNotPresent(base::Value::CreateStringValue(type))) { |
378 CallNotifyObserversPropertyChanged( | 373 CallNotifyObserversPropertyChanged( |
379 shill::kUninitializedTechnologiesProperty, 0); | 374 shill::kUninitializedTechnologiesProperty); |
380 } | 375 } |
381 } else { | 376 } else { |
382 if (GetListProperty(shill::kUninitializedTechnologiesProperty)->Remove( | 377 if (GetListProperty(shill::kUninitializedTechnologiesProperty) |
383 base::StringValue(type), NULL)) { | 378 ->Remove(base::StringValue(type), NULL)) { |
384 CallNotifyObserversPropertyChanged( | 379 CallNotifyObserversPropertyChanged( |
385 shill::kUninitializedTechnologiesProperty, 0); | 380 shill::kUninitializedTechnologiesProperty); |
386 } | 381 } |
387 } | 382 } |
388 } | 383 } |
389 | 384 |
390 void FakeShillManagerClient::ClearProperties() { | 385 void FakeShillManagerClient::ClearProperties() { stub_properties_.Clear(); } |
391 stub_properties_.Clear(); | |
392 } | |
393 | 386 |
394 void FakeShillManagerClient::AddManagerService(const std::string& service_path, | 387 void FakeShillManagerClient::AddManagerService(const std::string& service_path, |
395 bool add_to_visible_list, | 388 bool add_to_visible_list, |
396 bool add_to_watch_list) { | 389 bool add_to_watch_list) { |
397 // Always add to ServiceCompleteListProperty. | 390 // Always add to ServiceCompleteListProperty. |
398 GetListProperty(shill::kServiceCompleteListProperty)->AppendIfNotPresent( | 391 GetListProperty(shill::kServiceCompleteListProperty) |
399 base::Value::CreateStringValue(service_path)); | 392 ->AppendIfNotPresent(base::Value::CreateStringValue(service_path)); |
400 // If visible, add to Services and notify if new. | 393 // If visible, add to Services and notify if new. |
401 if (add_to_visible_list && | 394 if (add_to_visible_list && |
402 GetListProperty(shill::kServicesProperty)->AppendIfNotPresent( | 395 GetListProperty(shill::kServicesProperty) |
403 base::Value::CreateStringValue(service_path))) { | 396 ->AppendIfNotPresent(base::Value::CreateStringValue(service_path))) { |
404 CallNotifyObserversPropertyChanged(shill::kServicesProperty, 0); | 397 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
405 } | 398 } |
406 if (add_to_watch_list) | 399 if (add_to_watch_list) |
407 AddServiceToWatchList(service_path); | 400 AddServiceToWatchList(service_path); |
408 } | 401 } |
409 | 402 |
410 void FakeShillManagerClient::RemoveManagerService( | 403 void FakeShillManagerClient::RemoveManagerService( |
411 const std::string& service_path) { | 404 const std::string& service_path) { |
412 base::StringValue service_path_value(service_path); | 405 base::StringValue service_path_value(service_path); |
413 if (GetListProperty(shill::kServicesProperty)->Remove( | 406 if (GetListProperty(shill::kServicesProperty) |
414 service_path_value, NULL)) { | 407 ->Remove(service_path_value, NULL)) { |
415 CallNotifyObserversPropertyChanged(shill::kServicesProperty, 0); | 408 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
416 } | 409 } |
417 GetListProperty(shill::kServiceCompleteListProperty)->Remove( | 410 GetListProperty(shill::kServiceCompleteListProperty) |
418 service_path_value, NULL); | 411 ->Remove(service_path_value, NULL); |
419 if (GetListProperty(shill::kServiceWatchListProperty)->Remove( | 412 if (GetListProperty(shill::kServiceWatchListProperty) |
420 service_path_value, NULL)) { | 413 ->Remove(service_path_value, NULL)) { |
421 CallNotifyObserversPropertyChanged( | 414 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); |
422 shill::kServiceWatchListProperty, 0); | |
423 } | 415 } |
424 } | 416 } |
425 | 417 |
426 void FakeShillManagerClient::ClearManagerServices() { | 418 void FakeShillManagerClient::ClearManagerServices() { |
427 GetListProperty(shill::kServicesProperty)->Clear(); | 419 GetListProperty(shill::kServicesProperty)->Clear(); |
428 GetListProperty(shill::kServiceCompleteListProperty)->Clear(); | 420 GetListProperty(shill::kServiceCompleteListProperty)->Clear(); |
429 GetListProperty(shill::kServiceWatchListProperty)->Clear(); | 421 GetListProperty(shill::kServiceWatchListProperty)->Clear(); |
430 CallNotifyObserversPropertyChanged(shill::kServicesProperty, 0); | 422 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
431 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty, 0); | 423 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); |
432 } | 424 } |
433 | 425 |
434 void FakeShillManagerClient::SortManagerServices() { | 426 void FakeShillManagerClient::SortManagerServices() { |
435 static const char* ordered_types[] = { | 427 static const char* ordered_types[] = {shill::kTypeEthernet, shill::kTypeWifi, |
436 shill::kTypeEthernet, | 428 shill::kTypeCellular, shill::kTypeWimax, |
437 shill::kTypeWifi, | 429 shill::kTypeVPN}; |
438 shill::kTypeCellular, | |
439 shill::kTypeWimax, | |
440 shill::kTypeVPN | |
441 }; | |
442 base::ListValue* service_list = GetListProperty(shill::kServicesProperty); | 430 base::ListValue* service_list = GetListProperty(shill::kServicesProperty); |
443 if (!service_list || service_list->empty()) | 431 if (!service_list || service_list->empty()) |
444 return; | 432 return; |
445 std::vector<std::string> active_services; | 433 std::vector<std::string> active_services; |
446 std::vector<std::string> inactive_services; | 434 std::vector<std::string> inactive_services; |
447 for (size_t i = 0; i < arraysize(ordered_types); ++i) { | 435 for (size_t i = 0; i < arraysize(ordered_types); ++i) { |
448 AppendServicesForType(service_list, ordered_types[i], | 436 AppendServicesForType( |
449 &active_services, &inactive_services); | 437 service_list, ordered_types[i], &active_services, &inactive_services); |
450 } | 438 } |
451 service_list->Clear(); | 439 service_list->Clear(); |
452 for (size_t i = 0; i < active_services.size(); ++i) | 440 for (size_t i = 0; i < active_services.size(); ++i) |
453 service_list->AppendString(active_services[i]); | 441 service_list->AppendString(active_services[i]); |
454 for (size_t i = 0; i < inactive_services.size(); ++i) | 442 for (size_t i = 0; i < inactive_services.size(); ++i) |
455 service_list->AppendString(inactive_services[i]); | 443 service_list->AppendString(inactive_services[i]); |
456 | 444 |
457 CallNotifyObserversPropertyChanged(shill::kServicesProperty, 0); | 445 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
458 } | 446 } |
459 | 447 |
460 void FakeShillManagerClient::AddGeoNetwork( | 448 void FakeShillManagerClient::AddGeoNetwork( |
461 const std::string& technology, | 449 const std::string& technology, |
462 const base::DictionaryValue& network) { | 450 const base::DictionaryValue& network) { |
463 base::ListValue* list_value = NULL; | 451 base::ListValue* list_value = NULL; |
464 if (!stub_geo_networks_.GetListWithoutPathExpansion( | 452 if (!stub_geo_networks_.GetListWithoutPathExpansion(technology, |
465 technology, &list_value)) { | 453 &list_value)) { |
466 list_value = new base::ListValue; | 454 list_value = new base::ListValue; |
467 stub_geo_networks_.SetWithoutPathExpansion(technology, list_value); | 455 stub_geo_networks_.SetWithoutPathExpansion(technology, list_value); |
468 } | 456 } |
469 list_value->Append(network.DeepCopy()); | 457 list_value->Append(network.DeepCopy()); |
470 } | 458 } |
471 | 459 |
472 void FakeShillManagerClient::AddProfile(const std::string& profile_path) { | 460 void FakeShillManagerClient::AddProfile(const std::string& profile_path) { |
473 const char* key = shill::kProfilesProperty; | 461 const char* key = shill::kProfilesProperty; |
474 if (GetListProperty(key)->AppendIfNotPresent( | 462 if (GetListProperty(key) |
475 new base::StringValue(profile_path))) { | 463 ->AppendIfNotPresent(new base::StringValue(profile_path))) { |
476 CallNotifyObserversPropertyChanged(key, 0); | 464 CallNotifyObserversPropertyChanged(key); |
477 } | 465 } |
478 } | 466 } |
479 | 467 |
480 void FakeShillManagerClient::AddServiceToWatchList( | 468 void FakeShillManagerClient::AddServiceToWatchList( |
481 const std::string& service_path) { | 469 const std::string& service_path) { |
482 // Remove and insert the service, moving it to the front of the watch list. | 470 // Remove and insert the service, moving it to the front of the watch list. |
483 GetListProperty(shill::kServiceWatchListProperty)->Remove( | 471 GetListProperty(shill::kServiceWatchListProperty) |
484 base::StringValue(service_path), NULL); | 472 ->Remove(base::StringValue(service_path), NULL); |
485 GetListProperty(shill::kServiceWatchListProperty)->Insert( | 473 GetListProperty(shill::kServiceWatchListProperty) |
486 0, base::Value::CreateStringValue(service_path)); | 474 ->Insert(0, base::Value::CreateStringValue(service_path)); |
487 CallNotifyObserversPropertyChanged( | 475 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); |
488 shill::kServiceWatchListProperty, 0); | |
489 } | 476 } |
490 | 477 |
491 void FakeShillManagerClient::PassStubProperties( | 478 void FakeShillManagerClient::PassStubProperties( |
492 const DictionaryValueCallback& callback) const { | 479 const DictionaryValueCallback& callback) const { |
493 scoped_ptr<base::DictionaryValue> stub_properties( | 480 scoped_ptr<base::DictionaryValue> stub_properties( |
494 stub_properties_.DeepCopy()); | 481 stub_properties_.DeepCopy()); |
495 // Remove disabled services from the list. | 482 // Remove disabled services from the list. |
496 stub_properties->SetWithoutPathExpansion( | 483 stub_properties->SetWithoutPathExpansion( |
497 shill::kServicesProperty, | 484 shill::kServicesProperty, |
498 GetEnabledServiceList(shill::kServicesProperty)); | 485 GetEnabledServiceList(shill::kServicesProperty)); |
499 stub_properties->SetWithoutPathExpansion( | 486 stub_properties->SetWithoutPathExpansion( |
500 shill::kServiceWatchListProperty, | 487 shill::kServiceWatchListProperty, |
501 GetEnabledServiceList(shill::kServiceWatchListProperty)); | 488 GetEnabledServiceList(shill::kServiceWatchListProperty)); |
502 callback.Run(DBUS_METHOD_CALL_SUCCESS, *stub_properties); | 489 callback.Run(DBUS_METHOD_CALL_SUCCESS, *stub_properties); |
503 } | 490 } |
504 | 491 |
505 void FakeShillManagerClient::PassStubGeoNetworks( | 492 void FakeShillManagerClient::PassStubGeoNetworks( |
506 const DictionaryValueCallback& callback) const { | 493 const DictionaryValueCallback& callback) const { |
507 callback.Run(DBUS_METHOD_CALL_SUCCESS, stub_geo_networks_); | 494 callback.Run(DBUS_METHOD_CALL_SUCCESS, stub_geo_networks_); |
508 } | 495 } |
509 | 496 |
510 void FakeShillManagerClient::CallNotifyObserversPropertyChanged( | 497 void FakeShillManagerClient::CallNotifyObserversPropertyChanged( |
511 const std::string& property, | 498 const std::string& property) { |
512 int delay_ms) { | |
513 // Avoid unnecessary delayed task if we have no observers (e.g. during | 499 // Avoid unnecessary delayed task if we have no observers (e.g. during |
514 // initial setup). | 500 // initial setup). |
515 if (!observer_list_.might_have_observers()) | 501 if (!observer_list_.might_have_observers()) |
516 return; | 502 return; |
517 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 503 base::MessageLoop::current()->PostTask( |
518 chromeos::switches::kEnableStubInteractive)) { | |
519 delay_ms = 0; | |
520 } | |
521 base::MessageLoop::current()->PostDelayedTask( | |
522 FROM_HERE, | 504 FROM_HERE, |
523 base::Bind(&FakeShillManagerClient::NotifyObserversPropertyChanged, | 505 base::Bind(&FakeShillManagerClient::NotifyObserversPropertyChanged, |
524 weak_ptr_factory_.GetWeakPtr(), | 506 weak_ptr_factory_.GetWeakPtr(), |
525 property), | 507 property)); |
526 base::TimeDelta::FromMilliseconds(delay_ms)); | |
527 } | 508 } |
528 | 509 |
529 void FakeShillManagerClient::NotifyObserversPropertyChanged( | 510 void FakeShillManagerClient::NotifyObserversPropertyChanged( |
530 const std::string& property) { | 511 const std::string& property) { |
531 if (property == shill::kServicesProperty || | 512 if (property == shill::kServicesProperty || |
532 property == shill::kServiceWatchListProperty) { | 513 property == shill::kServiceWatchListProperty) { |
533 scoped_ptr<base::ListValue> services(GetEnabledServiceList(property)); | 514 scoped_ptr<base::ListValue> services(GetEnabledServiceList(property)); |
534 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, | 515 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, |
535 observer_list_, | 516 observer_list_, |
536 OnPropertyChanged(property, *(services.get()))); | 517 OnPropertyChanged(property, *(services.get()))); |
537 return; | 518 return; |
538 } | 519 } |
539 if (property == shill::kDevicesProperty) { | 520 if (property == shill::kDevicesProperty) { |
540 base::ListValue* devices = NULL; | 521 base::ListValue* devices = NULL; |
541 if (stub_properties_.GetListWithoutPathExpansion( | 522 if (stub_properties_.GetListWithoutPathExpansion(shill::kDevicesProperty, |
542 shill::kDevicesProperty, &devices)) { | 523 &devices)) { |
543 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, | 524 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, |
544 observer_list_, | 525 observer_list_, |
545 OnPropertyChanged(property, *devices)); | 526 OnPropertyChanged(property, *devices)); |
546 } | 527 } |
547 return; | 528 return; |
548 } | 529 } |
549 base::Value* value = NULL; | 530 base::Value* value = NULL; |
550 if (!stub_properties_.GetWithoutPathExpansion(property, &value)) { | 531 if (!stub_properties_.GetWithoutPathExpansion(property, &value)) { |
551 LOG(ERROR) << "Notify for unknown property: " << property; | 532 LOG(ERROR) << "Notify for unknown property: " << property; |
552 return; | 533 return; |
553 } | 534 } |
554 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, | 535 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, |
555 observer_list_, | 536 observer_list_, |
556 OnPropertyChanged(property, *value)); | 537 OnPropertyChanged(property, *value)); |
557 } | 538 } |
558 | 539 |
559 base::ListValue* FakeShillManagerClient::GetListProperty( | 540 base::ListValue* FakeShillManagerClient::GetListProperty( |
560 const std::string& property) { | 541 const std::string& property) { |
561 base::ListValue* list_property = NULL; | 542 base::ListValue* list_property = NULL; |
562 if (!stub_properties_.GetListWithoutPathExpansion( | 543 if (!stub_properties_.GetListWithoutPathExpansion(property, &list_property)) { |
563 property, &list_property)) { | |
564 list_property = new base::ListValue; | 544 list_property = new base::ListValue; |
565 stub_properties_.SetWithoutPathExpansion(property, list_property); | 545 stub_properties_.SetWithoutPathExpansion(property, list_property); |
566 } | 546 } |
567 return list_property; | 547 return list_property; |
568 } | 548 } |
569 | 549 |
570 bool FakeShillManagerClient::TechnologyEnabled(const std::string& type) const { | 550 bool FakeShillManagerClient::TechnologyEnabled(const std::string& type) const { |
571 if (type == shill::kTypeVPN) | 551 if (type == shill::kTypeVPN) |
572 return true; // VPN is always "enabled" since there is no associated device | 552 return true; // VPN is always "enabled" since there is no associated device |
573 bool enabled = false; | 553 bool enabled = false; |
574 const base::ListValue* technologies; | 554 const base::ListValue* technologies; |
575 if (stub_properties_.GetListWithoutPathExpansion( | 555 if (stub_properties_.GetListWithoutPathExpansion( |
576 shill::kEnabledTechnologiesProperty, &technologies)) { | 556 shill::kEnabledTechnologiesProperty, &technologies)) { |
577 base::StringValue type_value(type); | 557 base::StringValue type_value(type); |
578 if (technologies->Find(type_value) != technologies->end()) | 558 if (technologies->Find(type_value) != technologies->end()) |
579 enabled = true; | 559 enabled = true; |
580 } | 560 } |
581 return enabled; | 561 return enabled; |
582 } | 562 } |
583 | 563 |
584 void FakeShillManagerClient::SetTechnologyEnabled( | 564 void FakeShillManagerClient::SetTechnologyEnabled(const std::string& type, |
585 const std::string& type, | 565 const base::Closure& callback, |
586 const base::Closure& callback, | 566 bool enabled) { |
587 bool enabled) { | |
588 base::ListValue* enabled_list = NULL; | 567 base::ListValue* enabled_list = NULL; |
589 stub_properties_.GetListWithoutPathExpansion( | 568 stub_properties_.GetListWithoutPathExpansion( |
590 shill::kEnabledTechnologiesProperty, &enabled_list); | 569 shill::kEnabledTechnologiesProperty, &enabled_list); |
591 DCHECK(enabled_list); | 570 DCHECK(enabled_list); |
592 if (enabled) | 571 if (enabled) |
593 enabled_list->AppendIfNotPresent(new base::StringValue(type)); | 572 enabled_list->AppendIfNotPresent(new base::StringValue(type)); |
594 else | 573 else |
595 enabled_list->Remove(base::StringValue(type), NULL); | 574 enabled_list->Remove(base::StringValue(type), NULL); |
596 CallNotifyObserversPropertyChanged( | 575 CallNotifyObserversPropertyChanged(shill::kEnabledTechnologiesProperty); |
597 shill::kEnabledTechnologiesProperty, 0 /* already delayed */); | |
598 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 576 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
599 // May affect available services | 577 // May affect available services |
600 CallNotifyObserversPropertyChanged(shill::kServicesProperty, 0); | 578 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
601 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty, 0); | 579 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); |
602 } | 580 } |
603 | 581 |
604 base::ListValue* FakeShillManagerClient::GetEnabledServiceList( | 582 base::ListValue* FakeShillManagerClient::GetEnabledServiceList( |
605 const std::string& property) const { | 583 const std::string& property) const { |
606 base::ListValue* new_service_list = new base::ListValue; | 584 base::ListValue* new_service_list = new base::ListValue; |
607 const base::ListValue* service_list; | 585 const base::ListValue* service_list; |
608 if (stub_properties_.GetListWithoutPathExpansion(property, &service_list)) { | 586 if (stub_properties_.GetListWithoutPathExpansion(property, &service_list)) { |
609 ShillServiceClient::TestInterface* service_client = | 587 ShillServiceClient::TestInterface* service_client = |
610 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 588 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
611 for (base::ListValue::const_iterator iter = service_list->begin(); | 589 for (base::ListValue::const_iterator iter = service_list->begin(); |
612 iter != service_list->end(); ++iter) { | 590 iter != service_list->end(); |
| 591 ++iter) { |
613 std::string service_path; | 592 std::string service_path; |
614 if (!(*iter)->GetAsString(&service_path)) | 593 if (!(*iter)->GetAsString(&service_path)) |
615 continue; | 594 continue; |
616 const base::DictionaryValue* properties = | 595 const base::DictionaryValue* properties = |
617 service_client->GetServiceProperties(service_path); | 596 service_client->GetServiceProperties(service_path); |
618 if (!properties) { | 597 if (!properties) { |
619 LOG(ERROR) << "Properties not found for service: " << service_path; | 598 LOG(ERROR) << "Properties not found for service: " << service_path; |
620 continue; | 599 continue; |
621 } | 600 } |
622 std::string name; | 601 std::string name; |
623 properties->GetString(shill::kNameProperty, &name); | 602 properties->GetString(shill::kNameProperty, &name); |
624 std::string type; | 603 std::string type; |
625 properties->GetString(shill::kTypeProperty, &type); | 604 properties->GetString(shill::kTypeProperty, &type); |
626 if (TechnologyEnabled(type)) | 605 if (TechnologyEnabled(type)) |
627 new_service_list->Append((*iter)->DeepCopy()); | 606 new_service_list->Append((*iter)->DeepCopy()); |
628 } | 607 } |
629 } | 608 } |
630 return new_service_list; | 609 return new_service_list; |
631 } | 610 } |
632 | 611 |
633 void FakeShillManagerClient::ScanCompleted(const std::string& device_path, | 612 void FakeShillManagerClient::ScanCompleted(const std::string& device_path, |
634 const base::Closure& callback) { | 613 const base::Closure& callback) { |
635 if (!device_path.empty()) { | 614 if (!device_path.empty()) { |
636 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> | 615 DBusThreadManager::Get() |
637 SetDeviceProperty(device_path, | 616 ->GetShillDeviceClient() |
638 shill::kScanningProperty, | 617 ->GetTestInterface() |
639 base::FundamentalValue(false)); | 618 ->SetDeviceProperty(device_path, |
| 619 shill::kScanningProperty, |
| 620 base::FundamentalValue(false)); |
640 } | 621 } |
641 CallNotifyObserversPropertyChanged(shill::kServicesProperty, 0); | 622 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
642 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty, 0); | 623 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); |
643 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 624 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
644 } | 625 } |
645 | 626 |
646 } // namespace chromeos | 627 } // namespace chromeos |
OLD | NEW |