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

Unified Diff: chrome/browser/file_watcher.h

Issue 864001: Move FileWatcher from src/base/ to src/chrome/browser/ and switch (Closed)
Patch Set: fix tests on mac Created 10 years, 9 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 | « base/base.gypi ('k') | chrome/browser/file_watcher_inotify.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « base/base.gypi ('k') | chrome/browser/file_watcher_inotify.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698