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

Unified Diff: base/files/file_path_watcher.cc

Issue 10519003: Added a base::Callback interface to FilePathWatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
Index: base/files/file_path_watcher.cc
diff --git a/base/files/file_path_watcher.cc b/base/files/file_path_watcher.cc
index 086da1e6968c542f7b5632e47d7727d87beeb060..dd2b37fc78d80a937c00afcb803cfc784970047b 100644
--- a/base/files/file_path_watcher.cc
+++ b/base/files/file_path_watcher.cc
@@ -13,6 +13,33 @@
namespace base {
namespace files {
+namespace {
+
+// A delegate implementation for the callback interface.
+class FilePathWatcherDelegate : public base::files::FilePathWatcher::Delegate {
+ public:
+ explicit FilePathWatcherDelegate(const FilePathWatcher::Callback& callback)
+ : callback_(callback) {}
+
+ // FilePathWatcher::Delegate implementation.
+ virtual void OnFilePathChanged(const FilePath& path) OVERRIDE {
+ callback_.Run(path, false);
+ }
+
+ virtual void OnFilePathError(const FilePath& path) OVERRIDE {
+ callback_.Run(path, true);
+ }
+
+ private:
+ virtual ~FilePathWatcherDelegate() {}
+
+ FilePathWatcher::Callback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(FilePathWatcherDelegate);
+};
+
+} // namespace
+
FilePathWatcher::~FilePathWatcher() {
impl_->Cancel();
}
@@ -35,5 +62,9 @@ FilePathWatcher::PlatformDelegate::~PlatformDelegate() {
DCHECK(is_cancelled());
}
+bool FilePathWatcher::Watch(const FilePath& path, const Callback& callback) {
+ return Watch(path, new FilePathWatcherDelegate(callback));
+}
+
} // namespace files
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698