Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Unified Diff: net/quic/network_connection.cc

Issue 944883003: QUIC - Cache the connection type and connection description. Make the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments to Patch Set 5 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/network_connection.h ('k') | net/quic/network_connection_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/network_connection.cc
diff --git a/net/quic/network_connection.cc b/net/quic/network_connection.cc
new file mode 100644
index 0000000000000000000000000000000000000000..870ff343510f8aeec7597595ad7ac9e27bb10f1a
--- /dev/null
+++ b/net/quic/network_connection.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2012 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 "net/quic/network_connection.h"
+
+#include "net/base/net_util.h"
+
+namespace net {
+
+NetworkConnection::NetworkConnection()
+ : connection_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN),
+ connection_description_(nullptr) {
+}
+
+const char* NetworkConnection::GetDescription() {
+ NetworkChangeNotifier::ConnectionType type =
+ NetworkChangeNotifier::GetConnectionType();
+ if (connection_description_ != nullptr && type == connection_type_)
+ return connection_description_;
+
+ DVLOG(1) << "Updating NetworkConnection's Cached Data";
+
+ connection_description_ = NetworkChangeNotifier::ConnectionTypeToString(type);
+ connection_type_ = type;
+ if (connection_type_ == NetworkChangeNotifier::CONNECTION_UNKNOWN ||
+ connection_type_ == NetworkChangeNotifier::CONNECTION_WIFI) {
+ // This function only seems usefully defined on Windows currently.
+ WifiPHYLayerProtocol wifi_type = GetWifiPHYLayerProtocol();
+ switch (wifi_type) {
+ case WIFI_PHY_LAYER_PROTOCOL_NONE:
+ // No wifi support or no associated AP.
+ break;
+ case WIFI_PHY_LAYER_PROTOCOL_ANCIENT:
+ // An obsolete modes introduced by the original 802.11, e.g. IR, FHSS.
+ connection_description_ = "CONNECTION_WIFI_ANCIENT";
+ break;
+ case WIFI_PHY_LAYER_PROTOCOL_A:
+ // 802.11a, OFDM-based rates.
+ connection_description_ = "CONNECTION_WIFI_802.11a";
+ break;
+ case WIFI_PHY_LAYER_PROTOCOL_B:
+ // 802.11b, DSSS or HR DSSS.
+ connection_description_ = "CONNECTION_WIFI_802.11b";
+ break;
+ case WIFI_PHY_LAYER_PROTOCOL_G:
+ // 802.11g, same rates as 802.11a but compatible with 802.11b.
+ connection_description_ = "CONNECTION_WIFI_802.11g";
+ break;
+ case WIFI_PHY_LAYER_PROTOCOL_N:
+ // 802.11n, HT rates.
+ connection_description_ = "CONNECTION_WIFI_802.11n";
+ break;
+ case WIFI_PHY_LAYER_PROTOCOL_UNKNOWN:
+ // Unclassified mode or failure to identify.
+ break;
+ }
+ }
+ return connection_description_;
+}
+
+void NetworkConnection::Clear() {
+ connection_type_ = NetworkChangeNotifier::CONNECTION_UNKNOWN;
+ connection_description_ = nullptr;
+}
+
+void NetworkConnection::OnIPAddressChanged() {
+ Clear();
+}
+
+void NetworkConnection::OnConnectionTypeChanged(
+ NetworkChangeNotifier::ConnectionType type) {
+ Clear();
+}
+
+} // namespace net
« no previous file with comments | « net/quic/network_connection.h ('k') | net/quic/network_connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698