OLD | NEW |
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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 case CONNECTION_WIFI: | 648 case CONNECTION_WIFI: |
649 case CONNECTION_NONE: | 649 case CONNECTION_NONE: |
650 case CONNECTION_BLUETOOTH: | 650 case CONNECTION_BLUETOOTH: |
651 is_cellular = false; | 651 is_cellular = false; |
652 break; | 652 break; |
653 } | 653 } |
654 return is_cellular; | 654 return is_cellular; |
655 } | 655 } |
656 | 656 |
657 // static | 657 // static |
| 658 NetworkChangeNotifier::ConnectionType |
| 659 NetworkChangeNotifier::ConnectionTypeFromInterfaceList( |
| 660 const NetworkInterfaceList& interfaces) { |
| 661 bool first = true; |
| 662 ConnectionType result = CONNECTION_NONE; |
| 663 for (size_t i = 0; i < interfaces.size(); ++i) { |
| 664 #if defined(OS_WIN) |
| 665 if (interfaces[i].friendly_name == "Teredo Tunneling Pseudo-Interface") |
| 666 continue; |
| 667 #endif |
| 668 if (first) { |
| 669 first = false; |
| 670 result = interfaces[i].type; |
| 671 } else if (result != interfaces[i].type) { |
| 672 return CONNECTION_UNKNOWN; |
| 673 } |
| 674 } |
| 675 return result; |
| 676 } |
| 677 |
| 678 // static |
658 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() { | 679 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() { |
659 return new MockNetworkChangeNotifier(); | 680 return new MockNetworkChangeNotifier(); |
660 } | 681 } |
661 | 682 |
662 void NetworkChangeNotifier::AddIPAddressObserver(IPAddressObserver* observer) { | 683 void NetworkChangeNotifier::AddIPAddressObserver(IPAddressObserver* observer) { |
663 if (g_network_change_notifier) | 684 if (g_network_change_notifier) |
664 g_network_change_notifier->ip_address_observer_list_->AddObserver(observer); | 685 g_network_change_notifier->ip_address_observer_list_->AddObserver(observer); |
665 } | 686 } |
666 | 687 |
667 void NetworkChangeNotifier::AddConnectionTypeObserver( | 688 void NetworkChangeNotifier::AddConnectionTypeObserver( |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 DCHECK(g_network_change_notifier); | 979 DCHECK(g_network_change_notifier); |
959 g_network_change_notifier = NULL; | 980 g_network_change_notifier = NULL; |
960 } | 981 } |
961 | 982 |
962 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 983 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
963 DCHECK(!g_network_change_notifier); | 984 DCHECK(!g_network_change_notifier); |
964 g_network_change_notifier = network_change_notifier_; | 985 g_network_change_notifier = network_change_notifier_; |
965 } | 986 } |
966 | 987 |
967 } // namespace net | 988 } // namespace net |
OLD | NEW |