| OLD | NEW |
| 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/generic_change_processor.h" | 5 #include "components/sync/driver/generic_change_processor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "components/sync/api/attachments/attachment_id.h" | 17 #include "components/sync/api/attachments/attachment_id.h" |
| 18 #include "components/sync/api/attachments/attachment_store.h" | 18 #include "components/sync/api/attachments/attachment_store.h" |
| 19 #include "components/sync/api/data_type_error_handler_mock.h" |
| 19 #include "components/sync/api/fake_syncable_service.h" | 20 #include "components/sync/api/fake_syncable_service.h" |
| 20 #include "components/sync/api/sync_change.h" | 21 #include "components/sync/api/sync_change.h" |
| 21 #include "components/sync/api/sync_merge_result.h" | 22 #include "components/sync/api/sync_merge_result.h" |
| 22 #include "components/sync/base/model_type.h" | 23 #include "components/sync/base/model_type.h" |
| 23 #include "components/sync/core/attachments/attachment_service_impl.h" | 24 #include "components/sync/core/attachments/attachment_service_impl.h" |
| 24 #include "components/sync/core/attachments/fake_attachment_downloader.h" | 25 #include "components/sync/core/attachments/fake_attachment_downloader.h" |
| 25 #include "components/sync/core/attachments/fake_attachment_uploader.h" | 26 #include "components/sync/core/attachments/fake_attachment_uploader.h" |
| 26 #include "components/sync/core/read_node.h" | 27 #include "components/sync/core/read_node.h" |
| 27 #include "components/sync/core/read_transaction.h" | 28 #include "components/sync/core/read_transaction.h" |
| 28 #include "components/sync/core/sync_encryption_handler.h" | 29 #include "components/sync/core/sync_encryption_handler.h" |
| 29 #include "components/sync/core/test/data_type_error_handler_mock.h" | |
| 30 #include "components/sync/core/test/test_user_share.h" | 30 #include "components/sync/core/test/test_user_share.h" |
| 31 #include "components/sync/core/user_share.h" | 31 #include "components/sync/core/user_share.h" |
| 32 #include "components/sync/core/write_node.h" | 32 #include "components/sync/core/write_node.h" |
| 33 #include "components/sync/core/write_transaction.h" | 33 #include "components/sync/core/write_transaction.h" |
| 34 #include "components/sync/device_info/local_device_info_provider.h" | 34 #include "components/sync/device_info/local_device_info_provider.h" |
| 35 #include "components/sync/driver/fake_sync_client.h" | 35 #include "components/sync/driver/fake_sync_client.h" |
| 36 #include "components/sync/driver/sync_api_component_factory.h" | 36 #include "components/sync/driver/sync_api_component_factory.h" |
| 37 #include "testing/gmock/include/gmock/gmock.h" | 37 #include "testing/gmock/include/gmock/gmock.h" |
| 38 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 39 | 39 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | 104 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, |
| 105 const base::FilePath& sync_folder) override { | 105 const base::FilePath& sync_folder) override { |
| 106 return nullptr; | 106 return nullptr; |
| 107 } | 107 } |
| 108 std::unique_ptr<sync_driver::LocalDeviceInfoProvider> | 108 std::unique_ptr<sync_driver::LocalDeviceInfoProvider> |
| 109 CreateLocalDeviceInfoProvider() override { | 109 CreateLocalDeviceInfoProvider() override { |
| 110 return nullptr; | 110 return nullptr; |
| 111 } | 111 } |
| 112 SyncComponents CreateBookmarkSyncComponents( | 112 SyncComponents CreateBookmarkSyncComponents( |
| 113 sync_driver::SyncService* sync_service, | 113 sync_driver::SyncService* sync_service, |
| 114 syncer::DataTypeErrorHandler* error_handler) override { | 114 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler) override { |
| 115 return SyncComponents(nullptr, nullptr); | 115 return SyncComponents(nullptr, nullptr); |
| 116 } | 116 } |
| 117 | 117 |
| 118 std::unique_ptr<syncer::AttachmentService> CreateAttachmentService( | 118 std::unique_ptr<syncer::AttachmentService> CreateAttachmentService( |
| 119 std::unique_ptr<syncer::AttachmentStoreForSync> attachment_store, | 119 std::unique_ptr<syncer::AttachmentStoreForSync> attachment_store, |
| 120 const syncer::UserShare& user_share, | 120 const syncer::UserShare& user_share, |
| 121 const std::string& store_birthday, | 121 const std::string& store_birthday, |
| 122 syncer::ModelType model_type, | 122 syncer::ModelType model_type, |
| 123 syncer::AttachmentService::Delegate* delegate) override { | 123 syncer::AttachmentService::Delegate* delegate) override { |
| 124 std::unique_ptr<MockAttachmentService> attachment_service( | 124 std::unique_ptr<MockAttachmentService> attachment_service( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 test_user_share_->user_share()); | 182 test_user_share_->user_share()); |
| 183 } | 183 } |
| 184 test_user_share_->encryption_handler()->Init(); | 184 test_user_share_->encryption_handler()->Init(); |
| 185 ConstructGenericChangeProcessor(type); | 185 ConstructGenericChangeProcessor(type); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void ConstructGenericChangeProcessor(syncer::ModelType type) { | 188 void ConstructGenericChangeProcessor(syncer::ModelType type) { |
| 189 std::unique_ptr<syncer::AttachmentStore> attachment_store = | 189 std::unique_ptr<syncer::AttachmentStore> attachment_store = |
| 190 syncer::AttachmentStore::CreateInMemoryStore(); | 190 syncer::AttachmentStore::CreateInMemoryStore(); |
| 191 change_processor_.reset(new GenericChangeProcessor( | 191 change_processor_.reset(new GenericChangeProcessor( |
| 192 type, &data_type_error_handler_, | 192 type, base::MakeUnique<syncer::DataTypeErrorHandlerMock>(), |
| 193 syncable_service_ptr_factory_.GetWeakPtr(), | 193 syncable_service_ptr_factory_.GetWeakPtr(), |
| 194 merge_result_ptr_factory_->GetWeakPtr(), test_user_share_->user_share(), | 194 merge_result_ptr_factory_->GetWeakPtr(), test_user_share_->user_share(), |
| 195 &sync_client_, attachment_store->CreateAttachmentStoreForSync())); | 195 &sync_client_, attachment_store->CreateAttachmentStoreForSync())); |
| 196 mock_attachment_service_ = sync_factory_.GetMockAttachmentService(); | 196 mock_attachment_service_ = sync_factory_.GetMockAttachmentService(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void BuildChildNodes(syncer::ModelType type, int n) { | 199 void BuildChildNodes(syncer::ModelType type, int n) { |
| 200 syncer::WriteTransaction trans(FROM_HERE, user_share()); | 200 syncer::WriteTransaction trans(FROM_HERE, user_share()); |
| 201 for (int i = 0; i < n; ++i) { | 201 for (int i = 0; i < n; ++i) { |
| 202 syncer::WriteNode node(&trans); | 202 syncer::WriteNode node(&trans); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 221 base::MessageLoopForUI loop_; | 221 base::MessageLoopForUI loop_; |
| 222 | 222 |
| 223 std::unique_ptr<syncer::SyncMergeResult> sync_merge_result_; | 223 std::unique_ptr<syncer::SyncMergeResult> sync_merge_result_; |
| 224 std::unique_ptr<base::WeakPtrFactory<syncer::SyncMergeResult>> | 224 std::unique_ptr<base::WeakPtrFactory<syncer::SyncMergeResult>> |
| 225 merge_result_ptr_factory_; | 225 merge_result_ptr_factory_; |
| 226 | 226 |
| 227 syncer::FakeSyncableService fake_syncable_service_; | 227 syncer::FakeSyncableService fake_syncable_service_; |
| 228 base::WeakPtrFactory<syncer::FakeSyncableService> | 228 base::WeakPtrFactory<syncer::FakeSyncableService> |
| 229 syncable_service_ptr_factory_; | 229 syncable_service_ptr_factory_; |
| 230 | 230 |
| 231 syncer::DataTypeErrorHandlerMock data_type_error_handler_; | |
| 232 std::unique_ptr<syncer::TestUserShare> test_user_share_; | 231 std::unique_ptr<syncer::TestUserShare> test_user_share_; |
| 233 MockAttachmentService* mock_attachment_service_; | 232 MockAttachmentService* mock_attachment_service_; |
| 234 FakeSyncClient sync_client_; | 233 FakeSyncClient sync_client_; |
| 235 MockSyncApiComponentFactory sync_factory_; | 234 MockSyncApiComponentFactory sync_factory_; |
| 236 | 235 |
| 237 std::unique_ptr<GenericChangeProcessor> change_processor_; | 236 std::unique_ptr<GenericChangeProcessor> change_processor_; |
| 238 }; | 237 }; |
| 239 | 238 |
| 240 // Similar to above, but focused on the method that implements sync/api | 239 // Similar to above, but focused on the method that implements sync/api |
| 241 // interfaces and is hence exposed to datatypes directly. | 240 // interfaces and is hence exposed to datatypes directly. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 change_processor()->GetAllSyncData(syncer::SESSIONS); | 533 change_processor()->GetAllSyncData(syncer::SESSIONS); |
| 535 ASSERT_EQ(sync_data.size(), 1U); | 534 ASSERT_EQ(sync_data.size(), 1U); |
| 536 ASSERT_EQ("session tag 2", | 535 ASSERT_EQ("session tag 2", |
| 537 sync_data[0].GetSpecifics().session().session_tag()); | 536 sync_data[0].GetSpecifics().session().session_tag()); |
| 538 EXPECT_FALSE(syncer::SyncDataRemote(sync_data[0]).GetClientTagHash().empty()); | 537 EXPECT_FALSE(syncer::SyncDataRemote(sync_data[0]).GetClientTagHash().empty()); |
| 539 } | 538 } |
| 540 | 539 |
| 541 } // namespace | 540 } // namespace |
| 542 | 541 |
| 543 } // namespace sync_driver | 542 } // namespace sync_driver |
| OLD | NEW |