OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ | 5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ |
6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ | 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ |
7 | 7 |
8 #include <unordered_set> | |
9 | |
10 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/containers/hash_tables.h" |
11 #include "base/macros.h" | 10 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
13 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
14 #include "net/base/network_change_notifier.h" | 13 #include "net/base/network_change_notifier.h" |
15 | 14 |
16 namespace net { | 15 namespace net { |
17 | 16 |
18 class NET_EXPORT_PRIVATE NetworkChangeNotifierLinux | 17 class NET_EXPORT_PRIVATE NetworkChangeNotifierLinux |
19 : public NetworkChangeNotifier { | 18 : public NetworkChangeNotifier { |
20 public: | 19 public: |
21 // Creates NetworkChangeNotifierLinux with a list of ignored interfaces. | 20 // Creates NetworkChangeNotifierLinux with a list of ignored interfaces. |
22 // |ignored_interfaces| is the list of interfaces to ignore. An ignored | 21 // |ignored_interfaces| is the list of interfaces to ignore. An ignored |
23 // interface will not trigger IP address or connection type notifications. | 22 // interface will not trigger IP address or connection type notifications. |
24 // NOTE: Only ignore interfaces not used to connect to the internet. Adding | 23 // NOTE: Only ignore interfaces not used to connect to the internet. Adding |
25 // interfaces used to connect to the internet can cause critical network | 24 // interfaces used to connect to the internet can cause critical network |
26 // changed signals to be lost allowing incorrect stale state to persist. | 25 // changed signals to be lost allowing incorrect stale state to persist. |
27 explicit NetworkChangeNotifierLinux( | 26 explicit NetworkChangeNotifierLinux( |
28 const std::unordered_set<std::string>& ignored_interfaces); | 27 const base::hash_set<std::string>& ignored_interfaces); |
29 | 28 |
30 private: | 29 private: |
31 class Thread; | 30 class Thread; |
32 | 31 |
33 ~NetworkChangeNotifierLinux() override; | 32 ~NetworkChangeNotifierLinux() override; |
34 static NetworkChangeCalculatorParams NetworkChangeCalculatorParamsLinux(); | 33 static NetworkChangeCalculatorParams NetworkChangeCalculatorParamsLinux(); |
35 | 34 |
36 // NetworkChangeNotifier: | 35 // NetworkChangeNotifier: |
37 ConnectionType GetCurrentConnectionType() const override; | 36 ConnectionType GetCurrentConnectionType() const override; |
38 | 37 |
39 const internal::AddressTrackerLinux* GetAddressTrackerInternal() | 38 const internal::AddressTrackerLinux* GetAddressTrackerInternal() |
40 const override; | 39 const override; |
41 | 40 |
42 // The thread used to listen for notifications. This relays the notification | 41 // The thread used to listen for notifications. This relays the notification |
43 // to the registered observers without posting back to the thread the object | 42 // to the registered observers without posting back to the thread the object |
44 // was created on. | 43 // was created on. |
45 // Also used for DnsConfigService which requires TYPE_IO message loop. | 44 // Also used for DnsConfigService which requires TYPE_IO message loop. |
46 scoped_ptr<Thread> notifier_thread_; | 45 scoped_ptr<Thread> notifier_thread_; |
47 | 46 |
48 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierLinux); | 47 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierLinux); |
49 }; | 48 }; |
50 | 49 |
51 } // namespace net | 50 } // namespace net |
52 | 51 |
53 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ | 52 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ |
OLD | NEW |