| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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_enumerator.h" | 5 #include "base/files/file_enumerator.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/threading/thread_restrictions.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 16 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 16 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" | 17 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" |
| 17 #include "chrome/browser/sync/test/integration/sync_test.h" | 18 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 18 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" | 19 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" |
| 19 #include "components/browser_sync/profile_sync_service.h" | 20 #include "components/browser_sync/profile_sync_service.h" |
| 20 #include "components/sync/syncable/directory.h" | 21 #include "components/sync/syncable/directory.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "sql/test/test_helpers.h" | 23 #include "sql/test/test_helpers.h" |
| 23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 24 | 25 |
| 25 using content::BrowserThread; | 26 using content::BrowserThread; |
| 26 using base::FileEnumerator; | 27 using base::FileEnumerator; |
| 27 using base::FilePath; | 28 using base::FilePath; |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 // USS ModelTypeStore uses the same folder as the Directory. However, all of its | 32 // USS ModelTypeStore uses the same folder as the Directory. However, all of its |
| 32 // content is in a sub-folder. By not asking for recursive files, this function | 33 // content is in a sub-folder. By not asking for recursive files, this function |
| 33 // will avoid seeing any of those, and return iff Directory database files still | 34 // will avoid seeing any of those, and return iff Directory database files still |
| 34 // exist. | 35 // exist. |
| 35 bool FolderContainsFiles(const FilePath& folder) { | 36 bool FolderContainsFiles(const FilePath& folder) { |
| 37 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 36 if (base::DirectoryExists(folder)) { | 38 if (base::DirectoryExists(folder)) { |
| 37 return !FileEnumerator(folder, false, FileEnumerator::FILES).Next().empty(); | 39 return !FileEnumerator(folder, false, FileEnumerator::FILES).Next().empty(); |
| 38 } else { | 40 } else { |
| 39 return false; | 41 return false; |
| 40 } | 42 } |
| 41 } | 43 } |
| 42 | 44 |
| 43 class SingleClientDirectorySyncTest : public SyncTest { | 45 class SingleClientDirectorySyncTest : public SyncTest { |
| 44 public: | 46 public: |
| 45 SingleClientDirectorySyncTest() : SyncTest(SINGLE_CLIENT) {} | 47 SingleClientDirectorySyncTest() : SyncTest(SINGLE_CLIENT) {} |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 ASSERT_TRUE(SyncUnrecoverableErrorChecker(sync_service).Wait()); | 139 ASSERT_TRUE(SyncUnrecoverableErrorChecker(sync_service).Wait()); |
| 138 ASSERT_TRUE(sync_service->HasUnrecoverableError()); | 140 ASSERT_TRUE(sync_service->HasUnrecoverableError()); |
| 139 | 141 |
| 140 // Wait until the sync loop has processed any existing tasks and see that the | 142 // Wait until the sync loop has processed any existing tasks and see that the |
| 141 // directory no longer exists. | 143 // directory no longer exists. |
| 142 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); | 144 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); |
| 143 ASSERT_FALSE(FolderContainsFiles(directory_path)); | 145 ASSERT_FALSE(FolderContainsFiles(directory_path)); |
| 144 } | 146 } |
| 145 | 147 |
| 146 } // namespace | 148 } // namespace |
| OLD | NEW |