| 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" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 DISALLOW_COPY_AND_ASSIGN(SingleClientDirectorySyncTest); | 49 DISALLOW_COPY_AND_ASSIGN(SingleClientDirectorySyncTest); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 void SignalEvent(base::WaitableEvent* e) { | 52 void SignalEvent(base::WaitableEvent* e) { |
| 53 e->Signal(); | 53 e->Signal(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool WaitForExistingTasksOnLoop(base::MessageLoop* loop) { | 56 bool WaitForExistingTasksOnLoop(base::MessageLoop* loop) { |
| 57 base::WaitableEvent e(base::WaitableEvent::ResetPolicy::MANUAL, | 57 base::WaitableEvent e(base::WaitableEvent::ResetPolicy::MANUAL, |
| 58 base::WaitableEvent::InitialState::NOT_SIGNALED); | 58 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 59 loop->task_runner()->PostTask(FROM_HERE, base::Bind(&SignalEvent, &e)); | 59 loop->task_runner()->PostTask(FROM_HERE, base::BindOnce(&SignalEvent, &e)); |
| 60 // Timeout stolen from StatusChangeChecker::GetTimeoutDuration(). | 60 // Timeout stolen from StatusChangeChecker::GetTimeoutDuration(). |
| 61 return e.TimedWait(base::TimeDelta::FromSeconds(45)); | 61 return e.TimedWait(base::TimeDelta::FromSeconds(45)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // A status change checker that waits for an unrecoverable sync error to occur. | 64 // A status change checker that waits for an unrecoverable sync error to occur. |
| 65 class SyncUnrecoverableErrorChecker : public SingleClientStatusChangeChecker { | 65 class SyncUnrecoverableErrorChecker : public SingleClientStatusChangeChecker { |
| 66 public: | 66 public: |
| 67 explicit SyncUnrecoverableErrorChecker( | 67 explicit SyncUnrecoverableErrorChecker( |
| 68 browser_sync::ProfileSyncService* service) | 68 browser_sync::ProfileSyncService* service) |
| 69 : SingleClientStatusChangeChecker(service) {} | 69 : SingleClientStatusChangeChecker(service) {} |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 ASSERT_TRUE(SyncUnrecoverableErrorChecker(sync_service).Wait()); | 137 ASSERT_TRUE(SyncUnrecoverableErrorChecker(sync_service).Wait()); |
| 138 ASSERT_TRUE(sync_service->HasUnrecoverableError()); | 138 ASSERT_TRUE(sync_service->HasUnrecoverableError()); |
| 139 | 139 |
| 140 // Wait until the sync loop has processed any existing tasks and see that the | 140 // Wait until the sync loop has processed any existing tasks and see that the |
| 141 // directory no longer exists. | 141 // directory no longer exists. |
| 142 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); | 142 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); |
| 143 ASSERT_FALSE(FolderContainsFiles(directory_path)); | 143 ASSERT_FALSE(FolderContainsFiles(directory_path)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace | 146 } // namespace |
| OLD | NEW |