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

Unified Diff: base/files/file_path_watcher.h

Issue 8677015: base::Bind: Convert FilePathWatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | « no previous file | base/files/file_path_watcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_path_watcher.h
diff --git a/base/files/file_path_watcher.h b/base/files/file_path_watcher.h
index ed174642b531c7e5300905850f9d10b7180623ab..b003ccb6b7434e4cdb55cd0384249d641874654d 100644
--- a/base/files/file_path_watcher.h
+++ b/base/files/file_path_watcher.h
@@ -40,37 +40,9 @@ class BASE_EXPORT FilePathWatcher {
virtual void OnFilePathError(const FilePath& path) {}
};
- FilePathWatcher();
- ~FilePathWatcher();
-
- // Register interest in any changes on |path|. OnPathChanged will be called
- // back for each change. Returns true on success.
- // OnFilePathChanged() will be called on the same thread as Watch() is called,
- // which should have a MessageLoop of TYPE_IO.
- bool Watch(const FilePath& path, Delegate* delegate) WARN_UNUSED_RESULT;
-
- class PlatformDelegate;
-
- // A custom Task that always cleans up the PlatformDelegate, either when
- // executed or when deleted without having been executed at all, as can
- // happen during shutdown.
- class CancelTask : public Task {
- public:
- CancelTask(PlatformDelegate* delegate): delegate_(delegate) {}
- virtual ~CancelTask() {
- delegate_->CancelOnMessageLoopThread();
- }
-
- virtual void Run() OVERRIDE {
- delegate_->CancelOnMessageLoopThread();
- }
- private:
- scoped_refptr<PlatformDelegate> delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(CancelTask);
- };
-
// Used internally to encapsulate different members on different platforms.
+ // TODO(jhawkins): Move this into its own file. Also fix the confusing naming
+ // wrt Delegate vs PlatformDelegate.
class PlatformDelegate : public base::RefCountedThreadSafe<PlatformDelegate> {
public:
PlatformDelegate();
@@ -85,6 +57,8 @@ class BASE_EXPORT FilePathWatcher {
virtual void Cancel() = 0;
protected:
+ friend class FilePathWatcher;
+
virtual ~PlatformDelegate();
// Stop watching. This is only called on the thread of the appropriate
@@ -111,12 +85,25 @@ class BASE_EXPORT FilePathWatcher {
private:
friend class base::RefCountedThreadSafe<PlatformDelegate>;
- friend class CancelTask;
scoped_refptr<base::MessageLoopProxy> message_loop_;
bool cancelled_;
};
+ // A callback that always cleans up the PlatformDelegate, either when executed
+ // or when deleted without having been executed at all, as can happen during
+ // shutdown.
+ static void CancelWatch(const scoped_refptr<PlatformDelegate>& delegate);
willchan no longer on Chromium 2011/11/23 19:54:13 This should come after the constructor/destructor
+
+ FilePathWatcher();
+ ~FilePathWatcher();
+
+ // Register interest in any changes on |path|. OnPathChanged will be called
+ // back for each change. Returns true on success.
+ // OnFilePathChanged() will be called on the same thread as Watch() is called,
+ // which should have a MessageLoop of TYPE_IO.
+ bool Watch(const FilePath& path, Delegate* delegate) WARN_UNUSED_RESULT;
+
private:
scoped_refptr<PlatformDelegate> impl_;
« no previous file with comments | « no previous file | base/files/file_path_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698