1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/quic/network_connection.h" 6 7 #include "base/logging.h" 8 #include "net/base/network_interfaces.h" 9 10 namespace net { 11 NetworkConnection()12NetworkConnection::NetworkConnection() { 13 NetworkChangeNotifier::AddIPAddressObserver(this); 14 NetworkChangeNotifier::AddConnectionTypeObserver(this); 15 OnIPAddressChanged(); 16 } 17 ~NetworkConnection()18NetworkConnection::~NetworkConnection() { 19 NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 20 NetworkChangeNotifier::RemoveIPAddressObserver(this); 21 } 22 OnIPAddressChanged()23void NetworkConnection::OnIPAddressChanged() { 24 OnConnectionTypeChanged(NetworkChangeNotifier::GetConnectionType()); 25 } 26 OnConnectionTypeChanged(NetworkChangeNotifier::ConnectionType type)27void NetworkConnection::OnConnectionTypeChanged( 28 NetworkChangeNotifier::ConnectionType type) { 29 DVLOG(1) << "Updating NetworkConnection's Cached Data"; 30 31 connection_type_ = type; 32 connection_description_ = NetworkChangeNotifier::ConnectionTypeToString(type); 33 if (connection_type_ != NetworkChangeNotifier::CONNECTION_UNKNOWN && 34 connection_type_ != NetworkChangeNotifier::CONNECTION_WIFI) { 35 return; 36 } 37 38 // This function only seems usefully defined on Windows currently. 39 WifiPHYLayerProtocol wifi_type = GetWifiPHYLayerProtocol(); 40 switch (wifi_type) { 41 case WIFI_PHY_LAYER_PROTOCOL_NONE: 42 // No wifi support or no associated AP. 43 break; 44 case WIFI_PHY_LAYER_PROTOCOL_ANCIENT: 45 // An obsolete modes introduced by the original 802.11, e.g. IR, FHSS. 46 connection_description_ = "CONNECTION_WIFI_ANCIENT"; 47 break; 48 case WIFI_PHY_LAYER_PROTOCOL_A: 49 // 802.11a, OFDM-based rates. 50 connection_description_ = "CONNECTION_WIFI_802.11a"; 51 break; 52 case WIFI_PHY_LAYER_PROTOCOL_B: 53 // 802.11b, DSSS or HR DSSS. 54 connection_description_ = "CONNECTION_WIFI_802.11b"; 55 break; 56 case WIFI_PHY_LAYER_PROTOCOL_G: 57 // 802.11g, same rates as 802.11a but compatible with 802.11b. 58 connection_description_ = "CONNECTION_WIFI_802.11g"; 59 break; 60 case WIFI_PHY_LAYER_PROTOCOL_N: 61 // 802.11n, HT rates. 62 connection_description_ = "CONNECTION_WIFI_802.11n"; 63 break; 64 case WIFI_PHY_LAYER_PROTOCOL_AC: 65 // 802.11ac 66 connection_description_ = "CONNECTION_WIFI_802.11ac"; 67 break; 68 case WIFI_PHY_LAYER_PROTOCOL_AD: 69 // 802.11ad 70 connection_description_ = "CONNECTION_WIFI_802.11ad"; 71 break; 72 case WIFI_PHY_LAYER_PROTOCOL_AX: 73 // 802.11ax 74 connection_description_ = "CONNECTION_WIFI_802.11ax"; 75 break; 76 case WIFI_PHY_LAYER_PROTOCOL_UNKNOWN: 77 // Unclassified mode or failure to identify. 78 break; 79 } 80 } 81 82 } // namespace net 83