• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Chromium Authors
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 "net/base/net_export.h"
9 #include "net/base/network_change_notifier.h"
10 
11 namespace net {
12 
13 // This class stores information about the current network type and
14 // provides a textual description of it.
15 class NET_EXPORT NetworkConnection
16     : public NetworkChangeNotifier::IPAddressObserver,
17       public NetworkChangeNotifier::ConnectionTypeObserver {
18  public:
19   NetworkConnection();
20 
21   NetworkConnection(const NetworkConnection&) = delete;
22   NetworkConnection& operator=(const NetworkConnection&) = delete;
23 
24   ~NetworkConnection() override;
25 
26   // Returns the underlying connection type.
connection_type()27   NetworkChangeNotifier::ConnectionType connection_type() {
28     return connection_type_;
29   }
30 
31   // NetworkChangeNotifier::IPAddressObserver methods:
32   void OnIPAddressChanged() override;
33 
34   // NetworkChangeNotifier::ConnectionTypeObserver methods:
35   void OnConnectionTypeChanged(
36       NetworkChangeNotifier::ConnectionType type) override;
37 
38  private:
39   // Cache the connection type to avoid calling the potentially expensive
40   // NetworkChangeNotifier::GetConnectionType() function.
41   NetworkChangeNotifier::ConnectionType connection_type_ =
42       NetworkChangeNotifier::CONNECTION_UNKNOWN;
43 };
44 
45 }  // namespace net
46 
47 #endif  // NET_QUIC_NETWORK_CONNECTION_H_
48