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 "base/location.h" | 7 #include "base/location.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
11 #include "components/sync_driver/sync_api_component_factory.h" | 11 #include "components/sync_driver/sync_api_component_factory.h" |
| 12 #include "components/sync_driver/sync_client.h" |
12 #include "sync/api/sync_change.h" | 13 #include "sync/api/sync_change.h" |
13 #include "sync/api/sync_error.h" | 14 #include "sync/api/sync_error.h" |
14 #include "sync/api/syncable_service.h" | 15 #include "sync/api/syncable_service.h" |
15 #include "sync/internal_api/public/base_node.h" | 16 #include "sync/internal_api/public/base_node.h" |
16 #include "sync/internal_api/public/change_record.h" | 17 #include "sync/internal_api/public/change_record.h" |
17 #include "sync/internal_api/public/read_node.h" | 18 #include "sync/internal_api/public/read_node.h" |
18 #include "sync/internal_api/public/read_transaction.h" | 19 #include "sync/internal_api/public/read_transaction.h" |
19 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 20 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
20 #include "sync/internal_api/public/write_node.h" | 21 #include "sync/internal_api/public/write_node.h" |
21 #include "sync/internal_api/public/write_transaction.h" | 22 #include "sync/internal_api/public/write_transaction.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 88 } |
88 | 89 |
89 } // namespace | 90 } // namespace |
90 | 91 |
91 GenericChangeProcessor::GenericChangeProcessor( | 92 GenericChangeProcessor::GenericChangeProcessor( |
92 syncer::ModelType type, | 93 syncer::ModelType type, |
93 DataTypeErrorHandler* error_handler, | 94 DataTypeErrorHandler* error_handler, |
94 const base::WeakPtr<syncer::SyncableService>& local_service, | 95 const base::WeakPtr<syncer::SyncableService>& local_service, |
95 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, | 96 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, |
96 syncer::UserShare* user_share, | 97 syncer::UserShare* user_share, |
97 SyncApiComponentFactory* sync_factory, | 98 SyncClient* sync_client, |
98 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store) | 99 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store) |
99 : ChangeProcessor(error_handler), | 100 : ChangeProcessor(error_handler), |
100 type_(type), | 101 type_(type), |
101 local_service_(local_service), | 102 local_service_(local_service), |
102 merge_result_(merge_result), | 103 merge_result_(merge_result), |
103 share_handle_(user_share), | 104 share_handle_(user_share), |
104 weak_ptr_factory_(this) { | 105 weak_ptr_factory_(this) { |
105 DCHECK(CalledOnValidThread()); | 106 DCHECK(CalledOnValidThread()); |
106 DCHECK_NE(type_, syncer::UNSPECIFIED); | 107 DCHECK_NE(type_, syncer::UNSPECIFIED); |
107 if (attachment_store) { | 108 if (attachment_store) { |
108 std::string store_birthday; | 109 std::string store_birthday; |
109 { | 110 { |
110 syncer::ReadTransaction trans(FROM_HERE, share_handle()); | 111 syncer::ReadTransaction trans(FROM_HERE, share_handle()); |
111 store_birthday = trans.GetStoreBirthday(); | 112 store_birthday = trans.GetStoreBirthday(); |
112 } | 113 } |
113 attachment_service_ = sync_factory->CreateAttachmentService( | 114 attachment_service_ = |
114 attachment_store.Pass(), *user_share, store_birthday, type, this); | 115 sync_client->GetSyncApiComponentFactory()->CreateAttachmentService( |
| 116 attachment_store.Pass(), *user_share, store_birthday, type, this); |
115 attachment_service_weak_ptr_factory_.reset( | 117 attachment_service_weak_ptr_factory_.reset( |
116 new base::WeakPtrFactory<syncer::AttachmentService>( | 118 new base::WeakPtrFactory<syncer::AttachmentService>( |
117 attachment_service_.get())); | 119 attachment_service_.get())); |
118 attachment_service_proxy_ = syncer::AttachmentServiceProxy( | 120 attachment_service_proxy_ = syncer::AttachmentServiceProxy( |
119 base::ThreadTaskRunnerHandle::Get(), | 121 base::ThreadTaskRunnerHandle::Get(), |
120 attachment_service_weak_ptr_factory_->GetWeakPtr()); | 122 attachment_service_weak_ptr_factory_->GetWeakPtr()); |
121 UploadAllAttachmentsNotOnServer(); | 123 UploadAllAttachmentsNotOnServer(); |
122 } else { | 124 } else { |
123 attachment_service_proxy_ = syncer::AttachmentServiceProxy( | 125 attachment_service_proxy_ = syncer::AttachmentServiceProxy( |
124 base::ThreadTaskRunnerHandle::Get(), | 126 base::ThreadTaskRunnerHandle::Get(), |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 } | 701 } |
700 } | 702 } |
701 | 703 |
702 scoped_ptr<syncer::AttachmentService> | 704 scoped_ptr<syncer::AttachmentService> |
703 GenericChangeProcessor::GetAttachmentService() const { | 705 GenericChangeProcessor::GetAttachmentService() const { |
704 return scoped_ptr<syncer::AttachmentService>( | 706 return scoped_ptr<syncer::AttachmentService>( |
705 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); | 707 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); |
706 } | 708 } |
707 | 709 |
708 } // namespace sync_driver | 710 } // namespace sync_driver |
OLD | NEW |