Use the correct typedef for the return value of BlinkPlatformImpl::getTraceSamplingState
[chromium-blink-merge.git] / net / quic / network_connection.cc
blob870ff343510f8aeec7597595ad7ac9e27bb10f1a
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/net_util.h"
9 namespace net {
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();
30 switch (wifi_type) {
31 case WIFI_PHY_LAYER_PROTOCOL_NONE:
32 // No wifi support or no associated AP.
33 break;
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";
37 break;
38 case WIFI_PHY_LAYER_PROTOCOL_A:
39 // 802.11a, OFDM-based rates.
40 connection_description_ = "CONNECTION_WIFI_802.11a";
41 break;
42 case WIFI_PHY_LAYER_PROTOCOL_B:
43 // 802.11b, DSSS or HR DSSS.
44 connection_description_ = "CONNECTION_WIFI_802.11b";
45 break;
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";
49 break;
50 case WIFI_PHY_LAYER_PROTOCOL_N:
51 // 802.11n, HT rates.
52 connection_description_ = "CONNECTION_WIFI_802.11n";
53 break;
54 case WIFI_PHY_LAYER_PROTOCOL_UNKNOWN:
55 // Unclassified mode or failure to identify.
56 break;
59 return connection_description_;
62 void NetworkConnection::Clear() {
63 connection_type_ = NetworkChangeNotifier::CONNECTION_UNKNOWN;
64 connection_description_ = nullptr;
67 void NetworkConnection::OnIPAddressChanged() {
68 Clear();
71 void NetworkConnection::OnConnectionTypeChanged(
72 NetworkChangeNotifier::ConnectionType type) {
73 Clear();
76 } // namespace net