| 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 "sync/api/sync_change.h" | 11 #include "sync/api/sync_change.h" |
| 11 #include "sync/api/sync_error.h" | 12 #include "sync/api/sync_error.h" |
| 12 #include "sync/api/syncable_service.h" | 13 #include "sync/api/syncable_service.h" |
| 13 #include "sync/internal_api/public/base_node.h" | 14 #include "sync/internal_api/public/base_node.h" |
| 14 #include "sync/internal_api/public/change_record.h" | 15 #include "sync/internal_api/public/change_record.h" |
| 15 #include "sync/internal_api/public/read_node.h" | 16 #include "sync/internal_api/public/read_node.h" |
| 16 #include "sync/internal_api/public/read_transaction.h" | 17 #include "sync/internal_api/public/read_transaction.h" |
| 17 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 18 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
| 18 #include "sync/internal_api/public/write_node.h" | 19 #include "sync/internal_api/public/write_node.h" |
| 19 #include "sync/internal_api/public/write_transaction.h" | 20 #include "sync/internal_api/public/write_transaction.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 attachment_service_proxy); | 85 attachment_service_proxy); |
| 85 } | 86 } |
| 86 | 87 |
| 87 } // namespace | 88 } // namespace |
| 88 | 89 |
| 89 GenericChangeProcessor::GenericChangeProcessor( | 90 GenericChangeProcessor::GenericChangeProcessor( |
| 90 DataTypeErrorHandler* error_handler, | 91 DataTypeErrorHandler* error_handler, |
| 91 const base::WeakPtr<syncer::SyncableService>& local_service, | 92 const base::WeakPtr<syncer::SyncableService>& local_service, |
| 92 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, | 93 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, |
| 93 syncer::UserShare* user_share, | 94 syncer::UserShare* user_share, |
| 94 scoped_ptr<syncer::AttachmentService> attachment_service) | 95 SyncApiComponentFactory* sync_factory) |
| 95 : ChangeProcessor(error_handler), | 96 : ChangeProcessor(error_handler), |
| 96 local_service_(local_service), | 97 local_service_(local_service), |
| 97 merge_result_(merge_result), | 98 merge_result_(merge_result), |
| 98 share_handle_(user_share), | 99 share_handle_(user_share), |
| 99 attachment_service_(attachment_service.Pass()), | 100 attachment_service_(sync_factory->CreateAttachmentService(this)), |
| 100 attachment_service_weak_ptr_factory_(attachment_service_.get()), | 101 attachment_service_weak_ptr_factory_(attachment_service_.get()), |
| 101 attachment_service_proxy_( | 102 attachment_service_proxy_( |
| 102 base::MessageLoopProxy::current(), | 103 base::MessageLoopProxy::current(), |
| 103 attachment_service_weak_ptr_factory_.GetWeakPtr()) { | 104 attachment_service_weak_ptr_factory_.GetWeakPtr()) { |
| 104 DCHECK(CalledOnValidThread()); | 105 DCHECK(CalledOnValidThread()); |
| 105 DCHECK(attachment_service_); | 106 DCHECK(attachment_service_); |
| 106 } | 107 } |
| 107 | 108 |
| 108 GenericChangeProcessor::~GenericChangeProcessor() { | 109 GenericChangeProcessor::~GenericChangeProcessor() { |
| 109 DCHECK(CalledOnValidThread()); | 110 DCHECK(CalledOnValidThread()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 203 |
| 203 syncer::WriteTransaction trans(FROM_HERE, share_handle()); | 204 syncer::WriteTransaction trans(FROM_HERE, share_handle()); |
| 204 trans.SetDataTypeContext(type, refresh_status, context); | 205 trans.SetDataTypeContext(type, refresh_status, context); |
| 205 | 206 |
| 206 // TODO(zea): plumb a pointer to the PSS or SyncManagerImpl here so we can | 207 // TODO(zea): plumb a pointer to the PSS or SyncManagerImpl here so we can |
| 207 // trigger a datatype nudge if |refresh_status == REFRESH_NEEDED|. | 208 // trigger a datatype nudge if |refresh_status == REFRESH_NEEDED|. |
| 208 | 209 |
| 209 return syncer::SyncError(); | 210 return syncer::SyncError(); |
| 210 } | 211 } |
| 211 | 212 |
| 213 void GenericChangeProcessor::OnAttachmentUploaded( |
| 214 const syncer::AttachmentId& attachment_id) { |
| 215 syncer::WriteTransaction trans(FROM_HERE, share_handle()); |
| 216 trans.UpdateEntriesWithAttachmentId(attachment_id); |
| 217 } |
| 218 |
| 212 syncer::SyncError GenericChangeProcessor::GetAllSyncDataReturnError( | 219 syncer::SyncError GenericChangeProcessor::GetAllSyncDataReturnError( |
| 213 syncer::ModelType type, | 220 syncer::ModelType type, |
| 214 syncer::SyncDataList* current_sync_data) const { | 221 syncer::SyncDataList* current_sync_data) const { |
| 215 DCHECK(CalledOnValidThread()); | 222 DCHECK(CalledOnValidThread()); |
| 216 std::string type_name = syncer::ModelTypeToString(type); | 223 std::string type_name = syncer::ModelTypeToString(type); |
| 217 syncer::ReadTransaction trans(FROM_HERE, share_handle()); | 224 syncer::ReadTransaction trans(FROM_HERE, share_handle()); |
| 218 syncer::ReadNode root(&trans); | 225 syncer::ReadNode root(&trans); |
| 219 if (root.InitByTagLookup(syncer::ModelTypeToRootTag(type)) != | 226 if (root.InitByTagLookup(syncer::ModelTypeToRootTag(type)) != |
| 220 syncer::BaseNode::INIT_OK) { | 227 syncer::BaseNode::INIT_OK) { |
| 221 syncer::SyncError error(FROM_HERE, | 228 syncer::SyncError error(FROM_HERE, |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 | 728 |
| 722 void GenericChangeProcessor::StartImpl() { | 729 void GenericChangeProcessor::StartImpl() { |
| 723 } | 730 } |
| 724 | 731 |
| 725 syncer::UserShare* GenericChangeProcessor::share_handle() const { | 732 syncer::UserShare* GenericChangeProcessor::share_handle() const { |
| 726 DCHECK(CalledOnValidThread()); | 733 DCHECK(CalledOnValidThread()); |
| 727 return share_handle_; | 734 return share_handle_; |
| 728 } | 735 } |
| 729 | 736 |
| 730 } // namespace browser_sync | 737 } // namespace browser_sync |
| OLD | NEW |