From 4d201ec63db39d03f5928550d3777859965d8759 Mon Sep 17 00:00:00 2001 From: "stevenjb@chromium.org" Date: Wed, 5 Mar 2014 19:54:40 +0000 Subject: Chrome OS: Use Manager.DefaultService for Default Network This changes Chrome to use Manager.DefaultService to provide the default network to Chrome (i.e. NetworkChangeNotifier) instead of relying on Manager.Services[0]. This should fix some timing issues and make the NCS more in sync with Shill. One change in behavior that should be benign is that Shill considers a connecting network to be the default network, whereas previously only a connected network would be considered. BUG=159540, 330873 R=gauravsh@chromium.org, pneubeck@chromium.org, tbarzic@chromium.org Review URL: https://codereview.chromium.org/175243004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255124 0039d316-1c4b-4281-b951-d872f2087c98 --- chromeos/dbus/fake_shill_service_client.cc | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'chromeos/dbus/fake_shill_service_client.cc') diff --git a/chromeos/dbus/fake_shill_service_client.cc b/chromeos/dbus/fake_shill_service_client.cc index 8987c18..ed47b28 100644 --- a/chromeos/dbus/fake_shill_service_client.cc +++ b/chromeos/dbus/fake_shill_service_client.cc @@ -39,6 +39,11 @@ void PassStubServiceProperties( callback.Run(call_status, *properties); } +void CallSortManagerServices() { + DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> + SortManagerServices(); +} + } // namespace FakeShillServiceClient::FakeShillServiceClient() : weak_ptr_factory_(this) { @@ -358,10 +363,14 @@ void FakeShillServiceClient::AddServiceWithIPConfig( properties->SetWithoutPathExpansion( shill::kStateProperty, base::Value::CreateStringValue(state)); - if (!ipconfig_path.empty()) + if (!ipconfig_path.empty()) { properties->SetWithoutPathExpansion( shill::kIPConfigProperty, base::Value::CreateStringValue(ipconfig_path)); + } + + DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> + SortManagerServices(); } void FakeShillServiceClient::RemoveService(const std::string& service_path) { @@ -401,12 +410,22 @@ bool FakeShillServiceClient::SetServiceProperty(const std::string& service_path, dict->MergeDictionary(&new_properties); + // Notify the Manager if the state changed (affects DefaultService). if (property == shill::kStateProperty) { - // When State changes the sort order of Services may change. + std::string state; + value.GetAsString(&state); DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> - SortManagerServices(); + ServiceStateChanged(service_path, state); + } + + // If the State changes, the sort order of Services may change and the + // DefaultService property may change. + if (property == shill::kStateProperty) { + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&CallSortManagerServices)); } + // Notifiy Chrome of the property change. base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&FakeShillServiceClient::NotifyObserversPropertyChanged, -- cgit v1.1