Index: base/files/file_path_watcher_linux.cc |
diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc |
index 0fb10e4590e448dadb90f23e5492e153efce0297..96350e95124de1d1e6a33be7256dc6031f6fc298 100644 |
--- a/base/files/file_path_watcher_linux.cc |
+++ b/base/files/file_path_watcher_linux.cc |
@@ -404,19 +404,21 @@ void FilePathWatcherImpl::Cancel() { |
} |
void FilePathWatcherImpl::CancelOnMessageLoopThread() { |
- if (!is_cancelled()) { |
+ if (!is_cancelled()) |
set_cancelled(); |
- MessageLoop::current()->RemoveDestructionObserver(this); |
- for (WatchVector::iterator watch_entry(watches_.begin()); |
- watch_entry != watches_.end(); ++watch_entry) { |
- if (watch_entry->watch_ != InotifyReader::kInvalidWatch) |
- g_inotify_reader.Get().RemoveWatch(watch_entry->watch_, this); |
- } |
- watches_.clear(); |
+ if (delegate_) { |
+ MessageLoop::current()->RemoveDestructionObserver(this); |
delegate_ = NULL; |
- target_.clear(); |
} |
+ |
+ for (WatchVector::iterator watch_entry(watches_.begin()); |
+ watch_entry != watches_.end(); ++watch_entry) { |
+ if (watch_entry->watch_ != InotifyReader::kInvalidWatch) |
+ g_inotify_reader.Get().RemoveWatch(watch_entry->watch_, this); |
+ } |
+ watches_.clear(); |
+ target_.clear(); |
} |
void FilePathWatcherImpl::WillDestroyCurrentMessageLoop() { |