diff options
author | pauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-07 17:37:25 +0000 |
---|---|---|
committer | pauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-07 17:37:25 +0000 |
commit | 4ec57d9fd16065b875b74a537967e6875f607be0 (patch) | |
tree | 79912ebca2a967d7ec0899a9de2abb817c3d040d | |
parent | 87ec22ff0eae429cfae3a847332cf11d78a8b6d0 (diff) | |
download | chromium_src-4ec57d9fd16065b875b74a537967e6875f607be0.zip chromium_src-4ec57d9fd16065b875b74a537967e6875f607be0.tar.gz chromium_src-4ec57d9fd16065b875b74a537967e6875f607be0.tar.bz2 |
Revert 278881 "Infer Windows network connection type from interf..."
Looks like it's causing a performance regression, see bug.
> Infer Windows network connection type from interface type.
>
> If all active network interfaces have the same network
> connection type it's safe to assume this is the type of
> the network connection. Make NetworkChangeNotifier return
> this network connection type on Windows.
>
> BUG=160537
>
> Review URL: https://codereview.chromium.org/298023005
BUG=387625
TBR=pauljensen@chromium.org
Review URL: https://codereview.chromium.org/375573002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281555 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/base/network_change_notifier.cc | 30 | ||||
-rw-r--r-- | net/base/network_change_notifier.h | 16 | ||||
-rw-r--r-- | net/base/network_change_notifier_unittest.cc | 65 | ||||
-rw-r--r-- | net/base/network_change_notifier_win.cc | 3 | ||||
-rw-r--r-- | net/net.gypi | 1 |
5 files changed, 2 insertions, 113 deletions
diff --git a/net/base/network_change_notifier.cc b/net/base/network_change_notifier.cc index 4d52839..d451e07 100644 --- a/net/base/network_change_notifier.cc +++ b/net/base/network_change_notifier.cc @@ -801,36 +801,6 @@ void NetworkChangeNotifier::SetDnsConfig(const DnsConfig& config) { NotifyObserversOfDNSChange(); } -// static -NetworkChangeNotifier::ConnectionType -NetworkChangeNotifier::ConnectionTypeFromInterfaces() { - NetworkInterfaceList interfaces; - if (!GetNetworkList(&interfaces, EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES)) - return CONNECTION_UNKNOWN; - return ConnectionTypeFromInterfaceList(interfaces); -} - -//static -NetworkChangeNotifier::ConnectionType -NetworkChangeNotifier::ConnectionTypeFromInterfaceList( - const NetworkInterfaceList& interfaces) { - bool first = true; - ConnectionType result = CONNECTION_UNKNOWN; - for (size_t i = 0; i < interfaces.size(); ++i) { -#if defined(OS_WIN) - if (interfaces[i].friendly_name == "Teredo Tunneling Pseudo-Interface") - continue; -#endif - if (first) { - first = false; - result = interfaces[i].type; - } else if (result != interfaces[i].type) { - return CONNECTION_UNKNOWN; - } - } - return result; -} - void NetworkChangeNotifier::NotifyObserversOfIPAddressChangeImpl() { ip_address_observer_list_->Notify(&IPAddressObserver::OnIPAddressChanged); } diff --git a/net/base/network_change_notifier.h b/net/base/network_change_notifier.h index 8d64444..b29426e 100644 --- a/net/base/network_change_notifier.h +++ b/net/base/network_change_notifier.h @@ -5,10 +5,7 @@ #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ -#include <vector> - #include "base/basictypes.h" -#include "base/gtest_prod_util.h" #include "base/observer_list_threadsafe.h" #include "base/time/time.h" #include "net/base/net_export.h" @@ -20,8 +17,6 @@ namespace net { struct DnsConfig; class HistogramWatcher; class NetworkChangeNotifierFactory; -struct NetworkInterface; -typedef std::vector<NetworkInterface> NetworkInterfaceList; class URLRequest; #if defined(OS_LINUX) @@ -310,26 +305,15 @@ class NET_EXPORT NetworkChangeNotifier { // Stores |config| in NetworkState and notifies observers. static void SetDnsConfig(const DnsConfig& config); - // Infer connection type from |GetNetworkList|. If all network interfaces have - // the same type, return it, otherwise return CONNECTION_UNKNOWN. - static ConnectionType ConnectionTypeFromInterfaces(); - private: friend class HostResolverImplDnsTest; friend class NetworkChangeNotifierAndroidTest; friend class NetworkChangeNotifierLinuxTest; friend class NetworkChangeNotifierWinTest; - FRIEND_TEST_ALL_PREFIXES(NetworkChangeNotifierTest, - InterfacesToConnectionType); class NetworkState; class NetworkChangeCalculator; - // Infer connection type from |interfaces|. If all network interfaces have - // the same type, return it, otherwise return CONNECTION_UNKNOWN. - static ConnectionType ConnectionTypeFromInterfaceList( - const NetworkInterfaceList& interfaces); - void NotifyObserversOfIPAddressChangeImpl(); void NotifyObserversOfConnectionTypeChangeImpl(ConnectionType type); void NotifyObserversOfDNSChangeImpl(); diff --git a/net/base/network_change_notifier_unittest.cc b/net/base/network_change_notifier_unittest.cc deleted file mode 100644 index 87fb093..0000000 --- a/net/base/network_change_notifier_unittest.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "network_change_notifier.h" - -#include "net/base/net_util.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace net { - -TEST(NetworkChangeNotifierTest, InterfacesToConnectionType) { - NetworkInterfaceList list; - - // Test empty list. - EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), - NetworkChangeNotifier::CONNECTION_UNKNOWN); - - NetworkInterface interface; - for (int i = NetworkChangeNotifier::CONNECTION_UNKNOWN; - i < NetworkChangeNotifier::CONNECTION_LAST; - i++) { - // Check individual types. - list.clear(); - interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i); - list.push_back(interface); - EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), i); - // Check two types. - for (int j = NetworkChangeNotifier::CONNECTION_UNKNOWN; - j < NetworkChangeNotifier::CONNECTION_LAST; - j++) { - list.clear(); - interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i); - list.push_back(interface); - interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(j); - list.push_back(interface); - EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), - i == j ? i : NetworkChangeNotifier::CONNECTION_UNKNOWN); - } - } - -#if defined(OS_WIN) - // Ignore fake Teredo interface. - list.clear(); - interface.type = NetworkChangeNotifier::CONNECTION_4G; - interface.friendly_name = "Teredo Tunneling Pseudo-Interface"; - list.push_back(interface); - // Verify Teredo interface type ignored. - EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), - NetworkChangeNotifier::CONNECTION_UNKNOWN); - // Verify type of non-Teredo interface used. - interface.type = NetworkChangeNotifier::CONNECTION_3G; - interface.friendly_name = ""; - list.push_back(interface); - EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), - NetworkChangeNotifier::CONNECTION_3G); - // Reverse elements. - list.push_back(list[0]); - list.erase(list.begin()); - EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), - NetworkChangeNotifier::CONNECTION_3G); -#endif -} - -} // namespace net diff --git a/net/base/network_change_notifier_win.cc b/net/base/network_change_notifier_win.cc index 05268d4..77a72b0 100644 --- a/net/base/network_change_notifier_win.cc +++ b/net/base/network_change_notifier_win.cc @@ -200,7 +200,8 @@ NetworkChangeNotifierWin::RecomputeCurrentConnectionType() const { LOG_IF(ERROR, result != 0) << "WSALookupServiceEnd() failed with: " << result; - return found_connection ? ConnectionTypeFromInterfaces() : + // TODO(droger): Return something more detailed than CONNECTION_UNKNOWN. + return found_connection ? NetworkChangeNotifier::CONNECTION_UNKNOWN : NetworkChangeNotifier::CONNECTION_NONE; } diff --git a/net/net.gypi b/net/net.gypi index 4481a34..712a3a5 100644 --- a/net/net.gypi +++ b/net/net.gypi @@ -1256,7 +1256,6 @@ 'base/net_log_unittest.h', 'base/net_util_unittest.cc', 'base/net_util_icu_unittest.cc', - 'base/network_change_notifier_unittest.cc', 'base/network_change_notifier_win_unittest.cc', 'base/prioritized_dispatcher_unittest.cc', 'base/priority_queue_unittest.cc', |