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 #include "base/files/file_path_watcher.h" | 5 #include "base/files/file_path_watcher.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <aclapi.h> | 9 #include <aclapi.h> |
10 #elif defined(OS_POSIX) | 10 #elif defined(OS_POSIX) |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 return write_size == static_cast<int>(content.length()); | 189 return write_size == static_cast<int>(content.length()); |
190 } | 190 } |
191 | 191 |
192 bool SetupWatch(const FilePath& target, | 192 bool SetupWatch(const FilePath& target, |
193 FilePathWatcher* watcher, | 193 FilePathWatcher* watcher, |
194 TestDelegateBase* delegate, | 194 TestDelegateBase* delegate, |
195 bool recursive_watch) WARN_UNUSED_RESULT; | 195 bool recursive_watch) WARN_UNUSED_RESULT; |
196 | 196 |
197 bool WaitForEvents() WARN_UNUSED_RESULT { | 197 bool WaitForEvents() WARN_UNUSED_RESULT { |
198 collector_->Reset(); | 198 collector_->Reset(); |
| 199 // Make sure we timeout if we don't get notified. |
| 200 loop_.PostDelayedTask(FROM_HERE, |
| 201 MessageLoop::QuitWhenIdleClosure(), |
| 202 TestTimeouts::action_timeout()); |
199 RunLoop().Run(); | 203 RunLoop().Run(); |
200 return collector_->Success(); | 204 return collector_->Success(); |
201 } | 205 } |
202 | 206 |
203 NotificationCollector* collector() { return collector_.get(); } | 207 NotificationCollector* collector() { return collector_.get(); } |
204 | 208 |
205 MessageLoop loop_; | 209 MessageLoop loop_; |
206 base::Thread file_thread_; | 210 base::Thread file_thread_; |
207 ScopedTempDir temp_dir_; | 211 ScopedTempDir temp_dir_; |
208 scoped_refptr<NotificationCollector> collector_; | 212 scoped_refptr<NotificationCollector> collector_; |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); | 905 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); |
902 ASSERT_TRUE(WaitForEvents()); | 906 ASSERT_TRUE(WaitForEvents()); |
903 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); | 907 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); |
904 DeleteDelegateOnFileThread(delegate.release()); | 908 DeleteDelegateOnFileThread(delegate.release()); |
905 } | 909 } |
906 | 910 |
907 #endif // OS_MACOSX | 911 #endif // OS_MACOSX |
908 } // namespace | 912 } // namespace |
909 | 913 |
910 } // namespace base | 914 } // namespace base |
OLD | NEW |