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

Side by Side Diff: components/sync/engine/ui_model_worker_unittest.cc

Issue 2782573002: [Sync] Refactor ModelSafeWorker::DoWorkAndWaitUntilDone() to avoid code duplication. (Closed)
Patch Set: self-review Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/sync/engine/ui_model_worker.h" 5 #include "components/sync/engine/ui_model_worker.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 public: 45 public:
46 SyncUIModelWorkerTest() : sync_thread_("SyncThreadForTest") { 46 SyncUIModelWorkerTest() : sync_thread_("SyncThreadForTest") {
47 sync_thread_.Start(); 47 sync_thread_.Start();
48 worker_ = new UIModelWorker(base::ThreadTaskRunnerHandle::Get()); 48 worker_ = new UIModelWorker(base::ThreadTaskRunnerHandle::Get());
49 } 49 }
50 50
51 void PostWorkToSyncThread(base::Closure work) { 51 void PostWorkToSyncThread(base::Closure work) {
52 sync_thread_.task_runner()->PostTask( 52 sync_thread_.task_runner()->PostTask(
53 FROM_HERE, 53 FROM_HERE,
54 base::Bind(base::IgnoreResult(&UIModelWorker::DoWorkAndWaitUntilDone), 54 base::Bind(base::IgnoreResult(&UIModelWorker::DoWorkAndWaitUntilDone),
55 worker_, ClosureToWorkCallback(work))); 55 worker_, base::Passed(ClosureToWorkCallback(work))));
56 } 56 }
57 57
58 protected: 58 protected:
59 std::unique_ptr<base::MessageLoop> ui_loop_ = 59 std::unique_ptr<base::MessageLoop> ui_loop_ =
60 base::MakeUnique<base::MessageLoop>(); 60 base::MakeUnique<base::MessageLoop>();
61 base::Thread sync_thread_; 61 base::Thread sync_thread_;
62 scoped_refptr<UIModelWorker> worker_; 62 scoped_refptr<UIModelWorker> worker_;
63 }; 63 };
64 64
65 } // namespace 65 } // namespace
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // RequestStop() is called. However, it doesn't fail (no flakes). 110 // RequestStop() is called. However, it doesn't fail (no flakes).
111 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); 111 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout());
112 112
113 // The sync thread shouldn't wait for the WorkCallback to run on the UI thread 113 // The sync thread shouldn't wait for the WorkCallback to run on the UI thread
114 // after RequestStop() is called. 114 // after RequestStop() is called.
115 worker_->RequestStop(); 115 worker_->RequestStop();
116 sync_thread_.Stop(); 116 sync_thread_.Stop();
117 } 117 }
118 118
119 } // namespace syncer 119 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine/ui_model_worker.cc ('k') | components/sync/engine_impl/directory_update_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698