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

Unified Diff: chrome/browser/file_watcher_inotify.cc

Issue 2868114: Rework FileWatcher to avoid race condition upon deletion. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Add missing return... Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/file_watcher.h ('k') | chrome/browser/file_watcher_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/file_watcher_inotify.cc
diff --git a/chrome/browser/file_watcher_inotify.cc b/chrome/browser/file_watcher_inotify.cc
index c65140815398e7993dd51cae32bdb15ad4d0ec0a..20321d5cf1fc81867542bacc37ad4528e7923d58 100644
--- a/chrome/browser/file_watcher_inotify.cc
+++ b/chrome/browser/file_watcher_inotify.cc
@@ -93,7 +93,7 @@ class FileWatcherImpl : public FileWatcher::PlatformDelegate {
private:
// Delegate to notify upon changes.
- FileWatcher::Delegate* delegate_;
+ scoped_refptr<FileWatcher::Delegate> delegate_;
// Watch returned by InotifyReader.
InotifyReader::Watch watch_;
@@ -104,24 +104,6 @@ class FileWatcherImpl : public FileWatcher::PlatformDelegate {
DISALLOW_COPY_AND_ASSIGN(FileWatcherImpl);
};
-class FileWatcherImplNotifyTask : public Task {
- public:
- FileWatcherImplNotifyTask(FileWatcher::Delegate* delegate,
- const FilePath& path)
- : delegate_(delegate), path_(path) {
- }
-
- virtual void Run() {
- delegate_->OnFileChanged(path_);
- }
-
- private:
- FileWatcher::Delegate* delegate_;
- FilePath path_;
-
- DISALLOW_COPY_AND_ASSIGN(FileWatcherImplNotifyTask);
-};
-
class InotifyReaderTask : public Task {
public:
InotifyReaderTask(InotifyReader* reader, int inotify_fd, int shutdown_fd)
@@ -293,7 +275,8 @@ void FileWatcherImpl::OnInotifyEvent(const inotify_event* event) {
return;
ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE,
- new FileWatcherImplNotifyTask(delegate_, path_));
+ NewRunnableMethod(delegate_.get(), &FileWatcher::Delegate::OnFileChanged,
+ path_));
}
bool FileWatcherImpl::Watch(const FilePath& path,
« no previous file with comments | « chrome/browser/file_watcher.h ('k') | chrome/browser/file_watcher_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698