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) |
11 #include <sys/stat.h> | 11 #include <sys/stat.h> |
12 #endif | 12 #endif |
13 | 13 |
14 #include <set> | 14 #include <set> |
15 | 15 |
16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/bind_helpers.h" | 18 #include "base/bind_helpers.h" |
19 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
20 #include "base/file_path.h" | 20 #include "base/file_path.h" |
21 #include "base/file_util.h" | 21 #include "base/file_util.h" |
22 #include "base/files/scoped_temp_dir.h" | 22 #include "base/files/scoped_temp_dir.h" |
23 #include "base/message_loop.h" | 23 #include "base/message_loop.h" |
24 #include "base/message_loop_proxy.h" | 24 #include "base/message_loop_proxy.h" |
| 25 #include "base/run_loop.h" |
25 #include "base/stl_util.h" | 26 #include "base/stl_util.h" |
26 #include "base/stringprintf.h" | 27 #include "base/stringprintf.h" |
27 #include "base/synchronization/waitable_event.h" | 28 #include "base/synchronization/waitable_event.h" |
28 #include "base/test/test_file_util.h" | 29 #include "base/test/test_file_util.h" |
29 #include "base/test/test_timeouts.h" | 30 #include "base/test/test_timeouts.h" |
30 #include "base/threading/thread.h" | 31 #include "base/threading/thread.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
32 | 33 |
33 namespace base { | 34 namespace base { |
34 | 35 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 protected: | 161 protected: |
161 virtual void SetUp() OVERRIDE { | 162 virtual void SetUp() OVERRIDE { |
162 // Create a separate file thread in order to test proper thread usage. | 163 // Create a separate file thread in order to test proper thread usage. |
163 base::Thread::Options options(MessageLoop::TYPE_IO, 0); | 164 base::Thread::Options options(MessageLoop::TYPE_IO, 0); |
164 ASSERT_TRUE(file_thread_.StartWithOptions(options)); | 165 ASSERT_TRUE(file_thread_.StartWithOptions(options)); |
165 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 166 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
166 collector_ = new NotificationCollector(); | 167 collector_ = new NotificationCollector(); |
167 } | 168 } |
168 | 169 |
169 virtual void TearDown() OVERRIDE { | 170 virtual void TearDown() OVERRIDE { |
170 loop_.RunUntilIdle(); | 171 RunLoop().RunUntilIdle(); |
171 } | 172 } |
172 | 173 |
173 void DeleteDelegateOnFileThread(TestDelegate* delegate) { | 174 void DeleteDelegateOnFileThread(TestDelegate* delegate) { |
174 file_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, delegate); | 175 file_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, delegate); |
175 } | 176 } |
176 | 177 |
177 FilePath test_file() { | 178 FilePath test_file() { |
178 return temp_dir_.path().AppendASCII("FilePathWatcherTest"); | 179 return temp_dir_.path().AppendASCII("FilePathWatcherTest"); |
179 } | 180 } |
180 | 181 |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); | 906 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); |
906 ASSERT_TRUE(WaitForEvents()); | 907 ASSERT_TRUE(WaitForEvents()); |
907 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); | 908 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); |
908 DeleteDelegateOnFileThread(delegate.release()); | 909 DeleteDelegateOnFileThread(delegate.release()); |
909 } | 910 } |
910 | 911 |
911 #endif // OS_MACOSX | 912 #endif // OS_MACOSX |
912 } // namespace | 913 } // namespace |
913 | 914 |
914 } // namespace base | 915 } // namespace base |
OLD | NEW |