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

Side by Side Diff: net/quic/network_connection.h

Issue 944883003: QUIC - Cache the connection type and connection description. Make the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments to Patch Set 5 Created 5 years, 10 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/net.gypi ('k') | net/quic/network_connection.cc » ('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 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. Callers don't need
28 // to make a copy of the returned C-string value. If the connection type is
29 // CONNECTION_WIFI, then we'll tease out some details when we are on WiFi, and
30 // hopefully leave only ethernet (with no WiFi available) in the
31 // CONNECTION_UNKNOWN category. This *might* err if there is both ethernet,
32 // as well as WiFi, where WiFi was not being used that much. Most platforms
33 // don't distinguish Wifi vs Etherenet, and call everything CONNECTION_UNKNOWN
34 // :-(. Fo non CONNECTIION_WIFI, this returns the C-string returned by
35 // NetworkChangeNotifier::ConnectionTypeToString.
36 const char* GetDescription();
37
38 // It clears the cached connection_type_ and connection_description_.
39 void Clear();
40
41 // NetworkChangeNotifier::IPAddressObserver methods:
42 void OnIPAddressChanged() override;
43
44 // NetworkChangeNotifier::ConnectionTypeObserver methods:
45 void OnConnectionTypeChanged(
46 NetworkChangeNotifier::ConnectionType type) override;
47
48 private:
49 friend class test::NetworkConnectionPeer;
50
51 // Cache the connection_type and the connection description string to avoid
52 // calling expensive GetWifiPHYLayerProtocol() function.
53 NetworkChangeNotifier::ConnectionType connection_type_;
54 const char* connection_description_;
55
56 DISALLOW_COPY_AND_ASSIGN(NetworkConnection);
57 };
58
59 } // namespace net
60
61 #endif // NET_QUIC_NETWORK_CONNECTION_H_
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/quic/network_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698