| Index: chrome/browser/chromeos/cros/network_library.cc
|
| diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc
|
| index bca39b932124c5eef208bff4f971439d369180c2..106c9004e4ac6ec0c2ab5684d56db67ea031603c 100644
|
| --- a/chrome/browser/chromeos/cros/network_library.cc
|
| +++ b/chrome/browser/chromeos/cros/network_library.cc
|
| @@ -1825,18 +1825,28 @@ void NetworkLibraryImplBase::RemoveUserActionObserver(
|
| // Use flimflam's ordering of the services to determine which type of
|
| // network to return (i.e. don't assume priority of network types).
|
| // Note: This does not include any virtual networks.
|
| +namespace {
|
| +Network* highest_priority(Network* a, Network*b) {
|
| + if (!a)
|
| + return b;
|
| + if (!b)
|
| + return a;
|
| + if (b->priority_order() < a->priority_order())
|
| + return b;
|
| + return a;
|
| +}
|
| +}
|
| +
|
| const Network* NetworkLibraryImplBase::active_network() const {
|
| Network* result = NULL;
|
| if (ethernet_ && ethernet_->is_active())
|
| result = ethernet_;
|
| - if ((active_wifi_ && active_wifi_->is_active()) &&
|
| - (!result ||
|
| - active_wifi_->priority_order_ < result->priority_order_))
|
| - result = active_wifi_;
|
| - if ((active_cellular_ && active_cellular_->is_active()) &&
|
| - (!result ||
|
| - active_cellular_->priority_order_ < result->priority_order_))
|
| - result = active_cellular_;
|
| + if (active_wifi_ && active_wifi_->is_active())
|
| + result = highest_priority(result, active_wifi_);
|
| + if (active_cellular_ && active_cellular_->is_active())
|
| + result = highest_priority(result, active_cellular_);
|
| + if (active_virtual_ && active_virtual_->is_active())
|
| + result = highest_priority(result, active_virtual_);
|
| return result;
|
| }
|
|
|
| @@ -1844,14 +1854,10 @@ const Network* NetworkLibraryImplBase::connected_network() const {
|
| Network* result = NULL;
|
| if (ethernet_ && ethernet_->connected())
|
| result = ethernet_;
|
| - if ((active_wifi_ && active_wifi_->connected()) &&
|
| - (!result ||
|
| - active_wifi_->priority_order_ < result->priority_order_))
|
| - result = active_wifi_;
|
| - if ((active_cellular_ && active_cellular_->connected()) &&
|
| - (!result ||
|
| - active_cellular_->priority_order_ < result->priority_order_))
|
| - result = active_cellular_;
|
| + if (active_wifi_ && active_wifi_->connected())
|
| + result = highest_priority(result, active_wifi_);
|
| + if (active_cellular_ && active_cellular_->connected())
|
| + result = highest_priority(result, active_cellular_);
|
| return result;
|
| }
|
|
|
|
|