Index: chrome/browser/file_watcher.h |
diff --git a/base/file_watcher.h b/chrome/browser/file_watcher.h |
similarity index 65% |
rename from base/file_watcher.h |
rename to chrome/browser/file_watcher.h |
index 1147d42a29c3625087359e83eb2b2bcb6a88ef2f..397feb197f95316fae36b1b602b91c2eca8cfb71 100644 |
--- a/base/file_watcher.h |
+++ b/chrome/browser/file_watcher.h |
@@ -4,15 +4,14 @@ |
// This module provides a way to monitor a file for changes. |
-#ifndef BASE_FILE_WATCHER_H_ |
-#define BASE_FILE_WATCHER_H_ |
+#ifndef CHROME_BROWSER_FILE_WATCHER_H_ |
+#define CHROME_BROWSER_FILE_WATCHER_H_ |
#include "base/basictypes.h" |
#include "base/ref_counted.h" |
+#include "chrome/browser/chrome_thread.h" |
class FilePath; |
-class MessageLoop; |
- |
// This class lets you register interest in changes on a file. The delegate |
// will get called whenever the file is changed, including created or deleted. |
// WARNING: To be able to get create/delete notifications and to work cross |
@@ -34,26 +33,23 @@ class FileWatcher { |
~FileWatcher() {} |
// Register interest in any changes on the file |path|. |
- // OnFileChanged will be called back for each change to the file. |
- // Any background operations will be ran on |backend_loop|, or inside Watch |
- // if |backend_loop| is NULL. Note: The directory containing |path| must |
- // exist before you try to watch the file. |
- // Returns false on error. |
- bool Watch(const FilePath& path, Delegate* delegate, |
- MessageLoop* backend_loop) { |
- return impl_->Watch(path, delegate, backend_loop); |
+ // OnFileChanged will be called back for each change to the file. Any |
+ // background operations will be ran on |backend_thread_id|. Note: The |
+ // directory containing |path| must exist before you try to watch the file. |
+ // Returns false if the watch can't be added. |
+ bool Watch(const FilePath& path, Delegate* delegate) { |
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); |
+ return impl_->Watch(path, delegate); |
} |
// Used internally to encapsulate different members on different platforms. |
- class PlatformDelegate : public base::RefCounted<PlatformDelegate> { |
+ class PlatformDelegate |
+ : public base::RefCountedThreadSafe<PlatformDelegate, |
+ ChromeThread::DeleteOnFileThread> { |
public: |
- virtual bool Watch(const FilePath& path, Delegate* delegate, |
- MessageLoop* backend_loop) = 0; |
- |
- protected: |
- friend class base::RefCounted<PlatformDelegate>; |
- |
virtual ~PlatformDelegate() {} |
+ |
+ virtual bool Watch(const FilePath& path, Delegate* delegate) = 0; |
}; |
private: |
@@ -62,4 +58,4 @@ class FileWatcher { |
DISALLOW_COPY_AND_ASSIGN(FileWatcher); |
}; |
-#endif // BASE_FILE_WATCHER_H_ |
+#endif // CHROME_BROWSER_FILE_WATCHER_H_ |