| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 friend class base::RefCountedThreadSafe<PlatformDelegate>; | 87 friend class base::RefCountedThreadSafe<PlatformDelegate>; |
| 88 | 88 |
| 89 scoped_refptr<base::MessageLoopProxy> message_loop_; | 89 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 90 bool cancelled_; | 90 bool cancelled_; |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 FilePathWatcher(); | 93 FilePathWatcher(); |
| 94 ~FilePathWatcher(); | 94 virtual ~FilePathWatcher(); |
| 95 | 95 |
| 96 // A callback that always cleans up the PlatformDelegate, either when executed | 96 // A callback that always cleans up the PlatformDelegate, either when executed |
| 97 // or when deleted without having been executed at all, as can happen during | 97 // or when deleted without having been executed at all, as can happen during |
| 98 // shutdown. | 98 // shutdown. |
| 99 static void CancelWatch(const scoped_refptr<PlatformDelegate>& delegate); | 99 static void CancelWatch(const scoped_refptr<PlatformDelegate>& delegate); |
| 100 | 100 |
| 101 // Register interest in any changes on |path|. OnPathChanged will be called | 101 // Register interest in any changes on |path|. OnPathChanged will be called |
| 102 // back for each change. Returns true on success. | 102 // back for each change. Returns true on success. |
| 103 // OnFilePathChanged() will be called on the same thread as Watch() is called, | 103 // OnFilePathChanged() will be called on the same thread as Watch() is called, |
| 104 // which should have a MessageLoop of TYPE_IO. | 104 // which should have a MessageLoop of TYPE_IO. |
| 105 bool Watch(const FilePath& path, Delegate* delegate) WARN_UNUSED_RESULT; | 105 virtual bool Watch(const FilePath& path, Delegate* delegate) |
| 106 WARN_UNUSED_RESULT; |
| 106 | 107 |
| 107 private: | 108 private: |
| 108 scoped_refptr<PlatformDelegate> impl_; | 109 scoped_refptr<PlatformDelegate> impl_; |
| 109 | 110 |
| 110 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); | 111 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); |
| 111 }; | 112 }; |
| 112 | 113 |
| 113 } // namespace files | 114 } // namespace files |
| 114 } // namespace base | 115 } // namespace base |
| 115 | 116 |
| 116 #endif // BASE_FILES_FILE_PATH_WATCHER_H_ | 117 #endif // BASE_FILES_FILE_PATH_WATCHER_H_ |
| OLD | NEW |