| 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 "chrome/browser/sync/glue/ui_model_worker.h" | 7 #include "chrome/browser/sync/glue/ui_model_worker.h" |
| 8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
| 9 #include "components/sync_driver/change_processor_mock.h" | 9 #include "components/sync_driver/change_processor_mock.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 }; | 284 }; |
| 285 | 285 |
| 286 // Wrap SyncBackendRegistrar so that we can monitor its lifetime. | 286 // Wrap SyncBackendRegistrar so that we can monitor its lifetime. |
| 287 class TestRegistrar : public SyncBackendRegistrar { | 287 class TestRegistrar : public SyncBackendRegistrar { |
| 288 public: | 288 public: |
| 289 explicit TestRegistrar(Profile* profile, | 289 explicit TestRegistrar(Profile* profile, |
| 290 SyncBackendRegistrarShutdownTest* test) | 290 SyncBackendRegistrarShutdownTest* test) |
| 291 : SyncBackendRegistrar("test", profile, scoped_ptr<base::Thread>()), | 291 : SyncBackendRegistrar("test", profile, scoped_ptr<base::Thread>()), |
| 292 test_(test) {} | 292 test_(test) {} |
| 293 | 293 |
| 294 virtual ~TestRegistrar() { test_->registrar_destroyed_.Signal(); } | 294 ~TestRegistrar() override { test_->registrar_destroyed_.Signal(); } |
| 295 | 295 |
| 296 private: | 296 private: |
| 297 SyncBackendRegistrarShutdownTest* test_; | 297 SyncBackendRegistrarShutdownTest* test_; |
| 298 }; | 298 }; |
| 299 | 299 |
| 300 TEST_F(SyncBackendRegistrarShutdownTest, BlockingShutdown) { | 300 TEST_F(SyncBackendRegistrarShutdownTest, BlockingShutdown) { |
| 301 // Take ownership of |db_thread_lock_| so that the DB thread can't acquire it. | 301 // Take ownership of |db_thread_lock_| so that the DB thread can't acquire it. |
| 302 db_thread_lock_.Acquire(); | 302 db_thread_lock_.Acquire(); |
| 303 | 303 |
| 304 // This will block the DB thread by waiting on |db_thread_lock_|. | 304 // This will block the DB thread by waiting on |db_thread_lock_|. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 base::MessageLoop::current()->RunUntilIdle(); | 337 base::MessageLoop::current()->RunUntilIdle(); |
| 338 | 338 |
| 339 // This verifies that all workers have been removed and the registrar | 339 // This verifies that all workers have been removed and the registrar |
| 340 // destroyed. | 340 // destroyed. |
| 341 registrar_destroyed_.Wait(); | 341 registrar_destroyed_.Wait(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 } // namespace | 344 } // namespace |
| 345 | 345 |
| 346 } // namespace browser_sync | 346 } // namespace browser_sync |
| OLD | NEW |