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

Side by Side Diff: net/base/network_change_notifier_win.h

Issue 2910473005: Deprecate NonThreadSafe in net/ in favor of SequenceChecker/ThreadChecker. (Closed)
Patch Set: Fix chromecast compile Created 3 years, 7 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
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/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/non_thread_safe.h" 15 #include "base/sequence_checker.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "base/win/object_watcher.h" 17 #include "base/win/object_watcher.h"
18 #include "net/base/net_export.h" 18 #include "net/base/net_export.h"
19 #include "net/base/network_change_notifier.h" 19 #include "net/base/network_change_notifier.h"
20 20
21 namespace net { 21 namespace net {
22 22
23 // NetworkChangeNotifierWin inherits from NonThreadSafe, as all its internal 23 // NetworkChangeNotifierWin inherits from NonThreadSafe, as all its internal
24 // notification code must be called on the thread it is created and destroyed 24 // notification code must be called on the thread it is created and destroyed
25 // on. All the NetworkChangeNotifier methods it implements are threadsafe. 25 // on. All the NetworkChangeNotifier methods it implements are threadsafe.
26 class NET_EXPORT_PRIVATE NetworkChangeNotifierWin 26 class NET_EXPORT_PRIVATE NetworkChangeNotifierWin
27 : public NetworkChangeNotifier, 27 : public NetworkChangeNotifier,
28 public base::win::ObjectWatcher::Delegate, 28 public base::win::ObjectWatcher::Delegate {
29 NON_EXPORTED_BASE(public base::NonThreadSafe) {
30 public: 29 public:
31 NetworkChangeNotifierWin(); 30 NetworkChangeNotifierWin();
32 31
33 // Begins listening for a single subsequent address change. If it fails to 32 // Begins listening for a single subsequent address change. If it fails to
34 // start watching, it retries on a timer. Must be called only once, on the 33 // start watching, it retries on a timer. Must be called only once, on the
35 // thread |this| was created on. This cannot be called in the constructor, as 34 // thread |this| was created on. This cannot be called in the constructor, as
36 // WatchForAddressChangeInternal is mocked out in unit tests. 35 // WatchForAddressChangeInternal is mocked out in unit tests.
37 // TODO(mmenke): Consider making this function a part of the 36 // TODO(mmenke): Consider making this function a part of the
38 // NetworkChangeNotifier interface, so other subclasses can be 37 // NetworkChangeNotifier interface, so other subclasses can be
39 // unit tested in similar fashion, as needed. 38 // unit tested in similar fashion, as needed.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 100
102 mutable base::Lock last_computed_connection_type_lock_; 101 mutable base::Lock last_computed_connection_type_lock_;
103 ConnectionType last_computed_connection_type_; 102 ConnectionType last_computed_connection_type_;
104 103
105 // Result of IsOffline() when NotifyObserversOfConnectionTypeChange() 104 // Result of IsOffline() when NotifyObserversOfConnectionTypeChange()
106 // was last called. 105 // was last called.
107 bool last_announced_offline_; 106 bool last_announced_offline_;
108 // Number of times polled to check if still offline. 107 // Number of times polled to check if still offline.
109 int offline_polls_; 108 int offline_polls_;
110 109
110 SEQUENCE_CHECKER(sequence_checker_);
111
111 // Used for calling WatchForAddressChange again on failure. 112 // Used for calling WatchForAddressChange again on failure.
112 base::WeakPtrFactory<NetworkChangeNotifierWin> weak_factory_; 113 base::WeakPtrFactory<NetworkChangeNotifierWin> weak_factory_;
113 114
114 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierWin); 115 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierWin);
115 }; 116 };
116 117
117 } // namespace net 118 } // namespace net
118 119
119 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_WIN_H_ 120 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698