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 "components/sync_driver/sync_api_component_factory.h" | 10 #include "components/sync_driver/sync_api_component_factory.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 } // namespace | 88 } // namespace |
89 | 89 |
90 GenericChangeProcessor::GenericChangeProcessor( | 90 GenericChangeProcessor::GenericChangeProcessor( |
91 syncer::ModelType type, | 91 syncer::ModelType type, |
92 DataTypeErrorHandler* error_handler, | 92 DataTypeErrorHandler* error_handler, |
93 const base::WeakPtr<syncer::SyncableService>& local_service, | 93 const base::WeakPtr<syncer::SyncableService>& local_service, |
94 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, | 94 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, |
95 syncer::UserShare* user_share, | 95 syncer::UserShare* user_share, |
96 SyncApiComponentFactory* sync_factory, | 96 SyncApiComponentFactory* sync_factory, |
97 const scoped_refptr<syncer::AttachmentStore>& attachment_store) | 97 syncer::AttachmentStore* attachment_store) |
98 : ChangeProcessor(error_handler), | 98 : ChangeProcessor(error_handler), |
99 type_(type), | 99 type_(type), |
100 local_service_(local_service), | 100 local_service_(local_service), |
101 merge_result_(merge_result), | 101 merge_result_(merge_result), |
102 share_handle_(user_share), | 102 share_handle_(user_share), |
103 weak_ptr_factory_(this) { | 103 weak_ptr_factory_(this) { |
104 DCHECK(CalledOnValidThread()); | 104 DCHECK(CalledOnValidThread()); |
105 DCHECK_NE(type_, syncer::UNSPECIFIED); | 105 DCHECK_NE(type_, syncer::UNSPECIFIED); |
106 if (attachment_store.get()) { | 106 if (attachment_store) { |
| 107 scoped_ptr<syncer::AttachmentStore> attachment_store_for_sync = |
| 108 attachment_store->CreateAttachmentStoreForSync(); |
107 std::string store_birthday; | 109 std::string store_birthday; |
108 { | 110 { |
109 syncer::ReadTransaction trans(FROM_HERE, share_handle()); | 111 syncer::ReadTransaction trans(FROM_HERE, share_handle()); |
110 store_birthday = trans.GetStoreBirthday(); | 112 store_birthday = trans.GetStoreBirthday(); |
111 } | 113 } |
112 attachment_service_ = sync_factory->CreateAttachmentService( | 114 attachment_service_ = sync_factory->CreateAttachmentService( |
113 attachment_store, *user_share, store_birthday, type, this); | 115 attachment_store_for_sync.Pass(), *user_share, store_birthday, type, |
| 116 this); |
114 attachment_service_weak_ptr_factory_.reset( | 117 attachment_service_weak_ptr_factory_.reset( |
115 new base::WeakPtrFactory<syncer::AttachmentService>( | 118 new base::WeakPtrFactory<syncer::AttachmentService>( |
116 attachment_service_.get())); | 119 attachment_service_.get())); |
117 attachment_service_proxy_ = syncer::AttachmentServiceProxy( | 120 attachment_service_proxy_ = syncer::AttachmentServiceProxy( |
118 base::MessageLoopProxy::current(), | 121 base::MessageLoopProxy::current(), |
119 attachment_service_weak_ptr_factory_->GetWeakPtr()); | 122 attachment_service_weak_ptr_factory_->GetWeakPtr()); |
120 UploadAllAttachmentsNotOnServer(); | 123 UploadAllAttachmentsNotOnServer(); |
121 } else { | 124 } else { |
122 attachment_service_proxy_ = syncer::AttachmentServiceProxy( | 125 attachment_service_proxy_ = syncer::AttachmentServiceProxy( |
123 base::MessageLoopProxy::current(), | 126 base::MessageLoopProxy::current(), |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 } | 718 } |
716 } | 719 } |
717 | 720 |
718 scoped_ptr<syncer::AttachmentService> | 721 scoped_ptr<syncer::AttachmentService> |
719 GenericChangeProcessor::GetAttachmentService() const { | 722 GenericChangeProcessor::GetAttachmentService() const { |
720 return scoped_ptr<syncer::AttachmentService>( | 723 return scoped_ptr<syncer::AttachmentService>( |
721 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); | 724 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); |
722 } | 725 } |
723 | 726 |
724 } // namespace sync_driver | 727 } // namespace sync_driver |
OLD | NEW |