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