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

Unified Diff: base/files/file_path_watcher.h

Issue 10519003: Added a base::Callback interface to FilePathWatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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
« no previous file with comments | « PRESUBMIT.py ('k') | 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 3795c9ed32d76c4618b611c09d3ad0f4866ff879..59199944e16a5c1060bc0eb0f14443bb7cb25722 100644
--- a/base/files/file_path_watcher.h
+++ b/base/files/file_path_watcher.h
@@ -10,6 +10,7 @@
#include "base/base_export.h"
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop_proxy.h"
@@ -28,9 +29,16 @@ namespace files {
// details.
class BASE_EXPORT FilePathWatcher {
public:
+ // Callback type for Watch(). |path| points to the file that was updated,
+ // and |error| is true if the platform specific code detected an error. In
+ // that case, the callback won't be invoked again.
+ typedef base::Callback<void(const FilePath& path, bool error)> Callback;
+
// Declares the callback client code implements to receive notifications. Note
// that implementations of this interface should not keep a reference to the
// corresponding FileWatcher object to prevent a reference cycle.
+ //
+ // Deprecated: see comment on Watch() below.
class Delegate : public base::RefCountedThreadSafe<Delegate> {
public:
virtual void OnFilePathChanged(const FilePath& path) = 0;
@@ -104,9 +112,18 @@ class BASE_EXPORT FilePathWatcher {
// 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.
+ //
+ // Deprecated: new code should use the callback interface, declared below.
+ // The FilePathWatcher::Delegate interface will be removed once all client
+ // code has been updated. http://crbug.com/130980
virtual bool Watch(const FilePath& path, Delegate* delegate)
WARN_UNUSED_RESULT;
+ // Invokes |callback| whenever updates to |path| are detected. This should be
+ // called at most once, and from a MessageLoop of TYPE_IO. The callback will
+ // be invoked on the same loop. Returns true on success.
+ bool Watch(const FilePath& path, const Callback& callback);
+
private:
scoped_refptr<PlatformDelegate> impl_;
« no previous file with comments | « PRESUBMIT.py ('k') | base/files/file_path_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698