OLD | NEW |
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 #pragma once | 9 #pragma once |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 // detect the creation and deletion of files in a watched directory, but will | 26 // detect the creation and deletion of files in a watched directory, but will |
27 // not detect modifications to those files. See file_path_watcher_mac.cc for | 27 // not detect modifications to those files. See file_path_watcher_mac.cc for |
28 // details. | 28 // details. |
29 class BASE_EXPORT FilePathWatcher { | 29 class BASE_EXPORT FilePathWatcher { |
30 public: | 30 public: |
31 // Declares the callback client code implements to receive notifications. Note | 31 // Declares the callback client code implements to receive notifications. Note |
32 // that implementations of this interface should not keep a reference to the | 32 // that implementations of this interface should not keep a reference to the |
33 // corresponding FileWatcher object to prevent a reference cycle. | 33 // corresponding FileWatcher object to prevent a reference cycle. |
34 class Delegate : public base::RefCountedThreadSafe<Delegate> { | 34 class Delegate : public base::RefCountedThreadSafe<Delegate> { |
35 public: | 35 public: |
36 virtual ~Delegate() {} | |
37 virtual void OnFilePathChanged(const FilePath& path) = 0; | 36 virtual void OnFilePathChanged(const FilePath& path) = 0; |
38 // Called when platform specific code detected an error. The watcher will | 37 // Called when platform specific code detected an error. The watcher will |
39 // not call OnFilePathChanged for future changes. | 38 // not call OnFilePathChanged for future changes. |
40 virtual void OnFilePathError(const FilePath& path) {} | 39 virtual void OnFilePathError(const FilePath& path) {} |
| 40 |
| 41 protected: |
| 42 virtual ~Delegate() {} |
| 43 |
| 44 private: |
| 45 friend class base::RefCountedThreadSafe<Delegate>; |
41 }; | 46 }; |
42 | 47 |
43 // Used internally to encapsulate different members on different platforms. | 48 // Used internally to encapsulate different members on different platforms. |
44 // TODO(jhawkins): Move this into its own file. Also fix the confusing naming | 49 // TODO(jhawkins): Move this into its own file. Also fix the confusing naming |
45 // wrt Delegate vs PlatformDelegate. | 50 // wrt Delegate vs PlatformDelegate. |
46 class PlatformDelegate : public base::RefCountedThreadSafe<PlatformDelegate> { | 51 class PlatformDelegate : public base::RefCountedThreadSafe<PlatformDelegate> { |
47 public: | 52 public: |
48 PlatformDelegate(); | 53 PlatformDelegate(); |
49 | 54 |
50 // Start watching for the given |path| and notify |delegate| about changes. | 55 // Start watching for the given |path| and notify |delegate| about changes. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 private: | 113 private: |
109 scoped_refptr<PlatformDelegate> impl_; | 114 scoped_refptr<PlatformDelegate> impl_; |
110 | 115 |
111 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); | 116 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); |
112 }; | 117 }; |
113 | 118 |
114 } // namespace files | 119 } // namespace files |
115 } // namespace base | 120 } // namespace base |
116 | 121 |
117 #endif // BASE_FILES_FILE_PATH_WATCHER_H_ | 122 #endif // BASE_FILES_FILE_PATH_WATCHER_H_ |
OLD | NEW |