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

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

Issue 289383004: Merge FavoriteState into NetworkState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Fix tests Created 6 years, 6 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 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_service_client.h" 5 #include "chromeos/dbus/fake_shill_service_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 21 matching lines...) Expand all
32 32
33 void PassStubServiceProperties( 33 void PassStubServiceProperties(
34 const ShillServiceClient::DictionaryValueCallback& callback, 34 const ShillServiceClient::DictionaryValueCallback& callback,
35 DBusMethodCallStatus call_status, 35 DBusMethodCallStatus call_status,
36 const base::DictionaryValue* properties) { 36 const base::DictionaryValue* properties) {
37 callback.Run(call_status, *properties); 37 callback.Run(call_status, *properties);
38 } 38 }
39 39
40 void CallSortManagerServices() { 40 void CallSortManagerServices() {
41 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 41 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
42 SortManagerServices(); 42 SortManagerServices(true);
43 } 43 }
44 44
45 int GetInteractiveDelay() { 45 int GetInteractiveDelay() {
46 return DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 46 return DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
47 GetInteractiveDelay(); 47 GetInteractiveDelay();
48 } 48 }
49 49
50 } // namespace 50 } // namespace
51 51
52 FakeShillServiceClient::FakeShillServiceClient() : weak_ptr_factory_(this) { 52 FakeShillServiceClient::FakeShillServiceClient() : weak_ptr_factory_(this) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 315 }
316 316
317 void FakeShillServiceClient::AddServiceWithIPConfig( 317 void FakeShillServiceClient::AddServiceWithIPConfig(
318 const std::string& service_path, 318 const std::string& service_path,
319 const std::string& guid, 319 const std::string& guid,
320 const std::string& name, 320 const std::string& name,
321 const std::string& type, 321 const std::string& type,
322 const std::string& state, 322 const std::string& state,
323 const std::string& ipconfig_path, 323 const std::string& ipconfig_path,
324 bool add_to_visible_list) { 324 bool add_to_visible_list) {
325 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
326 AddManagerService(service_path, add_to_visible_list);
327 std::string device_path = 325 std::string device_path =
328 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> 326 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()->
329 GetDevicePathForType(type); 327 GetDevicePathForType(type);
330 328
331 base::DictionaryValue* properties = 329 base::DictionaryValue* properties =
332 GetModifiableServiceProperties(service_path, true); 330 GetModifiableServiceProperties(service_path, true);
333 connect_behavior_.erase(service_path); 331 connect_behavior_.erase(service_path);
334 332
335 std::string profile_path; 333 std::string profile_path;
336 base::DictionaryValue profile_properties; 334 base::DictionaryValue profile_properties;
(...skipping 22 matching lines...) Expand all
359 new base::StringValue(name)); 357 new base::StringValue(name));
360 properties->SetWithoutPathExpansion( 358 properties->SetWithoutPathExpansion(
361 shill::kDeviceProperty, 359 shill::kDeviceProperty,
362 new base::StringValue(device_path)); 360 new base::StringValue(device_path));
363 properties->SetWithoutPathExpansion( 361 properties->SetWithoutPathExpansion(
364 shill::kTypeProperty, 362 shill::kTypeProperty,
365 new base::StringValue(type)); 363 new base::StringValue(type));
366 properties->SetWithoutPathExpansion( 364 properties->SetWithoutPathExpansion(
367 shill::kStateProperty, 365 shill::kStateProperty,
368 new base::StringValue(state)); 366 new base::StringValue(state));
367 properties->SetWithoutPathExpansion(
368 shill::kVisibleProperty,
369 new base::FundamentalValue(add_to_visible_list));
369 if (!ipconfig_path.empty()) { 370 if (!ipconfig_path.empty()) {
370 properties->SetWithoutPathExpansion( 371 properties->SetWithoutPathExpansion(
371 shill::kIPConfigProperty, 372 shill::kIPConfigProperty,
372 new base::StringValue(ipconfig_path)); 373 new base::StringValue(ipconfig_path));
373 } 374 }
374 if (type == shill::kTypeWifi) { 375 if (type == shill::kTypeWifi) {
375 properties->SetWithoutPathExpansion( 376 properties->SetWithoutPathExpansion(
376 shill::kSecurityProperty, 377 shill::kSecurityProperty,
377 new base::StringValue(shill::kSecurityNone)); 378 new base::StringValue(shill::kSecurityNone));
378 } 379 }
379 380
380 CallSortManagerServices();
381
382 if (!profile_path.empty()) { 381 if (!profile_path.empty()) {
383 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()-> 382 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()->
384 UpdateService(profile_path, service_path); 383 UpdateService(profile_path, service_path);
385 } 384 }
385
386 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
387 AddManagerService(service_path);
386 } 388 }
387 389
388 void FakeShillServiceClient::RemoveService(const std::string& service_path) { 390 void FakeShillServiceClient::RemoveService(const std::string& service_path) {
389 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
390 RemoveManagerService(service_path, true);
391
392 stub_services_.RemoveWithoutPathExpansion(service_path, NULL); 391 stub_services_.RemoveWithoutPathExpansion(service_path, NULL);
393 connect_behavior_.erase(service_path); 392 connect_behavior_.erase(service_path);
393 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
394 RemoveManagerService(service_path);
394 } 395 }
395 396
396 bool FakeShillServiceClient::SetServiceProperty(const std::string& service_path, 397 bool FakeShillServiceClient::SetServiceProperty(const std::string& service_path,
397 const std::string& property, 398 const std::string& property,
398 const base::Value& value) { 399 const base::Value& value) {
399 base::DictionaryValue* dict = NULL; 400 base::DictionaryValue* dict = NULL;
400 if (!stub_services_.GetDictionaryWithoutPathExpansion(service_path, &dict)) 401 if (!stub_services_.GetDictionaryWithoutPathExpansion(service_path, &dict))
401 return false; 402 return false;
402 403
403 VLOG(1) << "Service.SetProperty: " << property << " = " << value 404 VLOG(1) << "Service.SetProperty: " << property << " = " << value
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 442 }
442 443
443 // Notify the Manager if the state changed (affects DefaultService). 444 // Notify the Manager if the state changed (affects DefaultService).
444 if (property == shill::kStateProperty) { 445 if (property == shill::kStateProperty) {
445 std::string state; 446 std::string state;
446 value.GetAsString(&state); 447 value.GetAsString(&state);
447 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 448 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
448 ServiceStateChanged(service_path, state); 449 ServiceStateChanged(service_path, state);
449 } 450 }
450 451
451 // If the State changes, the sort order of Services may change and the 452 // If the State or Visibility changes, the sort order of Services may change
452 // DefaultService property may change. 453 // and the DefaultService property may change.
453 if (property == shill::kStateProperty) { 454 if (property == shill::kStateProperty ||
455 property == shill::kVisibleProperty) {
454 base::MessageLoop::current()->PostTask( 456 base::MessageLoop::current()->PostTask(
455 FROM_HERE, base::Bind(&CallSortManagerServices)); 457 FROM_HERE, base::Bind(&CallSortManagerServices));
456 } 458 }
457 459
458 // Notifiy Chrome of the property change. 460 // Notifiy Chrome of the property change.
459 base::MessageLoop::current()->PostTask( 461 base::MessageLoop::current()->PostTask(
460 FROM_HERE, 462 FROM_HERE,
461 base::Bind(&FakeShillServiceClient::NotifyObserversPropertyChanged, 463 base::Bind(&FakeShillServiceClient::NotifyObserversPropertyChanged,
462 weak_ptr_factory_.GetWeakPtr(), 464 weak_ptr_factory_.GetWeakPtr(),
463 dbus::ObjectPath(service_path), changed_property)); 465 dbus::ObjectPath(service_path), changed_property));
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 base::StringValue(shill::kErrorBadPassphrase))); 609 base::StringValue(shill::kErrorBadPassphrase)));
608 } else { 610 } else {
609 // Set Online. 611 // Set Online.
610 SetServiceProperty(service_path, 612 SetServiceProperty(service_path,
611 shill::kStateProperty, 613 shill::kStateProperty,
612 base::StringValue(shill::kStateOnline)); 614 base::StringValue(shill::kStateOnline));
613 } 615 }
614 } 616 }
615 617
616 } // namespace chromeos 618 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698