| 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 "chrome/browser/sync/glue/sync_backend_registrar.h" | 5 #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "chrome/browser/sync/glue/ui_model_worker.h" | 8 #include "chrome/browser/sync/glue/ui_model_worker.h" |
| 9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 10 #include "components/sync_driver/change_processor_mock.h" | 10 #include "components/sync_driver/change_processor_mock.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 done->Signal(); | 58 done->Signal(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 SyncBackendRegistrarTest() | 62 SyncBackendRegistrarTest() |
| 63 : sync_thread_(NULL), | 63 : sync_thread_(NULL), |
| 64 thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | | 64 thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | |
| 65 content::TestBrowserThreadBundle::REAL_FILE_THREAD | | 65 content::TestBrowserThreadBundle::REAL_FILE_THREAD | |
| 66 content::TestBrowserThreadBundle::REAL_IO_THREAD) {} | 66 content::TestBrowserThreadBundle::REAL_IO_THREAD) {} |
| 67 | 67 |
| 68 virtual ~SyncBackendRegistrarTest() {} | 68 ~SyncBackendRegistrarTest() override {} |
| 69 | 69 |
| 70 virtual void SetUp() { | 70 void SetUp() override { |
| 71 test_user_share_.SetUp(); | 71 test_user_share_.SetUp(); |
| 72 registrar_.reset(new SyncBackendRegistrar("test", &profile_, | 72 registrar_.reset(new SyncBackendRegistrar("test", &profile_, |
| 73 scoped_ptr<base::Thread>())); | 73 scoped_ptr<base::Thread>())); |
| 74 sync_thread_ = registrar_->sync_thread(); | 74 sync_thread_ = registrar_->sync_thread(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual void TearDown() { | 77 void TearDown() override { |
| 78 registrar_->RequestWorkerStopOnUIThread(); | 78 registrar_->RequestWorkerStopOnUIThread(); |
| 79 test_user_share_.TearDown(); | 79 test_user_share_.TearDown(); |
| 80 sync_thread_->message_loop()->PostTask( | 80 sync_thread_->message_loop()->PostTask( |
| 81 FROM_HERE, | 81 FROM_HERE, |
| 82 base::Bind(&SyncBackendRegistrar::Shutdown, | 82 base::Bind(&SyncBackendRegistrar::Shutdown, |
| 83 base::Unretained(registrar_.release()))); | 83 base::Unretained(registrar_.release()))); |
| 84 sync_thread_->message_loop()->RunUntilIdle(); | 84 sync_thread_->message_loop()->RunUntilIdle(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void ExpectRoutingInfo( | 87 void ExpectRoutingInfo( |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 friend class TestRegistrar; | 270 friend class TestRegistrar; |
| 271 | 271 |
| 272 SyncBackendRegistrarShutdownTest() | 272 SyncBackendRegistrarShutdownTest() |
| 273 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | | 273 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | |
| 274 content::TestBrowserThreadBundle::REAL_FILE_THREAD | | 274 content::TestBrowserThreadBundle::REAL_FILE_THREAD | |
| 275 content::TestBrowserThreadBundle::REAL_IO_THREAD), | 275 content::TestBrowserThreadBundle::REAL_IO_THREAD), |
| 276 db_thread_blocked_(false, false) { | 276 db_thread_blocked_(false, false) { |
| 277 quit_closure_ = run_loop_.QuitClosure(); | 277 quit_closure_ = run_loop_.QuitClosure(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 virtual ~SyncBackendRegistrarShutdownTest() {} | 280 ~SyncBackendRegistrarShutdownTest() override {} |
| 281 | 281 |
| 282 void PostQuitOnUIMessageLoop() { | 282 void PostQuitOnUIMessageLoop() { |
| 283 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_closure_); | 283 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_closure_); |
| 284 } | 284 } |
| 285 | 285 |
| 286 content::TestBrowserThreadBundle thread_bundle_; | 286 content::TestBrowserThreadBundle thread_bundle_; |
| 287 TestingProfile profile_; | 287 TestingProfile profile_; |
| 288 base::WaitableEvent db_thread_blocked_; | 288 base::WaitableEvent db_thread_blocked_; |
| 289 base::Lock db_thread_lock_; | 289 base::Lock db_thread_lock_; |
| 290 base::RunLoop run_loop_; | 290 base::RunLoop run_loop_; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 db_thread_lock_.Release(); | 343 db_thread_lock_.Release(); |
| 344 | 344 |
| 345 // Run the main thread loop until all workers have been removed and the | 345 // Run the main thread loop until all workers have been removed and the |
| 346 // registrar destroyed. | 346 // registrar destroyed. |
| 347 run_loop_.Run(); | 347 run_loop_.Run(); |
| 348 } | 348 } |
| 349 | 349 |
| 350 } // namespace | 350 } // namespace |
| 351 | 351 |
| 352 } // namespace browser_sync | 352 } // namespace browser_sync |
| OLD | NEW |