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_WIN_H_ | 5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_WIN_H_ |
6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_WIN_H_ | 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/callback.h" | |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
16 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
17 #include "base/win/object_watcher.h" | 18 #include "base/win/object_watcher.h" |
18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
19 #include "net/base/network_change_notifier.h" | 20 #include "net/base/network_change_notifier.h" |
20 | 21 |
21 namespace net { | 22 namespace net { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 ConnectionType GetCurrentConnectionType() const override; | 56 ConnectionType GetCurrentConnectionType() const override; |
56 | 57 |
57 // ObjectWatcher::Delegate methods: | 58 // ObjectWatcher::Delegate methods: |
58 // Must only be called on the thread |this| was created on. | 59 // Must only be called on the thread |this| was created on. |
59 void OnObjectSignaled(HANDLE object) override; | 60 void OnObjectSignaled(HANDLE object) override; |
60 | 61 |
61 // Does the actual work to determine the current connection type. | 62 // Does the actual work to determine the current connection type. |
62 // It is not thread safe, see crbug.com/324913. | 63 // It is not thread safe, see crbug.com/324913. |
63 virtual ConnectionType RecomputeCurrentConnectionType() const; | 64 virtual ConnectionType RecomputeCurrentConnectionType() const; |
64 | 65 |
66 // Calls RecomputeCurrentConnectionTypeImpl on the DNS thread and runs | |
67 // |reply_callback| with the type on the calling thread. | |
68 virtual void RecomputeCurrentConnectionTypeOnDnsThread( | |
69 base::Callback<void(ConnectionType)> reply_callback) const; | |
pauljensen
2017/05/26 18:29:40
Instead of having every caller assemble the Callba
jkarlin
2017/05/26 19:03:58
Passing callbacks is more general however. I'd rat
| |
70 | |
65 void SetCurrentConnectionType(ConnectionType connection_type); | 71 void SetCurrentConnectionType(ConnectionType connection_type); |
66 | 72 |
67 // Notifies IP address change observers of a change immediately, and notifies | 73 // Notifies IP address change observers of a change immediately, and notifies |
68 // network state change observers on a delay. Must only be called on the | 74 // network state change observers on a delay. Must only be called on the |
69 // thread |this| was created on. | 75 // thread |this| was created on. |
70 void NotifyObservers(); | 76 void NotifyObservers(ConnectionType connection_type); |
71 | 77 |
72 // Forwards connection type notifications to parent class. | 78 // Forwards connection type notifications to parent class. |
73 void NotifyParentOfConnectionTypeChange(); | 79 void NotifyParentOfConnectionTypeChange(); |
80 void NotifyParentOfConnectionTypeChangeImpl(ConnectionType connection_type); | |
74 | 81 |
75 // Tries to start listening for a single subsequent address change. Returns | 82 // Tries to start listening for a single subsequent address change. Returns |
76 // false on failure. The caller is responsible for updating |is_watching_|. | 83 // false on failure. The caller is responsible for updating |is_watching_|. |
77 // Virtual for unit tests. Must only be called on the thread |this| was | 84 // Virtual for unit tests. Must only be called on the thread |this| was |
78 // created on. | 85 // created on. |
79 virtual bool WatchForAddressChangeInternal(); | 86 virtual bool WatchForAddressChangeInternal(); |
80 | 87 |
81 static NetworkChangeCalculatorParams NetworkChangeCalculatorParamsWin(); | 88 static NetworkChangeCalculatorParams NetworkChangeCalculatorParamsWin(); |
82 | 89 |
83 // All member variables may only be accessed on the thread |this| was created | 90 // All member variables may only be accessed on the thread |this| was created |
(...skipping 26 matching lines...) Expand all Loading... | |
110 | 117 |
111 // Used for calling WatchForAddressChange again on failure. | 118 // Used for calling WatchForAddressChange again on failure. |
112 base::WeakPtrFactory<NetworkChangeNotifierWin> weak_factory_; | 119 base::WeakPtrFactory<NetworkChangeNotifierWin> weak_factory_; |
113 | 120 |
114 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierWin); | 121 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierWin); |
115 }; | 122 }; |
116 | 123 |
117 } // namespace net | 124 } // namespace net |
118 | 125 |
119 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_WIN_H_ | 126 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_WIN_H_ |
OLD | NEW |