| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/sequenced_task_runner_handle.h" | 16 #include "base/threading/sequenced_task_runner_handle.h" |
| 17 #include "components/sync/base/unrecoverable_error_handler.h" | 17 #include "components/sync/base/unrecoverable_error_handler.h" |
| 18 #include "components/sync/driver/sync_api_component_factory.h" | 18 #include "components/sync/driver/sync_api_component_factory.h" |
| 19 #include "components/sync/driver/sync_client.h" |
| 19 #include "components/sync/model/local_change_observer.h" | 20 #include "components/sync/model/local_change_observer.h" |
| 20 #include "components/sync/model/sync_change.h" | 21 #include "components/sync/model/sync_change.h" |
| 21 #include "components/sync/model/sync_error.h" | 22 #include "components/sync/model/sync_error.h" |
| 22 #include "components/sync/model/syncable_service.h" | 23 #include "components/sync/model/syncable_service.h" |
| 23 #include "components/sync/syncable/base_node.h" | 24 #include "components/sync/syncable/base_node.h" |
| 24 #include "components/sync/syncable/change_record.h" | 25 #include "components/sync/syncable/change_record.h" |
| 25 #include "components/sync/syncable/entry.h" // TODO(tim): Bug 123674. | 26 #include "components/sync/syncable/entry.h" // TODO(tim): Bug 123674. |
| 26 #include "components/sync/syncable/read_node.h" | 27 #include "components/sync/syncable/read_node.h" |
| 27 #include "components/sync/syncable/read_transaction.h" | 28 #include "components/sync/syncable/read_transaction.h" |
| 28 #include "components/sync/syncable/write_node.h" | 29 #include "components/sync/syncable/write_node.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 104 } |
| 104 | 105 |
| 105 } // namespace | 106 } // namespace |
| 106 | 107 |
| 107 GenericChangeProcessor::GenericChangeProcessor( | 108 GenericChangeProcessor::GenericChangeProcessor( |
| 108 ModelType type, | 109 ModelType type, |
| 109 std::unique_ptr<DataTypeErrorHandler> error_handler, | 110 std::unique_ptr<DataTypeErrorHandler> error_handler, |
| 110 const base::WeakPtr<SyncableService>& local_service, | 111 const base::WeakPtr<SyncableService>& local_service, |
| 111 const base::WeakPtr<SyncMergeResult>& merge_result, | 112 const base::WeakPtr<SyncMergeResult>& merge_result, |
| 112 UserShare* user_share, | 113 UserShare* user_share, |
| 113 SyncApiComponentFactory* driver_factory, | 114 SyncClient* sync_client, |
| 114 std::unique_ptr<AttachmentStoreForSync> attachment_store) | 115 std::unique_ptr<AttachmentStoreForSync> attachment_store) |
| 115 : ChangeProcessor(std::move(error_handler)), | 116 : ChangeProcessor(std::move(error_handler)), |
| 116 type_(type), | 117 type_(type), |
| 117 local_service_(local_service), | 118 local_service_(local_service), |
| 118 merge_result_(merge_result), | 119 merge_result_(merge_result), |
| 119 share_handle_(user_share), | 120 share_handle_(user_share), |
| 120 weak_ptr_factory_(this) { | 121 weak_ptr_factory_(this) { |
| 121 DCHECK(sequence_checker_.CalledOnValidSequence()); | 122 DCHECK(sequence_checker_.CalledOnValidSequence()); |
| 122 DCHECK_NE(type_, UNSPECIFIED); | 123 DCHECK_NE(type_, UNSPECIFIED); |
| 123 if (attachment_store) { | 124 if (attachment_store) { |
| 124 std::string store_birthday; | 125 std::string store_birthday; |
| 125 { | 126 { |
| 126 ReadTransaction trans(FROM_HERE, share_handle()); | 127 ReadTransaction trans(FROM_HERE, share_handle()); |
| 127 store_birthday = trans.GetStoreBirthday(); | 128 store_birthday = trans.GetStoreBirthday(); |
| 128 } | 129 } |
| 129 attachment_service_ = driver_factory->CreateAttachmentService( | 130 attachment_service_ = |
| 130 std::move(attachment_store), *user_share, store_birthday, type, this); | 131 sync_client->GetSyncApiComponentFactory()->CreateAttachmentService( |
| 132 std::move(attachment_store), *user_share, store_birthday, type, |
| 133 this); |
| 131 attachment_service_weak_ptr_factory_ = | 134 attachment_service_weak_ptr_factory_ = |
| 132 base::MakeUnique<base::WeakPtrFactory<AttachmentService>>( | 135 base::MakeUnique<base::WeakPtrFactory<AttachmentService>>( |
| 133 attachment_service_.get()); | 136 attachment_service_.get()); |
| 134 attachment_service_proxy_ = AttachmentServiceProxy( | 137 attachment_service_proxy_ = AttachmentServiceProxy( |
| 135 base::SequencedTaskRunnerHandle::Get(), | 138 base::SequencedTaskRunnerHandle::Get(), |
| 136 attachment_service_weak_ptr_factory_->GetWeakPtr()); | 139 attachment_service_weak_ptr_factory_->GetWeakPtr()); |
| 137 UploadAllAttachmentsNotOnServer(); | 140 UploadAllAttachmentsNotOnServer(); |
| 138 } else { | 141 } else { |
| 139 attachment_service_proxy_ = | 142 attachment_service_proxy_ = |
| 140 AttachmentServiceProxy(base::SequencedTaskRunnerHandle::Get(), | 143 AttachmentServiceProxy(base::SequencedTaskRunnerHandle::Get(), |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 observer.OnLocalChange(current_entry, change); | 699 observer.OnLocalChange(current_entry, change); |
| 697 } | 700 } |
| 698 | 701 |
| 699 std::unique_ptr<AttachmentService> | 702 std::unique_ptr<AttachmentService> |
| 700 GenericChangeProcessor::GetAttachmentService() const { | 703 GenericChangeProcessor::GetAttachmentService() const { |
| 701 return std::unique_ptr<AttachmentService>( | 704 return std::unique_ptr<AttachmentService>( |
| 702 new AttachmentServiceProxy(attachment_service_proxy_)); | 705 new AttachmentServiceProxy(attachment_service_proxy_)); |
| 703 } | 706 } |
| 704 | 707 |
| 705 } // namespace syncer | 708 } // namespace syncer |
| OLD | NEW |