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

Side by Side Diff: net/nqe/network_id.h

Issue 2128793003: Factor out NetworkID and caching mechanism from n_q_e.{h,cc} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bengr comments Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « net/nqe/cached_network_quality.cc ('k') | net/nqe/network_quality.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
Alexei Svitkine (slow) 2016/07/25 15:33:27 Optional nit: I think it's fine to omit newlines b
tbansal1 2016/07/25 17:22:37 Done.
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 to support ordered collections.
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_
OLDNEW
« no previous file with comments | « net/nqe/cached_network_quality.cc ('k') | net/nqe/network_quality.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698