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

Side by Side Diff: base/files/file_path_watcher.h

Issue 11415066: FilePathWatcher::Watch() - Listen for sub directory changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac compile error. Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This module provides a way to monitor a file or directory for changes. 5 // This module provides a way to monitor a file or directory for changes.
6 6
7 #ifndef BASE_FILES_FILE_PATH_WATCHER_H_ 7 #ifndef BASE_FILES_FILE_PATH_WATCHER_H_
8 #define BASE_FILES_FILE_PATH_WATCHER_H_ 8 #define BASE_FILES_FILE_PATH_WATCHER_H_
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 // Used internally to encapsulate different members on different platforms. 53 // Used internally to encapsulate different members on different platforms.
54 // TODO(jhawkins): Move this into its own file. Also fix the confusing naming 54 // TODO(jhawkins): Move this into its own file. Also fix the confusing naming
55 // wrt Delegate vs PlatformDelegate. 55 // wrt Delegate vs PlatformDelegate.
56 class PlatformDelegate : public base::RefCountedThreadSafe<PlatformDelegate> { 56 class PlatformDelegate : public base::RefCountedThreadSafe<PlatformDelegate> {
57 public: 57 public:
58 PlatformDelegate(); 58 PlatformDelegate();
59 59
60 // Start watching for the given |path| and notify |delegate| about changes. 60 // Start watching for the given |path| and notify |delegate| about changes.
61 virtual bool Watch(const FilePath& path, 61 virtual bool Watch(const FilePath& path,
62 bool recursive,
62 Delegate* delegate) WARN_UNUSED_RESULT = 0; 63 Delegate* delegate) WARN_UNUSED_RESULT = 0;
63 64
64 // Stop watching. This is called from FilePathWatcher's dtor in order to 65 // Stop watching. This is called from FilePathWatcher's dtor in order to
65 // allow to shut down properly while the object is still alive. 66 // allow to shut down properly while the object is still alive.
66 // It can be called from any thread. 67 // It can be called from any thread.
67 virtual void Cancel() = 0; 68 virtual void Cancel() = 0;
68 69
69 protected: 70 protected:
70 friend class base::RefCountedThreadSafe<PlatformDelegate>; 71 friend class base::RefCountedThreadSafe<PlatformDelegate>;
71 friend class FilePathWatcher; 72 friend class FilePathWatcher;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 static void CancelWatch(const scoped_refptr<PlatformDelegate>& delegate); 109 static void CancelWatch(const scoped_refptr<PlatformDelegate>& delegate);
109 110
110 // Register interest in any changes on |path|. OnPathChanged will be called 111 // Register interest in any changes on |path|. OnPathChanged will be called
111 // back for each change. Returns true on success. 112 // back for each change. Returns true on success.
112 // OnFilePathChanged() will be called on the same thread as Watch() is called, 113 // OnFilePathChanged() will be called on the same thread as Watch() is called,
113 // which should have a MessageLoop of TYPE_IO. 114 // which should have a MessageLoop of TYPE_IO.
114 // 115 //
115 // Deprecated: new code should use the callback interface, declared below. 116 // Deprecated: new code should use the callback interface, declared below.
116 // The FilePathWatcher::Delegate interface will be removed once all client 117 // The FilePathWatcher::Delegate interface will be removed once all client
117 // code has been updated. http://crbug.com/130980 118 // code has been updated. http://crbug.com/130980
118 virtual bool Watch(const FilePath& path, Delegate* delegate) 119 virtual bool Watch(const FilePath& path, bool recursive, Delegate* delegate)
Lei Zhang 2012/11/21 03:36:49 Do we need this? I don't think anyone will write n
kmadhusu 2012/11/21 04:13:26 bool Watch(const FilePath& path, bool recursive, c
Lei Zhang 2012/11/21 04:21:02 Maybe it's time to make the new Watch() method cal
kmadhusu 2012/11/22 01:39:41 Done.
119 WARN_UNUSED_RESULT; 120 WARN_UNUSED_RESULT;
120 121
121 // Invokes |callback| whenever updates to |path| are detected. This should be 122 // Invokes |callback| whenever updates to |path| are detected. This should be
122 // called at most once, and from a MessageLoop of TYPE_IO. The callback will 123 // called at most once, and from a MessageLoop of TYPE_IO. Set |recursive| to
Lei Zhang 2012/11/21 03:36:49 "Set |recursive| to true to watch the |path| and i
kmadhusu 2012/11/21 04:13:26 Done.
124 // true, to watch the sub trees of the specified |path|. The callback will
123 // be invoked on the same loop. Returns true on success. 125 // be invoked on the same loop. Returns true on success.
124 bool Watch(const FilePath& path, const Callback& callback); 126 bool Watch(const FilePath& path, bool recursive, const Callback& callback);
125 127
126 private: 128 private:
127 scoped_refptr<PlatformDelegate> impl_; 129 scoped_refptr<PlatformDelegate> impl_;
128 130
129 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); 131 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher);
130 }; 132 };
131 133
132 } // namespace files 134 } // namespace files
133 } // namespace base 135 } // namespace base
134 136
135 #endif // BASE_FILES_FILE_PATH_WATCHER_H_ 137 #endif // BASE_FILES_FILE_PATH_WATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | base/files/file_path_watcher.cc » ('j') | base/files/file_path_watcher_browsertest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698