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

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

Issue 1550003: Stop watching the netlink file descriptor before the message pump is destroye... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: syn and resolve Created 10 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/network_change_notifier_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "net/base/network_change_notifier.h" 11 #include "net/base/network_change_notifier.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 class NetworkChangeNotifierLinux 15 class NetworkChangeNotifierLinux
16 : public NetworkChangeNotifier, public MessageLoopForIO::Watcher { 16 : public NetworkChangeNotifier,
17 public MessageLoopForIO::Watcher,
18 public MessageLoop::DestructionObserver {
17 public: 19 public:
18 NetworkChangeNotifierLinux(); 20 NetworkChangeNotifierLinux();
19 21
20 // NetworkChangeNotifier methods: 22 // NetworkChangeNotifier methods:
21 23
22 virtual void AddObserver(Observer* observer) { 24 virtual void AddObserver(Observer* observer) {
23 observers_.AddObserver(observer); 25 observers_.AddObserver(observer);
24 } 26 }
25 27
26 virtual void RemoveObserver(Observer* observer) { 28 virtual void RemoveObserver(Observer* observer) {
27 observers_.RemoveObserver(observer); 29 observers_.RemoveObserver(observer);
28 } 30 }
29 31
30 // MessageLoopForIO::Watcher methods: 32 // MessageLoopForIO::Watcher methods:
31 33
32 virtual void OnFileCanReadWithoutBlocking(int fd); 34 virtual void OnFileCanReadWithoutBlocking(int fd);
33 virtual void OnFileCanWriteWithoutBlocking(int /* fd */); 35 virtual void OnFileCanWriteWithoutBlocking(int /* fd */);
34 36
37 // MessageLoop::DestructionObserver methods:
38
39 virtual void WillDestroyCurrentMessageLoop();
40
35 private: 41 private:
36 virtual ~NetworkChangeNotifierLinux(); 42 virtual ~NetworkChangeNotifierLinux();
37 43
38 // Starts listening for netlink messages. Also handles the messages if there 44 // Starts listening for netlink messages. Also handles the messages if there
39 // are any available on the netlink socket. 45 // are any available on the netlink socket.
40 void ListenForNotifications(); 46 void ListenForNotifications();
41 47
42 // Attempts to read from the netlink socket into |buf| of length |len|. 48 // Attempts to read from the netlink socket into |buf| of length |len|.
43 // Returns the bytes read on synchronous success and ERR_IO_PENDING if the 49 // Returns the bytes read on synchronous success and ERR_IO_PENDING if the
44 // recv() would block. Otherwise, it returns a net error code. 50 // recv() would block. Otherwise, it returns a net error code.
45 int ReadNotificationMessage(char* buf, size_t len); 51 int ReadNotificationMessage(char* buf, size_t len);
46 52
53 // Stops watching the netlink file descriptor.
54 void StopWatching();
55
47 ObserverList<Observer, true> observers_; 56 ObserverList<Observer, true> observers_;
48 57
49 int netlink_fd_; // This is the netlink socket descriptor. 58 int netlink_fd_; // This is the netlink socket descriptor.
50 MessageLoopForIO* const loop_; 59 MessageLoopForIO* loop_;
51 MessageLoopForIO::FileDescriptorWatcher netlink_watcher_; 60 MessageLoopForIO::FileDescriptorWatcher netlink_watcher_;
52 61
53 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierLinux); 62 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierLinux);
54 }; 63 };
55 64
56 } // namespace net 65 } // namespace net
57 66
58 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_ 67 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_LINUX_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/network_change_notifier_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698