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

Side by Side Diff: chromeos/dbus/shill_service_client_stub.cc

Issue 12634019: NetworkChangeNotifierChromeos: Handle IPConfig property changes on the default network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more cleanup Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/shill_service_client_stub.h" 5 #include "chromeos/dbus/shill_service_client_stub.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.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 ShillServiceClient::TestInterface* ShillServiceClientStub::GetTestInterface() { 246 ShillServiceClient::TestInterface* ShillServiceClientStub::GetTestInterface() {
247 return this; 247 return this;
248 } 248 }
249 249
250 // ShillServiceClient::TestInterface overrides. 250 // ShillServiceClient::TestInterface overrides.
251 251
252 void ShillServiceClientStub::AddService(const std::string& service_path, 252 void ShillServiceClientStub::AddService(const std::string& service_path,
253 const std::string& name, 253 const std::string& name,
254 const std::string& type, 254 const std::string& type,
255 const std::string& state, 255 const std::string& state,
256 const std::string& ipconfig_path,
256 bool add_to_watch_list) { 257 bool add_to_watch_list) {
257 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 258 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
258 AddService(service_path, add_to_watch_list); 259 AddService(service_path, add_to_watch_list);
259 260
260 base::DictionaryValue* properties = 261 base::DictionaryValue* properties =
261 GetModifiableServiceProperties(service_path); 262 GetModifiableServiceProperties(service_path);
262 properties->SetWithoutPathExpansion( 263 properties->SetWithoutPathExpansion(
263 flimflam::kSSIDProperty, 264 flimflam::kSSIDProperty,
264 base::Value::CreateStringValue(service_path)); 265 base::Value::CreateStringValue(service_path));
265 properties->SetWithoutPathExpansion( 266 properties->SetWithoutPathExpansion(
266 flimflam::kNameProperty, 267 flimflam::kNameProperty,
267 base::Value::CreateStringValue(name)); 268 base::Value::CreateStringValue(name));
268 properties->SetWithoutPathExpansion( 269 properties->SetWithoutPathExpansion(
269 flimflam::kTypeProperty, 270 flimflam::kTypeProperty,
270 base::Value::CreateStringValue(type)); 271 base::Value::CreateStringValue(type));
271 properties->SetWithoutPathExpansion( 272 properties->SetWithoutPathExpansion(
272 flimflam::kStateProperty, 273 flimflam::kStateProperty,
273 base::Value::CreateStringValue(state)); 274 base::Value::CreateStringValue(state));
275 if (!ipconfig_path.empty())
276 properties->SetWithoutPathExpansion(
277 flimflam::kStateProperty,
278 base::Value::CreateStringValue(state));
274 } 279 }
275 280
276 void ShillServiceClientStub::RemoveService(const std::string& service_path) { 281 void ShillServiceClientStub::RemoveService(const std::string& service_path) {
277 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 282 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
278 RemoveService(service_path); 283 RemoveService(service_path);
279 284
280 stub_services_.RemoveWithoutPathExpansion(service_path, NULL); 285 stub_services_.RemoveWithoutPathExpansion(service_path, NULL);
281 } 286 }
282 287
283 void ShillServiceClientStub::SetServiceProperty(const std::string& service_path, 288 void ShillServiceClientStub::SetServiceProperty(const std::string& service_path,
(...skipping 19 matching lines...) Expand all
303 } 308 }
304 309
305 void ShillServiceClientStub::SetDefaultProperties() { 310 void ShillServiceClientStub::SetDefaultProperties() {
306 const bool add_to_watchlist = true; 311 const bool add_to_watchlist = true;
307 312
308 if (!CommandLine::ForCurrentProcess()->HasSwitch( 313 if (!CommandLine::ForCurrentProcess()->HasSwitch(
309 chromeos::switches::kDisableStubEthernet)) { 314 chromeos::switches::kDisableStubEthernet)) {
310 AddService("stub_ethernet", "eth0", 315 AddService("stub_ethernet", "eth0",
311 flimflam::kTypeEthernet, 316 flimflam::kTypeEthernet,
312 flimflam::kStateOnline, 317 flimflam::kStateOnline,
318 "",
313 add_to_watchlist); 319 add_to_watchlist);
314 } 320 }
315 321
316 AddService("stub_wifi1", "wifi1", 322 AddService("stub_wifi1", "wifi1",
317 flimflam::kTypeWifi, 323 flimflam::kTypeWifi,
318 flimflam::kStateOnline, 324 flimflam::kStateOnline,
325 "",
319 add_to_watchlist); 326 add_to_watchlist);
320 SetServiceProperty("stub_wifi1", 327 SetServiceProperty("stub_wifi1",
321 flimflam::kSecurityProperty, 328 flimflam::kSecurityProperty,
322 base::StringValue(flimflam::kSecurityWep)); 329 base::StringValue(flimflam::kSecurityWep));
323 330
324 AddService("stub_wifi2", "wifi2_PSK", 331 AddService("stub_wifi2", "wifi2_PSK",
325 flimflam::kTypeWifi, 332 flimflam::kTypeWifi,
326 flimflam::kStateIdle, 333 flimflam::kStateIdle,
334 "",
327 add_to_watchlist); 335 add_to_watchlist);
328 SetServiceProperty("stub_wifi2", 336 SetServiceProperty("stub_wifi2",
329 flimflam::kSecurityProperty, 337 flimflam::kSecurityProperty,
330 base::StringValue(flimflam::kSecurityPsk)); 338 base::StringValue(flimflam::kSecurityPsk));
331 base::FundamentalValue strength_value(80); 339 base::FundamentalValue strength_value(80);
332 SetServiceProperty("stub_wifi2", 340 SetServiceProperty("stub_wifi2",
333 flimflam::kSignalStrengthProperty, 341 flimflam::kSignalStrengthProperty,
334 strength_value); 342 strength_value);
335 343
336 AddService("stub_cellular1", "cellular1", 344 AddService("stub_cellular1", "cellular1",
337 flimflam::kTypeCellular, 345 flimflam::kTypeCellular,
338 flimflam::kStateIdle, 346 flimflam::kStateIdle,
347 "",
339 add_to_watchlist); 348 add_to_watchlist);
340 base::StringValue technology_value(flimflam::kNetworkTechnologyGsm); 349 base::StringValue technology_value(flimflam::kNetworkTechnologyGsm);
341 SetServiceProperty("stub_cellular1", 350 SetServiceProperty("stub_cellular1",
342 flimflam::kNetworkTechnologyProperty, 351 flimflam::kNetworkTechnologyProperty,
343 technology_value); 352 technology_value);
344 SetServiceProperty("stub_cellular1", 353 SetServiceProperty("stub_cellular1",
345 flimflam::kActivationStateProperty, 354 flimflam::kActivationStateProperty,
346 base::StringValue(flimflam::kActivationStateNotActivated)); 355 base::StringValue(flimflam::kActivationStateNotActivated));
347 SetServiceProperty("stub_cellular1", 356 SetServiceProperty("stub_cellular1",
348 flimflam::kRoamingStateProperty, 357 flimflam::kRoamingStateProperty,
349 base::StringValue(flimflam::kRoamingStateHome)); 358 base::StringValue(flimflam::kRoamingStateHome));
350 359
351 AddService("stub_vpn1", "vpn1", 360 AddService("stub_vpn1", "vpn1",
352 flimflam::kTypeVPN, 361 flimflam::kTypeVPN,
353 flimflam::kStateOnline, 362 flimflam::kStateOnline,
363 "",
354 add_to_watchlist); 364 add_to_watchlist);
355 365
356 AddService("stub_vpn2", "vpn2", 366 AddService("stub_vpn2", "vpn2",
357 flimflam::kTypeVPN, 367 flimflam::kTypeVPN,
358 flimflam::kStateOffline, 368 flimflam::kStateOffline,
369 "",
359 add_to_watchlist); 370 add_to_watchlist);
360 } 371 }
361 372
362 void ShillServiceClientStub::PassStubServiceProperties( 373 void ShillServiceClientStub::PassStubServiceProperties(
363 const dbus::ObjectPath& service_path, 374 const dbus::ObjectPath& service_path,
364 const DictionaryValueCallback& callback) { 375 const DictionaryValueCallback& callback) {
365 base::DictionaryValue* dict = NULL; 376 base::DictionaryValue* dict = NULL;
366 if (!stub_services_.GetDictionaryWithoutPathExpansion( 377 if (!stub_services_.GetDictionaryWithoutPathExpansion(
367 service_path.value(), &dict)) { 378 service_path.value(), &dict)) {
368 base::DictionaryValue empty_dictionary; 379 base::DictionaryValue empty_dictionary;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = 419 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter =
409 observer_list_.find(device_path); 420 observer_list_.find(device_path);
410 if (iter != observer_list_.end()) 421 if (iter != observer_list_.end())
411 return *(iter->second); 422 return *(iter->second);
412 PropertyObserverList* observer_list = new PropertyObserverList(); 423 PropertyObserverList* observer_list = new PropertyObserverList();
413 observer_list_[device_path] = observer_list; 424 observer_list_[device_path] = observer_list;
414 return *observer_list; 425 return *observer_list;
415 } 426 }
416 427
417 } // namespace chromeos 428 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698