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
3 // found in the LICENSE file.
5 #include "net/quic/network_connection.h"
7 #include "net/base/network_interfaces.h"
11 NetworkConnection::NetworkConnection()
12 : connection_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN
),
13 connection_description_(nullptr) {
16 const char* NetworkConnection::GetDescription() {
17 NetworkChangeNotifier::ConnectionType type
=
18 NetworkChangeNotifier::GetConnectionType();
19 if (connection_description_
!= nullptr && type
== connection_type_
)
20 return connection_description_
;
22 DVLOG(1) << "Updating NetworkConnection's Cached Data";
24 connection_description_
= NetworkChangeNotifier::ConnectionTypeToString(type
);
25 connection_type_
= type
;
26 if (connection_type_
== NetworkChangeNotifier::CONNECTION_UNKNOWN
||
27 connection_type_
== NetworkChangeNotifier::CONNECTION_WIFI
) {
28 // This function only seems usefully defined on Windows currently.
29 WifiPHYLayerProtocol wifi_type
= GetWifiPHYLayerProtocol();
31 case WIFI_PHY_LAYER_PROTOCOL_NONE
:
32 // No wifi support or no associated AP.
34 case WIFI_PHY_LAYER_PROTOCOL_ANCIENT
:
35 // An obsolete modes introduced by the original 802.11, e.g. IR, FHSS.
36 connection_description_
= "CONNECTION_WIFI_ANCIENT";
38 case WIFI_PHY_LAYER_PROTOCOL_A
:
39 // 802.11a, OFDM-based rates.
40 connection_description_
= "CONNECTION_WIFI_802.11a";
42 case WIFI_PHY_LAYER_PROTOCOL_B
:
43 // 802.11b, DSSS or HR DSSS.
44 connection_description_
= "CONNECTION_WIFI_802.11b";
46 case WIFI_PHY_LAYER_PROTOCOL_G
:
47 // 802.11g, same rates as 802.11a but compatible with 802.11b.
48 connection_description_
= "CONNECTION_WIFI_802.11g";
50 case WIFI_PHY_LAYER_PROTOCOL_N
:
52 connection_description_
= "CONNECTION_WIFI_802.11n";
54 case WIFI_PHY_LAYER_PROTOCOL_UNKNOWN
:
55 // Unclassified mode or failure to identify.
59 return connection_description_
;
62 void NetworkConnection::Clear() {
63 connection_type_
= NetworkChangeNotifier::CONNECTION_UNKNOWN
;
64 connection_description_
= nullptr;
67 void NetworkConnection::OnIPAddressChanged() {
71 void NetworkConnection::OnConnectionTypeChanged(
72 NetworkChangeNotifier::ConnectionType type
) {