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

Side by Side Diff: components/sync/driver/glue/sync_backend_registrar_unittest.cc

Issue 2422253002: [Sync] Rewriting ".reset(new" pattern to use "= base::MakeUnique" instead. (Closed)
Patch Set: Fixing compile. Created 4 years, 2 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/driver/glue/sync_backend_registrar.h" 5 #include "components/sync/driver/glue/sync_backend_registrar.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h" 9 #include "base/run_loop.h"
9 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
10 #include "components/sync/driver/change_processor_mock.h" 11 #include "components/sync/driver/change_processor_mock.h"
11 #include "components/sync/driver/fake_sync_client.h" 12 #include "components/sync/driver/fake_sync_client.h"
12 #include "components/sync/driver/glue/browser_thread_model_worker.h" 13 #include "components/sync/driver/glue/browser_thread_model_worker.h"
13 #include "components/sync/driver/sync_api_component_factory_mock.h" 14 #include "components/sync/driver/sync_api_component_factory_mock.h"
14 #include "components/sync/engine/passive_model_worker.h" 15 #include "components/sync/engine/passive_model_worker.h"
15 #include "components/sync/syncable/test_user_share.h" 16 #include "components/sync/syncable/test_user_share.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 : db_thread_("DBThreadForTest"), 82 : db_thread_("DBThreadForTest"),
82 file_thread_("FileThreadForTest"), 83 file_thread_("FileThreadForTest"),
83 sync_thread_(NULL) {} 84 sync_thread_(NULL) {}
84 85
85 ~SyncBackendRegistrarTest() override {} 86 ~SyncBackendRegistrarTest() override {}
86 87
87 void SetUp() override { 88 void SetUp() override {
88 db_thread_.StartAndWaitForTesting(); 89 db_thread_.StartAndWaitForTesting();
89 file_thread_.StartAndWaitForTesting(); 90 file_thread_.StartAndWaitForTesting();
90 test_user_share_.SetUp(); 91 test_user_share_.SetUp();
91 sync_client_.reset(new RegistrarSyncClient( 92 sync_client_ = base::MakeUnique<RegistrarSyncClient>(
92 ui_task_runner(), db_task_runner(), file_task_runner())); 93 ui_task_runner(), db_task_runner(), file_task_runner());
93 registrar_.reset(new SyncBackendRegistrar( 94 registrar_ = base::MakeUnique<SyncBackendRegistrar>(
94 "test", sync_client_.get(), std::unique_ptr<base::Thread>(), 95 "test", sync_client_.get(), std::unique_ptr<base::Thread>(),
95 ui_task_runner(), db_task_runner(), file_task_runner())); 96 ui_task_runner(), db_task_runner(), file_task_runner());
96 sync_thread_ = registrar_->sync_thread(); 97 sync_thread_ = registrar_->sync_thread();
97 } 98 }
98 99
99 void TearDown() override { 100 void TearDown() override {
100 registrar_->RequestWorkerStopOnUIThread(); 101 registrar_->RequestWorkerStopOnUIThread();
101 test_user_share_.TearDown(); 102 test_user_share_.TearDown();
102 sync_thread_->task_runner()->PostTask( 103 sync_thread_->task_runner()->PostTask(
103 FROM_HERE, base::Bind(&SyncBackendRegistrar::Shutdown, 104 FROM_HERE, base::Bind(&SyncBackendRegistrar::Shutdown,
104 base::Unretained(registrar_.release()))); 105 base::Unretained(registrar_.release())));
105 sync_thread_->WaitUntilThreadStarted(); 106 sync_thread_->WaitUntilThreadStarted();
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 db_thread_blocked_(base::WaitableEvent::ResetPolicy::AUTOMATIC, 322 db_thread_blocked_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
322 base::WaitableEvent::InitialState::NOT_SIGNALED) { 323 base::WaitableEvent::InitialState::NOT_SIGNALED) {
323 quit_closure_ = run_loop_.QuitClosure(); 324 quit_closure_ = run_loop_.QuitClosure();
324 } 325 }
325 326
326 ~SyncBackendRegistrarShutdownTest() override {} 327 ~SyncBackendRegistrarShutdownTest() override {}
327 328
328 void SetUp() override { 329 void SetUp() override {
329 db_thread_.StartAndWaitForTesting(); 330 db_thread_.StartAndWaitForTesting();
330 file_thread_.StartAndWaitForTesting(); 331 file_thread_.StartAndWaitForTesting();
331 sync_client_.reset(new RegistrarSyncClient( 332 sync_client_ = base::MakeUnique<RegistrarSyncClient>(
332 ui_task_runner(), db_task_runner(), file_task_runner())); 333 ui_task_runner(), db_task_runner(), file_task_runner());
333 } 334 }
334 335
335 void PostQuitOnUIMessageLoop() { 336 void PostQuitOnUIMessageLoop() {
336 ui_task_runner()->PostTask(FROM_HERE, quit_closure_); 337 ui_task_runner()->PostTask(FROM_HERE, quit_closure_);
337 } 338 }
338 339
339 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() { 340 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() {
340 return message_loop_.task_runner(); 341 return message_loop_.task_runner();
341 } 342 }
342 343
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 db_thread_lock_.Release(); 424 db_thread_lock_.Release();
424 425
425 // Run the main thread loop until all workers have been removed and the 426 // Run the main thread loop until all workers have been removed and the
426 // registrar destroyed. 427 // registrar destroyed.
427 run_loop_.Run(); 428 run_loop_.Run();
428 } 429 }
429 430
430 } // namespace 431 } // namespace
431 432
432 } // namespace syncer 433 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/glue/sync_backend_registrar.cc ('k') | components/sync/driver/model_type_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698