| 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 #include "base/files/file_path_watcher.h" | 5 #include "base/files/file_path_watcher.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #include <aclapi.h> | 11 #include <aclapi.h> |
| 12 #elif defined(OS_POSIX) | 12 #elif defined(OS_POSIX) |
| 13 #include <sys/stat.h> | 13 #include <sys/stat.h> |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/file_path.h" | 18 #include "base/file_path.h" |
| 19 #include "base/file_util.h" | 19 #include "base/file_util.h" |
| 20 #include "base/memory/scoped_temp_dir.h" | 20 #include "base/memory/scoped_temp_dir.h" |
| 21 #include "base/message_loop.h" | 21 #include "base/message_loop.h" |
| 22 #include "base/message_loop_proxy.h" | 22 #include "base/message_loop_proxy.h" |
| 23 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 24 #include "base/string_util.h" | |
| 25 #include "base/stl_util-inl.h" | 24 #include "base/stl_util-inl.h" |
| 25 #include "base/stringprintf.h" |
| 26 #include "base/synchronization/waitable_event.h" | 26 #include "base/synchronization/waitable_event.h" |
| 27 #include "base/test/test_timeouts.h" | 27 #include "base/test/test_timeouts.h" |
| 28 #include "base/threading/thread.h" | 28 #include "base/threading/thread.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 30 |
| 31 namespace base { | 31 namespace base { |
| 32 namespace files { | 32 namespace files { |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 VLOG(1) << "Waiting for file deletion"; | 328 VLOG(1) << "Waiting for file deletion"; |
| 329 ASSERT_TRUE(WaitForEvents()); | 329 ASSERT_TRUE(WaitForEvents()); |
| 330 } | 330 } |
| 331 | 331 |
| 332 // Exercises watch reconfiguration for the case that directories on the path | 332 // Exercises watch reconfiguration for the case that directories on the path |
| 333 // are rapidly created. | 333 // are rapidly created. |
| 334 TEST_F(FilePathWatcherTest, DirectoryChain) { | 334 TEST_F(FilePathWatcherTest, DirectoryChain) { |
| 335 FilePath path(temp_dir_.path()); | 335 FilePath path(temp_dir_.path()); |
| 336 std::vector<std::string> dir_names; | 336 std::vector<std::string> dir_names; |
| 337 for (int i = 0; i < 20; i++) { | 337 for (int i = 0; i < 20; i++) { |
| 338 std::string dir(StringPrintf("d%d", i)); | 338 std::string dir(base::StringPrintf("d%d", i)); |
| 339 dir_names.push_back(dir); | 339 dir_names.push_back(dir); |
| 340 path = path.AppendASCII(dir); | 340 path = path.AppendASCII(dir); |
| 341 } | 341 } |
| 342 | 342 |
| 343 FilePathWatcher watcher; | 343 FilePathWatcher watcher; |
| 344 FilePath file(path.AppendASCII("file")); | 344 FilePath file(path.AppendASCII("file")); |
| 345 scoped_refptr<TestDelegate> delegate(new TestDelegate(collector())); | 345 scoped_refptr<TestDelegate> delegate(new TestDelegate(collector())); |
| 346 ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get())); | 346 ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get())); |
| 347 | 347 |
| 348 FilePath sub_path(temp_dir_.path()); | 348 FilePath sub_path(temp_dir_.path()); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); | 613 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); |
| 614 ASSERT_TRUE(WaitForEvents()); | 614 ASSERT_TRUE(WaitForEvents()); |
| 615 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); | 615 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); |
| 616 } | 616 } |
| 617 | 617 |
| 618 #endif // OS_MACOSX | 618 #endif // OS_MACOSX |
| 619 } // namespace | 619 } // namespace |
| 620 | 620 |
| 621 } // namespace files | 621 } // namespace files |
| 622 } // namespace base | 622 } // namespace base |
| OLD | NEW |