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

Unified Diff: components/sync/driver/glue/ui_model_worker_unittest.cc

Issue 2496723003: [Sync] Signal UIModelWorker to abort on sync shutdown. (Closed)
Patch Set: Fix iOS hopefully. Created 4 years, 1 month 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 | « components/sync/driver/glue/ui_model_worker.cc ('k') | components/sync/engine/model_safe_worker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/driver/glue/ui_model_worker_unittest.cc
diff --git a/components/sync/driver/glue/ui_model_worker_unittest.cc b/components/sync/driver/glue/ui_model_worker_unittest.cc
index d091f317a5c60f2896c0a05ec84abbea9095a730..5af7a1ca2be2a8ddd0123f2fbfb94013891b9dcb 100644
--- a/components/sync/driver/glue/ui_model_worker_unittest.cc
+++ b/components/sync/driver/glue/ui_model_worker_unittest.cc
@@ -39,11 +39,23 @@ class SyncUIModelWorkerTest : public testing::Test {
worker_ = new UIModelWorker(base::ThreadTaskRunnerHandle::Get());
}
- void PostWorkToSyncThread(WorkCallback work) {
+ void PostWorkToSyncThread(base::Closure work) {
sync_thread_.task_runner()->PostTask(
FROM_HERE,
base::Bind(base::IgnoreResult(&UIModelWorker::DoWorkAndWaitUntilDone),
- worker_, work));
+ worker_, ClosureToWorkCallback(work)));
+ }
+
+ // Work function for ShutdownNoDeadlock below.
+ void DeadlockTest(base::Closure quit_closure) {
+ // Unblock the sync thread.
+ worker_->RequestStop();
+
+ // Join the sync thread.
+ sync_thread_.Stop();
+
+ // Let the test complete.
+ quit_closure.Run();
}
private:
@@ -54,10 +66,18 @@ class SyncUIModelWorkerTest : public testing::Test {
TEST_F(SyncUIModelWorkerTest, ScheduledWorkRunsOnUILoop) {
base::RunLoop run_loop;
- PostWorkToSyncThread(ClosureToWorkCallback(run_loop.QuitClosure()));
+ PostWorkToSyncThread(run_loop.QuitClosure());
// This won't quit until the QuitClosure is run.
run_loop.Run();
}
+TEST_F(SyncUIModelWorkerTest, ShutdownNoDeadlock) {
+ base::RunLoop run_loop;
+ PostWorkToSyncThread(base::Bind(&SyncUIModelWorkerTest::DeadlockTest,
+ base::Unretained(this),
+ run_loop.QuitClosure()));
+ run_loop.Run();
+}
+
} // namespace
} // namespace syncer
« no previous file with comments | « components/sync/driver/glue/ui_model_worker.cc ('k') | components/sync/engine/model_safe_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698