| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 scoped_refptr<NotificationCollector> collector_; | 208 scoped_refptr<NotificationCollector> collector_; |
| 209 | 209 |
| 210 private: | 210 private: |
| 211 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherTest); | 211 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherTest); |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 bool FilePathWatcherTest::SetupWatch(const FilePath& target, | 214 bool FilePathWatcherTest::SetupWatch(const FilePath& target, |
| 215 FilePathWatcher* watcher, | 215 FilePathWatcher* watcher, |
| 216 TestDelegateBase* delegate, | 216 TestDelegateBase* delegate, |
| 217 bool recursive_watch) { | 217 bool recursive_watch) { |
| 218 base::WaitableEvent completion(false, false); | 218 base::WaitableEvent completion(WaitableEvent::ResetPolicy::AUTOMATIC, |
| 219 WaitableEvent::InitialState::NOT_SIGNALED); |
| 219 bool result; | 220 bool result; |
| 220 file_thread_.task_runner()->PostTask( | 221 file_thread_.task_runner()->PostTask( |
| 221 FROM_HERE, base::Bind(SetupWatchCallback, target, watcher, delegate, | 222 FROM_HERE, base::Bind(SetupWatchCallback, target, watcher, delegate, |
| 222 recursive_watch, &result, &completion)); | 223 recursive_watch, &result, &completion)); |
| 223 completion.Wait(); | 224 completion.Wait(); |
| 224 return result; | 225 return result; |
| 225 } | 226 } |
| 226 | 227 |
| 227 // Basic test: Create the file and verify that we notice. | 228 // Basic test: Create the file and verify that we notice. |
| 228 TEST_F(FilePathWatcherTest, NewFile) { | 229 TEST_F(FilePathWatcherTest, NewFile) { |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); | 901 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); |
| 901 ASSERT_TRUE(WaitForEvents()); | 902 ASSERT_TRUE(WaitForEvents()); |
| 902 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); | 903 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); |
| 903 DeleteDelegateOnFileThread(delegate.release()); | 904 DeleteDelegateOnFileThread(delegate.release()); |
| 904 } | 905 } |
| 905 | 906 |
| 906 #endif // OS_MACOSX | 907 #endif // OS_MACOSX |
| 907 } // namespace | 908 } // namespace |
| 908 | 909 |
| 909 } // namespace base | 910 } // namespace base |
| OLD | NEW |