OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This module provides a way to monitor a directory for changes. |
| 6 |
| 7 #ifndef BASE_DIRECTORY_WATCHER_H_ |
| 8 #define BASE_DIRECTORY_WATCHER_H_ |
| 9 |
| 10 #include <string> |
| 11 #include "base/basictypes.h" |
| 12 #include "base/ref_counted.h" |
| 13 |
| 14 class FilePath; |
| 15 |
| 16 // This class lets you register interest in changes on a directory. |
| 17 // The delegate will get called whenever a file is added or changed in the |
| 18 // directory. |
| 19 class DirectoryWatcher { |
| 20 public: |
| 21 class Delegate { |
| 22 public: |
| 23 virtual void OnDirectoryChanged(const FilePath& path) = 0; |
| 24 }; |
| 25 |
| 26 DirectoryWatcher(); |
| 27 ~DirectoryWatcher(); |
| 28 |
| 29 // Register interest in any changes in the directory |path|. |
| 30 // OnDirectoryChanged will be called back for each change within the dir. |
| 31 // Returns false on error. |
| 32 bool Watch(const FilePath& path, Delegate* delegate); |
| 33 |
| 34 private: |
| 35 class Impl; |
| 36 friend class Impl; |
| 37 scoped_refptr<Impl> impl_; |
| 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(DirectoryWatcher); |
| 40 }; |
| 41 |
| 42 #endif // BASE_DIRECTORY_WATCHER_H_ |
OLD | NEW |