| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 directory for changes. | 5 // This module provides a way to monitor a directory for changes. |
| 6 | 6 |
| 7 #ifndef BASE_DIRECTORY_WATCHER_H_ | 7 #ifndef BASE_DIRECTORY_WATCHER_H_ |
| 8 #define BASE_DIRECTORY_WATCHER_H_ | 8 #define BASE_DIRECTORY_WATCHER_H_ |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 virtual void OnDirectoryChanged(const FilePath& path) = 0; | 22 virtual void OnDirectoryChanged(const FilePath& path) = 0; |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 DirectoryWatcher(); | 25 DirectoryWatcher(); |
| 26 ~DirectoryWatcher() {} | 26 ~DirectoryWatcher() {} |
| 27 | 27 |
| 28 // Register interest in any changes in the directory |path|. | 28 // Register interest in any changes in the directory |path|. |
| 29 // OnDirectoryChanged will be called back for each change within the dir. | 29 // OnDirectoryChanged will be called back for each change within the dir. |
| 30 // If |recursive| is true, the delegate will be notified for each change | 30 // If |recursive| is true, the delegate will be notified for each change |
| 31 // within the directory tree starting at |path|. Returns false on error. | 31 // within the directory tree starting at |path|. Returns false on error. |
| 32 // |
| 33 // Note: on Windows the non-recursive watch will also send a notification |
| 34 // when you create a file in a subdirectory (but won't send notifications |
| 35 // for further modifications). |
| 32 bool Watch(const FilePath& path, Delegate* delegate, bool recursive) { | 36 bool Watch(const FilePath& path, Delegate* delegate, bool recursive) { |
| 33 return impl_->Watch(path, delegate, recursive); | 37 return impl_->Watch(path, delegate, recursive); |
| 34 } | 38 } |
| 35 | 39 |
| 36 // Used internally to encapsulate different members on different platforms. | 40 // Used internally to encapsulate different members on different platforms. |
| 37 class PlatformDelegate : public base::RefCounted<PlatformDelegate> { | 41 class PlatformDelegate : public base::RefCounted<PlatformDelegate> { |
| 38 public: | 42 public: |
| 39 virtual ~PlatformDelegate() {} | 43 virtual ~PlatformDelegate() {} |
| 40 virtual bool Watch(const FilePath& path, Delegate* delegate, | 44 virtual bool Watch(const FilePath& path, Delegate* delegate, |
| 41 bool recursive) = 0; | 45 bool recursive) = 0; |
| 42 }; | 46 }; |
| 43 | 47 |
| 44 private: | 48 private: |
| 45 scoped_refptr<PlatformDelegate> impl_; | 49 scoped_refptr<PlatformDelegate> impl_; |
| 46 | 50 |
| 47 DISALLOW_COPY_AND_ASSIGN(DirectoryWatcher); | 51 DISALLOW_COPY_AND_ASSIGN(DirectoryWatcher); |
| 48 }; | 52 }; |
| 49 | 53 |
| 50 #endif // BASE_DIRECTORY_WATCHER_H_ | 54 #endif // BASE_DIRECTORY_WATCHER_H_ |
| OLD | NEW |