OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 for changes. | 5 // This module provides a way to monitor a file for changes. |
6 | 6 |
7 #ifndef CHROME_BROWSER_FILE_WATCHER_H_ | 7 #ifndef CHROME_BROWSER_FILE_WATCHER_H_ |
8 #define CHROME_BROWSER_FILE_WATCHER_H_ | 8 #define CHROME_BROWSER_FILE_WATCHER_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
13 #include "chrome/browser/chrome_thread.h" | 13 #include "chrome/browser/chrome_thread.h" |
14 | 14 |
15 class FilePath; | 15 class FilePath; |
| 16 |
16 // This class lets you register interest in changes on a file. The delegate | 17 // This class lets you register interest in changes on a file. The delegate |
17 // will get called whenever the file is changed, including created or deleted. | 18 // will get called whenever the file is changed, including created or deleted. |
18 // WARNING: To be able to get create/delete notifications and to work cross | 19 // WARNING: To be able to get create/delete notifications and to work cross |
19 // platform, we actually listen for changes to the directory containing | 20 // platform, we actually listen for changes to the directory containing |
20 // the file. | 21 // the file. |
21 // WARNING: On OSX and Windows, the OS API doesn't tell us which file in the | 22 // WARNING: On OSX and Windows, the OS API doesn't tell us which file in the |
22 // directory changed. We work around this by watching the file time, but this | 23 // directory changed. We work around this by watching the file time, but this |
23 // can result in some extra notifications if we get other notifications within | 24 // can result in some extra notifications if we get other notifications within |
24 // 2s of the file having changed. | 25 // 2s of the file having changed. |
25 class FileWatcher { | 26 class FileWatcher { |
(...skipping 27 matching lines...) Expand all Loading... |
53 virtual bool Watch(const FilePath& path, Delegate* delegate) = 0; | 54 virtual bool Watch(const FilePath& path, Delegate* delegate) = 0; |
54 }; | 55 }; |
55 | 56 |
56 private: | 57 private: |
57 scoped_refptr<PlatformDelegate> impl_; | 58 scoped_refptr<PlatformDelegate> impl_; |
58 | 59 |
59 DISALLOW_COPY_AND_ASSIGN(FileWatcher); | 60 DISALLOW_COPY_AND_ASSIGN(FileWatcher); |
60 }; | 61 }; |
61 | 62 |
62 #endif // CHROME_BROWSER_FILE_WATCHER_H_ | 63 #endif // CHROME_BROWSER_FILE_WATCHER_H_ |
OLD | NEW |