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

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: Move description caching into a distinct class 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
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. 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 const char* GetDescription();
Ryan Hamilton 2015/02/23 18:43:00 Please comment on the lifetime/ownership of this v
ramant (doing other things) 2015/02/23 19:50:18 Done.
35
36 // It clears the cached connection_type_ and connection_description_.
37 void Clear();
38
39 // NetworkChangeNotifier::IPAddressObserver methods:
40 void OnIPAddressChanged() override;
41
42 // NetworkChangeNotifier::ConnectionTypeObserver methods:
43 void OnConnectionTypeChanged(
44 NetworkChangeNotifier::ConnectionType type) override;
45
46 private:
47 friend class test::NetworkConnectionPeer;
48
49 // Cache the connection_type and the connection description string to avoid
50 // calling expensive GetWifiPHYLayerProtocol() function.
51 NetworkChangeNotifier::ConnectionType connection_type_;
52 const char* connection_description_;
53
54 DISALLOW_COPY_AND_ASSIGN(NetworkConnection);
55 };
56
57 } // namespace net
58
59 #endif // NET_QUIC_NETWORK_CONNECTION_H_
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/quic/network_connection.cc » ('j') | net/quic/quic_connection_logger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698