OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #ifndef NET_NQE_NETWORK_ID_H_ |
| 6 #define NET_NQE_NETWORK_ID_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <tuple> |
| 10 |
| 11 #include "net/base/net_export.h" |
| 12 #include "net/base/network_change_notifier.h" |
| 13 |
| 14 namespace net { |
| 15 namespace nqe { |
| 16 namespace internal { |
| 17 |
| 18 // NetworkID is used to uniquely identify a network. |
| 19 // For the purpose of network quality estimation and caching, a network is |
| 20 // uniquely identified by a combination of |type| and |
| 21 // |id|. This approach is unable to distinguish networks with |
| 22 // same name (e.g., different Wi-Fi networks with same SSID). |
| 23 // This is a protected member to expose it to tests. |
| 24 struct NET_EXPORT_PRIVATE NetworkID { |
| 25 NetworkID(NetworkChangeNotifier::ConnectionType type, const std::string& id) |
| 26 : type(type), id(id) {} |
| 27 NetworkID(const NetworkID& other) : type(other.type), id(other.id) {} |
| 28 ~NetworkID() {} |
| 29 |
| 30 NetworkID& operator=(const NetworkID& other) { |
| 31 type = other.type; |
| 32 id = other.id; |
| 33 return *this; |
| 34 } |
| 35 |
| 36 // Overloaded to support ordered collections. |
| 37 bool operator<(const NetworkID& other) const { |
| 38 return std::tie(type, id) < std::tie(other.type, other.id); |
| 39 } |
| 40 |
| 41 // Connection type of the network. |
| 42 NetworkChangeNotifier::ConnectionType type; |
| 43 |
| 44 // Name of this network. This is set to: |
| 45 // - Wi-Fi SSID if the device is connected to a Wi-Fi access point and the |
| 46 // SSID name is available, or |
| 47 // - MCC/MNC code of the cellular carrier if the device is connected to a |
| 48 // cellular network, or |
| 49 // - "Ethernet" in case the device is connected to ethernet. |
| 50 // - An empty string in all other cases or if the network name is not |
| 51 // exposed by platform APIs. |
| 52 std::string id; |
| 53 }; |
| 54 |
| 55 } // namespace internal |
| 56 } // namespace nqe |
| 57 } // namespace net |
| 58 |
| 59 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
OLD | NEW |