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 | |
16 namespace nqe { | |
17 | |
18 namespace internal { | |
19 | |
20 // NetworkID is used to uniquely identify a network. | |
21 // For the purpose of network quality estimation and caching, a network is | |
22 // uniquely identified by a combination of |type| and | |
23 // |id|. This approach is unable to distinguish networks with | |
24 // same name (e.g., different Wi-Fi networks with same SSID). | |
25 // This is a protected member to expose it to tests. | |
26 struct NET_EXPORT_PRIVATE NetworkID { | |
27 NetworkID(NetworkChangeNotifier::ConnectionType type, const std::string& id) | |
28 : type(type), id(id) {} | |
29 NetworkID(const NetworkID& other) : type(other.type), id(other.id) {} | |
30 ~NetworkID() {} | |
31 | |
32 NetworkID& operator=(const NetworkID& other) { | |
33 type = other.type; | |
34 id = other.id; | |
35 return *this; | |
36 } | |
37 | |
38 // Overloaded because NetworkID is used as key in a map. | |
bengr
2016/07/19 01:04:35
I'd remove the comment because NetworkID should no
tbansal1
2016/07/20 00:08:47
Done.
| |
39 bool operator<(const NetworkID& other) const { | |
40 return std::tie(type, id) < std::tie(other.type, other.id); | |
41 } | |
42 | |
43 // Connection type of the network. | |
44 NetworkChangeNotifier::ConnectionType type; | |
45 | |
46 // Name of this network. This is set to: | |
47 // - Wi-Fi SSID if the device is connected to a Wi-Fi access point and the | |
48 // SSID name is available, or | |
49 // - MCC/MNC code of the cellular carrier if the device is connected to a | |
50 // cellular network, or | |
51 // - "Ethernet" in case the device is connected to ethernet. | |
52 // - An empty string in all other cases or if the network name is not | |
53 // exposed by platform APIs. | |
54 std::string id; | |
55 }; | |
56 | |
57 } // namespace internal | |
58 | |
59 } // namespace nqe | |
60 | |
61 } // namespace net | |
62 | |
63 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | |
OLD | NEW |