Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc

Issue 296893002: [SyncFS] Make DriveBackendSyncTest run in multi-threaded env. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b528b52d5c6d3431672953270aec4d7f0b1647a3..381e76e8c3a5ac1b8f0cea0d2ca184b1e046d605 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_in) {
nhiroki 2014/05/26 09:56:00 In syncfs, we haven't used "_in" suffix for input
peria 2014/05/27 02:40:12 Done. Going along with current code is better, I t
+ *status_out = status_in;
+ closure.Run();
+}
+
+void SetSyncStatusAndUrl(const base::Closure& closure,
+ SyncStatusCode* status_out,
+ fileapi::FileSystemURL* url_out,
+ SyncStatusCode status_in,
+ const fileapi::FileSystemURL& url_in) {
+ *status_out = status_in;
+ *url_out = url_in;
+ closure.Run();
+}
+
+} // namespace
+
class DriveBackendSyncTest : public testing::Test,
public LocalFileSyncService::Observer,
public RemoteFileSyncService::Observer {
@@ -53,10 +74,17 @@ class DriveBackendSyncTest : public testing::Test,
ASSERT_TRUE(base_dir_.CreateUniqueTempDir());
in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
+ scoped_refptr<base::SequencedWorkerPool> worker_pool(
+ content::BrowserThread::GetBlockingPool());
+
nhiroki 2014/05/26 09:56:00 Can you move this to line 83 or just call content:
peria 2014/05/27 02:40:12 Done.
io_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::IO);
file_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE);
+ worker_task_runner_ =
+ worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
+ worker_pool->GetSequenceToken(),
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
RegisterSyncableFileSystem();
local_sync_service_ = LocalFileSyncService::CreateForTesting(
@@ -83,7 +111,7 @@ class DriveBackendSyncTest : public testing::Test,
NULL, NULL, NULL));
remote_sync_service_->AddServiceObserver(this);
remote_sync_service_->Initialize(base_dir_.path(),
- base::MessageLoopProxy::current(),
+ worker_task_runner_.get(),
in_memory_env_.get());
remote_sync_service_->SetSyncEnabled(true);
@@ -161,10 +189,13 @@ class DriveBackendSyncTest : public testing::Test,
file_system->SetUp(CannedSyncableFileSystem::QUOTA_DISABLED);
SyncStatusCode status = SYNC_STATUS_UNKNOWN;
- local_sync_service_->MaybeInitializeFileSystemContext(
- origin, file_system->file_system_context(),
- CreateResultReceiver(&status));
- base::RunLoop().RunUntilIdle();
+ {
+ base::RunLoop run_loop;
+ local_sync_service_->MaybeInitializeFileSystemContext(
+ origin, file_system->file_system_context(),
+ base::Bind(&SetSyncStatus, run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ }
nhiroki 2014/05/26 09:56:00 You are already surrounded with if-block.
peria 2014/05/27 02:40:12 Done.
EXPECT_EQ(SYNC_STATUS_OK, status);
file_system->backend()->sync_context()->
@@ -175,8 +206,13 @@ 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;
}
@@ -222,18 +258,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;
}
@@ -491,6 +529,7 @@ class DriveBackendSyncTest : public testing::Test,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
+ scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
nhiroki 2014/05/26 09:56:00 Can you move this after |file_task_runner_| to sor
peria 2014/05/27 02:40:12 Done. I changed the order of setting them up. I an
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
DISALLOW_COPY_AND_ASSIGN(DriveBackendSyncTest);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698