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

Unified Diff: chrome/browser/chromeos/cros/network_library.cc

Issue 7633046: Fix VPN icon issues (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mock expectations. Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.h ('k') | chrome/browser/chromeos/network_login_observer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.h ('k') | chrome/browser/chromeos/network_login_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698