Chromium Code Reviews| 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/browser_thread_model_worker.h" | 5 #include "components/sync/engine/browser_thread_model_worker.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 WorkCallback c = base::Bind(&SyncBrowserThreadModelWorkerTest::DoWork, | 43 WorkCallback c = base::Bind(&SyncBrowserThreadModelWorkerTest::DoWork, |
| 44 base::Unretained(this)); | 44 base::Unretained(this)); |
| 45 timer()->Start(FROM_HERE, TestTimeouts::action_timeout(), this, | 45 timer()->Start(FROM_HERE, TestTimeouts::action_timeout(), this, |
| 46 &SyncBrowserThreadModelWorkerTest::Timeout); | 46 &SyncBrowserThreadModelWorkerTest::Timeout); |
| 47 worker()->DoWorkAndWaitUntilDone(c); | 47 worker()->DoWorkAndWaitUntilDone(c); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // This is the work that will be scheduled to be done on the DB thread. | 50 // This is the work that will be scheduled to be done on the DB thread. |
| 51 SyncerError DoWork() { | 51 SyncerError DoWork() { |
| 52 EXPECT_TRUE(db_thread_.task_runner()->BelongsToCurrentThread()); | 52 EXPECT_TRUE(db_thread_.task_runner()->BelongsToCurrentThread()); |
| 53 timer_.Stop(); // Stop the failure timer so the test succeeds. | |
|
stanisc
2017/01/25 00:55:16
Would it make sense to remove timer_ completely an
gab
2017/01/25 14:51:47
Yes it does but since there are many erroneous cas
| |
| 54 main_message_loop_.task_runner()->PostTask( | 53 main_message_loop_.task_runner()->PostTask( |
| 55 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 54 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
| 56 did_do_work_ = true; | 55 did_do_work_ = true; |
| 57 return SYNCER_OK; | 56 return SYNCER_OK; |
| 58 } | 57 } |
| 59 | 58 |
| 60 // This will be called by the OneShotTimer and make the test fail unless | 59 // This will be called by the OneShotTimer and make the test fail unless |
| 61 // DoWork is called first. | 60 // DoWork is called first. |
| 62 void Timeout() { | 61 void Timeout() { |
| 63 ADD_FAILURE() << "Timed out waiting for work to be done on the DB thread."; | 62 ADD_FAILURE() << "Timed out waiting for work to be done on the DB thread."; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 90 base::ThreadTaskRunnerHandle::Get()->PostTask( | 89 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 91 FROM_HERE, base::Bind(&SyncBrowserThreadModelWorkerTest::ScheduleWork, | 90 FROM_HERE, base::Bind(&SyncBrowserThreadModelWorkerTest::ScheduleWork, |
| 92 factory()->GetWeakPtr())); | 91 factory()->GetWeakPtr())); |
| 93 base::RunLoop().Run(); | 92 base::RunLoop().Run(); |
| 94 EXPECT_TRUE(did_do_work()); | 93 EXPECT_TRUE(did_do_work()); |
| 95 } | 94 } |
| 96 | 95 |
| 97 } // namespace | 96 } // namespace |
| 98 | 97 |
| 99 } // namespace syncer | 98 } // namespace syncer |
| OLD | NEW |