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

Side by Side Diff: net/base/network_change_notifier.cc

Issue 739983005: Determine connection type in NetworkChangeNotifierLinux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from patch set 4 Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/base/network_change_notifier.h" 5 #include "net/base/network_change_notifier.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 case CONNECTION_WIFI: 649 case CONNECTION_WIFI:
650 case CONNECTION_NONE: 650 case CONNECTION_NONE:
651 case CONNECTION_BLUETOOTH: 651 case CONNECTION_BLUETOOTH:
652 is_cellular = false; 652 is_cellular = false;
653 break; 653 break;
654 } 654 }
655 return is_cellular; 655 return is_cellular;
656 } 656 }
657 657
658 // static 658 // static
659 NetworkChangeNotifier::ConnectionType
660 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(
661 const NetworkInterfaceList& interfaces) {
662 bool first = true;
663 ConnectionType result = CONNECTION_NONE;
664 for (size_t i = 0; i < interfaces.size(); ++i) {
665 #if defined(OS_WIN)
666 if (interfaces[i].friendly_name == "Teredo Tunneling Pseudo-Interface")
667 continue;
668 #endif
669 if (first) {
670 first = false;
671 result = interfaces[i].type;
672 } else if (result != interfaces[i].type) {
673 return CONNECTION_UNKNOWN;
674 }
675 }
676 return result;
677 }
678
679 // static
659 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() { 680 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() {
660 return new MockNetworkChangeNotifier(); 681 return new MockNetworkChangeNotifier();
661 } 682 }
662 683
663 void NetworkChangeNotifier::AddIPAddressObserver(IPAddressObserver* observer) { 684 void NetworkChangeNotifier::AddIPAddressObserver(IPAddressObserver* observer) {
664 if (g_network_change_notifier) 685 if (g_network_change_notifier)
665 g_network_change_notifier->ip_address_observer_list_->AddObserver(observer); 686 g_network_change_notifier->ip_address_observer_list_->AddObserver(observer);
666 } 687 }
667 688
668 void NetworkChangeNotifier::AddConnectionTypeObserver( 689 void NetworkChangeNotifier::AddConnectionTypeObserver(
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 DCHECK(g_network_change_notifier); 980 DCHECK(g_network_change_notifier);
960 g_network_change_notifier = NULL; 981 g_network_change_notifier = NULL;
961 } 982 }
962 983
963 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 984 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
964 DCHECK(!g_network_change_notifier); 985 DCHECK(!g_network_change_notifier);
965 g_network_change_notifier = network_change_notifier_; 986 g_network_change_notifier = network_change_notifier_;
966 } 987 }
967 988
968 } // namespace net 989 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698