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

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: Added more test cases Created 8 years 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
« no previous file with comments | « no previous file | base/files/file_path_watcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, Delegate* delegate)
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
123 // be invoked on the same loop. Returns true on success. 124 // true, to watch |path| and its children. The callback will be invoked on
124 bool Watch(const FilePath& path, const Callback& callback); 125 // the same loop. Returns true on success.
126 //
127 // NOTE: Recursive watch is not supported on all platforms and file systems.
128 // Watch() will return false in the case of failure.
129 bool Watch(const FilePath& path, bool recursive, const Callback& callback);
125 130
126 private: 131 private:
127 scoped_refptr<PlatformDelegate> impl_; 132 scoped_refptr<PlatformDelegate> impl_;
128 133
129 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); 134 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher);
130 }; 135 };
131 136
132 } // namespace files 137 } // namespace files
133 } // namespace base 138 } // namespace base
134 139
135 #endif // BASE_FILES_FILE_PATH_WATCHER_H_ 140 #endif // BASE_FILES_FILE_PATH_WATCHER_H_
OLDNEW
« 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