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

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

Issue 8427007: Thread::Stop() must be called before any subclass's destructor completes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest version as trybot-ted Created 9 years, 1 month 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 | « dbus/test_service.cc ('k') | tools/valgrind/tsan/suppressions.txt » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "net/base/network_change_notifier_linux.h" 5 #include "net/base/network_change_notifier_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/socket.h> 8 #include <sys/socket.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 DISALLOW_COPY_AND_ASSIGN(Thread); 99 DISALLOW_COPY_AND_ASSIGN(Thread);
100 }; 100 };
101 101
102 NetworkChangeNotifierLinux::Thread::Thread() 102 NetworkChangeNotifierLinux::Thread::Thread()
103 : base::Thread("NetworkChangeNotifier"), 103 : base::Thread("NetworkChangeNotifier"),
104 netlink_fd_(kInvalidSocket), 104 netlink_fd_(kInvalidSocket),
105 ALLOW_THIS_IN_INITIALIZER_LIST(ptr_factory_(this)) { 105 ALLOW_THIS_IN_INITIALIZER_LIST(ptr_factory_(this)) {
106 } 106 }
107 107
108 NetworkChangeNotifierLinux::Thread::~Thread() {} 108 NetworkChangeNotifierLinux::Thread::~Thread() {
109 DCHECK(!Thread::IsRunning());
110 }
109 111
110 void NetworkChangeNotifierLinux::Thread::Init() { 112 void NetworkChangeNotifierLinux::Thread::Init() {
111 resolv_file_watcher_.reset(new FilePathWatcher); 113 resolv_file_watcher_.reset(new FilePathWatcher);
112 hosts_file_watcher_.reset(new FilePathWatcher); 114 hosts_file_watcher_.reset(new FilePathWatcher);
113 file_watcher_delegate_ = new DNSWatchDelegate(base::Bind( 115 file_watcher_delegate_ = new DNSWatchDelegate(base::Bind(
114 &NetworkChangeNotifierLinux::Thread::NotifyObserversOfDNSChange, 116 &NetworkChangeNotifierLinux::Thread::NotifyObserversOfDNSChange,
115 base::Unretained(this))); 117 base::Unretained(this)));
116 if (!resolv_file_watcher_->Watch( 118 if (!resolv_file_watcher_->Watch(
117 FilePath(FILE_PATH_LITERAL("/etc/resolv.conf")), 119 FilePath(FILE_PATH_LITERAL("/etc/resolv.conf")),
118 file_watcher_delegate_.get())) { 120 file_watcher_delegate_.get())) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 NetworkChangeNotifierLinux::NetworkChangeNotifierLinux() 209 NetworkChangeNotifierLinux::NetworkChangeNotifierLinux()
208 : notifier_thread_(new Thread) { 210 : notifier_thread_(new Thread) {
209 // We create this notifier thread because the notification implementation 211 // We create this notifier thread because the notification implementation
210 // needs a MessageLoopForIO, and there's no guarantee that 212 // needs a MessageLoopForIO, and there's no guarantee that
211 // MessageLoop::current() meets that criterion. 213 // MessageLoop::current() meets that criterion.
212 base::Thread::Options thread_options(MessageLoop::TYPE_IO, 0); 214 base::Thread::Options thread_options(MessageLoop::TYPE_IO, 0);
213 notifier_thread_->StartWithOptions(thread_options); 215 notifier_thread_->StartWithOptions(thread_options);
214 } 216 }
215 217
216 NetworkChangeNotifierLinux::~NetworkChangeNotifierLinux() { 218 NetworkChangeNotifierLinux::~NetworkChangeNotifierLinux() {
217 // We don't need to explicitly Stop(), but doing so allows us to sanity- 219 // Stopping from here allows us to sanity- check that the notifier
218 // check that the notifier thread shut down properly. 220 // thread shut down properly.
219 notifier_thread_->Stop(); 221 notifier_thread_->Stop();
220 } 222 }
221 223
222 bool NetworkChangeNotifierLinux::IsCurrentlyOffline() const { 224 bool NetworkChangeNotifierLinux::IsCurrentlyOffline() const {
223 // TODO(eroman): http://crbug.com/53473 225 // TODO(eroman): http://crbug.com/53473
224 return false; 226 return false;
225 } 227 }
226 228
227 } // namespace net 229 } // namespace net
OLDNEW
« no previous file with comments | « dbus/test_service.cc ('k') | tools/valgrind/tsan/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698