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

Side by Side Diff: chrome/browser/file_watcher_mac.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 unified diff | Download patch
« no previous file with comments | « chrome/browser/file_watcher_inotify.cc ('k') | chrome/browser/file_watcher_unittest.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 #include "chrome/browser/file_watcher.h" 5 #include "chrome/browser/file_watcher.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // much rather than miss a notification. 69 // much rather than miss a notification.
70 delegate_->OnFileChanged(path_); 70 delegate_->OnFileChanged(path_);
71 } else if (!file_exists && !last_modified_.is_null()) { 71 } else if (!file_exists && !last_modified_.is_null()) {
72 last_modified_ = base::Time(); 72 last_modified_ = base::Time();
73 delegate_->OnFileChanged(path_); 73 delegate_->OnFileChanged(path_);
74 } 74 }
75 } 75 }
76 76
77 private: 77 private:
78 // Delegate to notify upon changes. 78 // Delegate to notify upon changes.
79 FileWatcher::Delegate* delegate_; 79 scoped_refptr<FileWatcher::Delegate> delegate_;
80 80
81 // Path we're watching (passed to delegate). 81 // Path we're watching (passed to delegate).
82 FilePath path_; 82 FilePath path_;
83 83
84 // Backend stream we receive event callbacks from (strong reference). 84 // Backend stream we receive event callbacks from (strong reference).
85 FSEventStreamRef fsevent_stream_; 85 FSEventStreamRef fsevent_stream_;
86 86
87 // Keep track of the last modified time of the file. We use nulltime 87 // Keep track of the last modified time of the file. We use nulltime
88 // to represent the file not existing. 88 // to represent the file not existing.
89 base::Time last_modified_; 89 base::Time last_modified_;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 FSEventStreamStart(fsevent_stream_); 148 FSEventStreamStart(fsevent_stream_);
149 149
150 return true; 150 return true;
151 } 151 }
152 152
153 } // namespace 153 } // namespace
154 154
155 FileWatcher::FileWatcher() { 155 FileWatcher::FileWatcher() {
156 impl_ = new FileWatcherImpl(); 156 impl_ = new FileWatcherImpl();
157 } 157 }
OLDNEW
« no previous file with comments | « chrome/browser/file_watcher_inotify.cc ('k') | chrome/browser/file_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698