OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |