| Index: chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc
|
| diff --git a/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc b/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc
|
| index ef451291d12f281102dcf05492884bfa61a43091..917c8374597026eb63cb53aebe7e7c1c6970a9e5 100644
|
| --- a/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc
|
| +++ b/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc
|
| @@ -39,6 +39,27 @@ namespace drive_backend {
|
|
|
| typedef fileapi::FileSystemOperation::FileEntryList FileEntryList;
|
|
|
| +namespace {
|
| +
|
| +void SetSyncStatus(const base::Closure& closure,
|
| + SyncStatusCode* status_out,
|
| + SyncStatusCode status) {
|
| + *status_out = status;
|
| + closure.Run();
|
| +}
|
| +
|
| +void SetSyncStatusAndUrl(const base::Closure& closure,
|
| + SyncStatusCode* status_out,
|
| + fileapi::FileSystemURL* url_out,
|
| + SyncStatusCode status,
|
| + const fileapi::FileSystemURL& url) {
|
| + *status_out = status;
|
| + *url_out = url;
|
| + closure.Run();
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| class DriveBackendSyncTest : public testing::Test,
|
| public LocalFileSyncService::Observer,
|
| public RemoteFileSyncService::Observer {
|
| @@ -55,6 +76,12 @@ class DriveBackendSyncTest : public testing::Test,
|
|
|
| io_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread(
|
| content::BrowserThread::IO);
|
| + scoped_refptr<base::SequencedWorkerPool> worker_pool(
|
| + content::BrowserThread::GetBlockingPool());
|
| + worker_task_runner_ =
|
| + worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
|
| + worker_pool->GetSequenceToken(),
|
| + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
|
| file_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread(
|
| content::BrowserThread::FILE);
|
|
|
| @@ -84,7 +111,7 @@ class DriveBackendSyncTest : public testing::Test,
|
| remote_sync_service_->AddServiceObserver(this);
|
| remote_sync_service_->Initialize(base_dir_.path(),
|
| NULL,
|
| - base::MessageLoopProxy::current(),
|
| + worker_task_runner_.get(),
|
| in_memory_env_.get());
|
| remote_sync_service_->SetSyncEnabled(true);
|
|
|
| @@ -162,10 +189,11 @@ class DriveBackendSyncTest : public testing::Test,
|
| file_system->SetUp(CannedSyncableFileSystem::QUOTA_DISABLED);
|
|
|
| SyncStatusCode status = SYNC_STATUS_UNKNOWN;
|
| + base::RunLoop run_loop;
|
| local_sync_service_->MaybeInitializeFileSystemContext(
|
| origin, file_system->file_system_context(),
|
| - CreateResultReceiver(&status));
|
| - base::RunLoop().RunUntilIdle();
|
| + base::Bind(&SetSyncStatus, run_loop.QuitClosure(), &status));
|
| + run_loop.Run();
|
| EXPECT_EQ(SYNC_STATUS_OK, status);
|
|
|
| file_system->backend()->sync_context()->
|
| @@ -176,8 +204,11 @@ class DriveBackendSyncTest : public testing::Test,
|
| }
|
|
|
| SyncStatusCode status = SYNC_STATUS_UNKNOWN;
|
| - remote_sync_service_->RegisterOrigin(origin, CreateResultReceiver(&status));
|
| - base::RunLoop().RunUntilIdle();
|
| + base::RunLoop run_loop;
|
| + remote_sync_service_->RegisterOrigin(
|
| + origin,
|
| + base::Bind(&SetSyncStatus, run_loop.QuitClosure(), &status));
|
| + run_loop.Run();
|
| return status;
|
| }
|
|
|
| @@ -223,18 +254,20 @@ class DriveBackendSyncTest : public testing::Test,
|
| SyncStatusCode ProcessLocalChange() {
|
| SyncStatusCode status = SYNC_STATUS_UNKNOWN;
|
| fileapi::FileSystemURL url;
|
| - local_sync_service_->ProcessLocalChange(
|
| - CreateResultReceiver(&status, &url));
|
| - base::RunLoop().RunUntilIdle();
|
| + base::RunLoop run_loop;
|
| + local_sync_service_->ProcessLocalChange(base::Bind(
|
| + &SetSyncStatusAndUrl, run_loop.QuitClosure(), &status, &url));
|
| + run_loop.Run();
|
| return status;
|
| }
|
|
|
| SyncStatusCode ProcessRemoteChange() {
|
| SyncStatusCode status = SYNC_STATUS_UNKNOWN;
|
| fileapi::FileSystemURL url;
|
| - remote_sync_service_->ProcessRemoteChange(
|
| - CreateResultReceiver(&status, &url));
|
| - base::RunLoop().RunUntilIdle();
|
| + base::RunLoop run_loop;
|
| + remote_sync_service_->ProcessRemoteChange(base::Bind(
|
| + &SetSyncStatusAndUrl, run_loop.QuitClosure(), &status, &url));
|
| + run_loop.Run();
|
| return status;
|
| }
|
|
|
| @@ -492,6 +525,7 @@ class DriveBackendSyncTest : public testing::Test,
|
|
|
|
|
| scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
|
| + scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
|
| scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(DriveBackendSyncTest);
|
|
|