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

Side by Side Diff: components/sync/driver/shared_change_processor_unittest.cc

Issue 2257523003: [Sync] Move StartAssociation from NonUIDataTypeController to SharedChangeProcessor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move local_service_ WeakPtr to SharedChangeProcessor. Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/shared_change_processor.h" 5 #include "components/sync/driver/shared_change_processor.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/location.h" 14 #include "base/location.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
16 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
17 #include "components/sync/api/attachments/attachment_id.h" 18 #include "components/sync/api/attachments/attachment_id.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 // FakeSyncClient override. 97 // FakeSyncClient override.
97 base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( 98 base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType(
98 syncer::ModelType type) override { 99 syncer::ModelType type) override {
99 return db_syncable_service_->AsWeakPtr(); 100 return db_syncable_service_->AsWeakPtr();
100 } 101 }
101 102
102 protected: 103 protected:
103 void SetUp() override { 104 void SetUp() override {
104 test_user_share_.SetUp(); 105 test_user_share_.SetUp();
105 shared_change_processor_ = new SharedChangeProcessor(); 106 shared_change_processor_ = new SharedChangeProcessor(syncer::AUTOFILL);
106 ASSERT_TRUE(backend_thread_.Start()); 107 ASSERT_TRUE(backend_thread_.Start());
107 ASSERT_TRUE(backend_thread_.task_runner()->PostTask( 108 ASSERT_TRUE(backend_thread_.task_runner()->PostTask(
108 FROM_HERE, 109 FROM_HERE,
109 base::Bind(&SyncSharedChangeProcessorTest::SetUpDBSyncableService, 110 base::Bind(&SyncSharedChangeProcessorTest::SetUpDBSyncableService,
110 base::Unretained(this)))); 111 base::Unretained(this))));
111 } 112 }
112 113
113 void TearDown() override { 114 void TearDown() override {
114 EXPECT_TRUE(backend_thread_.task_runner()->PostTask( 115 EXPECT_TRUE(backend_thread_.task_runner()->PostTask(
115 FROM_HERE, 116 FROM_HERE,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 183 }
183 184
184 // Used by Connect(). The SharedChangeProcessor is passed in 185 // Used by Connect(). The SharedChangeProcessor is passed in
185 // because we modify |shared_change_processor_| on the main thread 186 // because we modify |shared_change_processor_| on the main thread
186 // (in TearDown()). 187 // (in TearDown()).
187 void ConnectOnDBThread( 188 void ConnectOnDBThread(
188 const scoped_refptr<SharedChangeProcessor>& shared_change_processor) { 189 const scoped_refptr<SharedChangeProcessor>& shared_change_processor) {
189 DCHECK(backend_thread_.task_runner()->BelongsToCurrentThread()); 190 DCHECK(backend_thread_.task_runner()->BelongsToCurrentThread());
190 EXPECT_TRUE(shared_change_processor->Connect( 191 EXPECT_TRUE(shared_change_processor->Connect(
191 this, &processor_factory_, test_user_share_.user_share(), 192 this, &processor_factory_, test_user_share_.user_share(),
192 &error_handler_, syncer::AUTOFILL, 193 &error_handler_, base::WeakPtr<syncer::SyncMergeResult>()));
193 base::WeakPtr<syncer::SyncMergeResult>()));
194 did_connect_ = true; 194 did_connect_ = true;
195 } 195 }
196 196
197 void CheckAttachmentServiceOnDBThread(base::WaitableEvent* event) { 197 void CheckAttachmentServiceOnDBThread(base::WaitableEvent* event) {
198 DCHECK(backend_thread_.task_runner()->BelongsToCurrentThread()); 198 DCHECK(backend_thread_.task_runner()->BelongsToCurrentThread());
199 DCHECK(db_syncable_service_.get()); 199 DCHECK(db_syncable_service_.get());
200 has_attachment_service_ = !!db_syncable_service_->attachment_service(); 200 has_attachment_service_ = !!db_syncable_service_->attachment_service();
201 event->Signal(); 201 event->Signal();
202 } 202 }
203 203
(...skipping 24 matching lines...) Expand all
228 // creates AttachmentService and passes it back to the syncable service. 228 // creates AttachmentService and passes it back to the syncable service.
229 TEST_F(SyncSharedChangeProcessorTest, ConnectWithAttachmentStore) { 229 TEST_F(SyncSharedChangeProcessorTest, ConnectWithAttachmentStore) {
230 SetAttachmentStore(); 230 SetAttachmentStore();
231 Connect(); 231 Connect();
232 EXPECT_TRUE(HasAttachmentService()); 232 EXPECT_TRUE(HasAttachmentService());
233 } 233 }
234 234
235 } // namespace 235 } // namespace
236 236
237 } // namespace sync_driver 237 } // namespace sync_driver
OLDNEW
« no previous file with comments | « components/sync/driver/shared_change_processor.cc ('k') | components/sync/driver/ui_data_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698