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 "sync/api/sync_change.h" | 10 #include "sync/api/sync_change.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 local_service_(local_service), | 96 local_service_(local_service), |
97 merge_result_(merge_result), | 97 merge_result_(merge_result), |
98 share_handle_(user_share), | 98 share_handle_(user_share), |
99 attachment_service_(attachment_service.Pass()), | 99 attachment_service_(attachment_service.Pass()), |
100 attachment_service_weak_ptr_factory_(attachment_service_.get()), | 100 attachment_service_weak_ptr_factory_(attachment_service_.get()), |
101 attachment_service_proxy_( | 101 attachment_service_proxy_( |
102 base::MessageLoopProxy::current(), | 102 base::MessageLoopProxy::current(), |
103 attachment_service_weak_ptr_factory_.GetWeakPtr()) { | 103 attachment_service_weak_ptr_factory_.GetWeakPtr()) { |
104 DCHECK(CalledOnValidThread()); | 104 DCHECK(CalledOnValidThread()); |
105 DCHECK(attachment_service_); | 105 DCHECK(attachment_service_); |
| 106 attachment_service_->SetDelegate(this); |
106 } | 107 } |
107 | 108 |
108 GenericChangeProcessor::~GenericChangeProcessor() { | 109 GenericChangeProcessor::~GenericChangeProcessor() { |
109 DCHECK(CalledOnValidThread()); | 110 DCHECK(CalledOnValidThread()); |
| 111 attachment_service_->SetDelegate(NULL); |
110 } | 112 } |
111 | 113 |
112 void GenericChangeProcessor::ApplyChangesFromSyncModel( | 114 void GenericChangeProcessor::ApplyChangesFromSyncModel( |
113 const syncer::BaseTransaction* trans, | 115 const syncer::BaseTransaction* trans, |
114 int64 model_version, | 116 int64 model_version, |
115 const syncer::ImmutableChangeRecordList& changes) { | 117 const syncer::ImmutableChangeRecordList& changes) { |
116 DCHECK(CalledOnValidThread()); | 118 DCHECK(CalledOnValidThread()); |
117 DCHECK(syncer_changes_.empty()); | 119 DCHECK(syncer_changes_.empty()); |
118 for (syncer::ChangeRecordList::const_iterator it = | 120 for (syncer::ChangeRecordList::const_iterator it = |
119 changes.Get().begin(); it != changes.Get().end(); ++it) { | 121 changes.Get().begin(); it != changes.Get().end(); ++it) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 204 |
203 syncer::WriteTransaction trans(FROM_HERE, share_handle()); | 205 syncer::WriteTransaction trans(FROM_HERE, share_handle()); |
204 trans.SetDataTypeContext(type, refresh_status, context); | 206 trans.SetDataTypeContext(type, refresh_status, context); |
205 | 207 |
206 // TODO(zea): plumb a pointer to the PSS or SyncManagerImpl here so we can | 208 // TODO(zea): plumb a pointer to the PSS or SyncManagerImpl here so we can |
207 // trigger a datatype nudge if |refresh_status == REFRESH_NEEDED|. | 209 // trigger a datatype nudge if |refresh_status == REFRESH_NEEDED|. |
208 | 210 |
209 return syncer::SyncError(); | 211 return syncer::SyncError(); |
210 } | 212 } |
211 | 213 |
| 214 void GenericChangeProcessor::OnAttachmentUploaded( |
| 215 const syncer::AttachmentId& attachment_id) { |
| 216 syncer::WriteTransaction trans(FROM_HERE, share_handle()); |
| 217 trans.UpdateEntriesWithAttachmentId(attachment_id); |
| 218 } |
| 219 |
212 syncer::SyncError GenericChangeProcessor::GetAllSyncDataReturnError( | 220 syncer::SyncError GenericChangeProcessor::GetAllSyncDataReturnError( |
213 syncer::ModelType type, | 221 syncer::ModelType type, |
214 syncer::SyncDataList* current_sync_data) const { | 222 syncer::SyncDataList* current_sync_data) const { |
215 DCHECK(CalledOnValidThread()); | 223 DCHECK(CalledOnValidThread()); |
216 std::string type_name = syncer::ModelTypeToString(type); | 224 std::string type_name = syncer::ModelTypeToString(type); |
217 syncer::ReadTransaction trans(FROM_HERE, share_handle()); | 225 syncer::ReadTransaction trans(FROM_HERE, share_handle()); |
218 syncer::ReadNode root(&trans); | 226 syncer::ReadNode root(&trans); |
219 if (root.InitByTagLookup(syncer::ModelTypeToRootTag(type)) != | 227 if (root.InitByTagLookup(syncer::ModelTypeToRootTag(type)) != |
220 syncer::BaseNode::INIT_OK) { | 228 syncer::BaseNode::INIT_OK) { |
221 syncer::SyncError error(FROM_HERE, | 229 syncer::SyncError error(FROM_HERE, |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 void GenericChangeProcessor::StartImpl() { | 730 void GenericChangeProcessor::StartImpl() { |
723 DCHECK(CalledOnValidThread()); | 731 DCHECK(CalledOnValidThread()); |
724 } | 732 } |
725 | 733 |
726 syncer::UserShare* GenericChangeProcessor::share_handle() const { | 734 syncer::UserShare* GenericChangeProcessor::share_handle() const { |
727 DCHECK(CalledOnValidThread()); | 735 DCHECK(CalledOnValidThread()); |
728 return share_handle_; | 736 return share_handle_; |
729 } | 737 } |
730 | 738 |
731 } // namespace browser_sync | 739 } // namespace browser_sync |
OLD | NEW |