OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_QUIC_NETWORK_CONNECTION_H_ | |
6 #define NET_QUIC_NETWORK_CONNECTION_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "net/base/net_export.h" | |
10 #include "net/base/network_change_notifier.h" | |
11 | |
12 namespace net { | |
13 | |
14 namespace test { | |
15 class NetworkConnectionPeer; | |
16 } // namespace test | |
17 | |
18 // This class returns the current network's connection description. It also | |
19 // cache's the connection description to fix crbug.com/422516. | |
20 class NET_EXPORT NetworkConnection | |
21 : public NetworkChangeNotifier::IPAddressObserver, | |
22 public NetworkChangeNotifier::ConnectionTypeObserver { | |
23 public: | |
24 NetworkConnection(); | |
25 ~NetworkConnection() override {} | |
26 | |
27 // Return a string equivalent of current connection type. If the | |
28 // connection type is CONNECTION_WIFI, then we'll tease out some | |
29 // details when we are on WiFi, and hopefully leave only ethernet | |
30 // (with no WiFi available) in the CONNECTION_UNKNOWN category. This | |
31 // *might* err if there is both ethernet, as well as WiFi, where WiFi | |
32 // was not being used that much. Most platforms don't distinguish Wifi vs | |
33 // Etherenet, and call everything CONNECTION_UNKNOWN :-(. | |
34 // Fo non CONNECTIION_WIFI, this returns the C-string returned by | |
35 // NetworkChangeNotifier::ConnectionTypeToString. Callers don't need to make a | |
Ryan Hamilton
2015/02/23 20:42:19
nit: please move the ownership comment to be the s
ramant (doing other things)
2015/02/23 21:05:29
Done.
| |
36 // copy of the returned C-string value. | |
37 const char* GetDescription(); | |
38 | |
39 // It clears the cached connection_type_ and connection_description_. | |
40 void Clear(); | |
41 | |
42 // NetworkChangeNotifier::IPAddressObserver methods: | |
43 void OnIPAddressChanged() override; | |
44 | |
45 // NetworkChangeNotifier::ConnectionTypeObserver methods: | |
46 void OnConnectionTypeChanged( | |
47 NetworkChangeNotifier::ConnectionType type) override; | |
48 | |
49 private: | |
50 friend class test::NetworkConnectionPeer; | |
51 | |
52 // Cache the connection_type and the connection description string to avoid | |
53 // calling expensive GetWifiPHYLayerProtocol() function. | |
54 NetworkChangeNotifier::ConnectionType connection_type_; | |
55 const char* connection_description_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(NetworkConnection); | |
58 }; | |
59 | |
60 } // namespace net | |
61 | |
62 #endif // NET_QUIC_NETWORK_CONNECTION_H_ | |
OLD | NEW |