| 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 #ifndef COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ | 6 #define COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // |attachment_store| can be NULL which means that datatype will not use sync | 48 // |attachment_store| can be NULL which means that datatype will not use sync |
| 49 // attachments. | 49 // attachments. |
| 50 GenericChangeProcessor( | 50 GenericChangeProcessor( |
| 51 syncer::ModelType type, | 51 syncer::ModelType type, |
| 52 DataTypeErrorHandler* error_handler, | 52 DataTypeErrorHandler* error_handler, |
| 53 const base::WeakPtr<syncer::SyncableService>& local_service, | 53 const base::WeakPtr<syncer::SyncableService>& local_service, |
| 54 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, | 54 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, |
| 55 syncer::UserShare* user_share, | 55 syncer::UserShare* user_share, |
| 56 SyncApiComponentFactory* sync_factory, | 56 SyncApiComponentFactory* sync_factory, |
| 57 const scoped_refptr<syncer::AttachmentStore>& attachment_store); | 57 const scoped_refptr<syncer::AttachmentStore>& attachment_store); |
| 58 virtual ~GenericChangeProcessor(); | 58 ~GenericChangeProcessor() override; |
| 59 | 59 |
| 60 // ChangeProcessor interface. | 60 // ChangeProcessor interface. |
| 61 // Build and store a list of all changes into |syncer_changes_|. | 61 // Build and store a list of all changes into |syncer_changes_|. |
| 62 virtual void ApplyChangesFromSyncModel( | 62 void ApplyChangesFromSyncModel( |
| 63 const syncer::BaseTransaction* trans, | 63 const syncer::BaseTransaction* trans, |
| 64 int64 version, | 64 int64 version, |
| 65 const syncer::ImmutableChangeRecordList& changes) override; | 65 const syncer::ImmutableChangeRecordList& changes) override; |
| 66 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto | 66 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto |
| 67 // |local_service_| by way of its ProcessSyncChanges method. | 67 // |local_service_| by way of its ProcessSyncChanges method. |
| 68 virtual void CommitChangesFromSyncModel() override; | 68 void CommitChangesFromSyncModel() override; |
| 69 | 69 |
| 70 // syncer::SyncChangeProcessor implementation. | 70 // syncer::SyncChangeProcessor implementation. |
| 71 virtual syncer::SyncError ProcessSyncChanges( | 71 syncer::SyncError ProcessSyncChanges( |
| 72 const tracked_objects::Location& from_here, | 72 const tracked_objects::Location& from_here, |
| 73 const syncer::SyncChangeList& change_list) override; | 73 const syncer::SyncChangeList& change_list) override; |
| 74 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) | 74 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| 75 const override; | 75 syncer::SyncError UpdateDataTypeContext( |
| 76 virtual syncer::SyncError UpdateDataTypeContext( | |
| 77 syncer::ModelType type, | 76 syncer::ModelType type, |
| 78 syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status, | 77 syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status, |
| 79 const std::string& context) override; | 78 const std::string& context) override; |
| 80 | 79 |
| 81 // syncer::AttachmentService::Delegate implementation. | 80 // syncer::AttachmentService::Delegate implementation. |
| 82 virtual void OnAttachmentUploaded( | 81 void OnAttachmentUploaded(const syncer::AttachmentId& attachment_id) override; |
| 83 const syncer::AttachmentId& attachment_id) override; | |
| 84 | 82 |
| 85 // Similar to above, but returns a SyncError for use by direct clients | 83 // Similar to above, but returns a SyncError for use by direct clients |
| 86 // of GenericChangeProcessor that may need more error visibility. | 84 // of GenericChangeProcessor that may need more error visibility. |
| 87 virtual syncer::SyncError GetAllSyncDataReturnError( | 85 virtual syncer::SyncError GetAllSyncDataReturnError( |
| 88 syncer::SyncDataList* data) const; | 86 syncer::SyncDataList* data) const; |
| 89 | 87 |
| 90 // If a datatype context associated with this GenericChangeProcessor's type | 88 // If a datatype context associated with this GenericChangeProcessor's type |
| 91 // exists, fills |context| and returns true. Otheriwse, if there has not been | 89 // exists, fills |context| and returns true. Otheriwse, if there has not been |
| 92 // a context set, returns false. | 90 // a context set, returns false. |
| 93 virtual bool GetDataTypeContext(std::string* context) const; | 91 virtual bool GetDataTypeContext(std::string* context) const; |
| 94 | 92 |
| 95 // Returns the number of items for this type. | 93 // Returns the number of items for this type. |
| 96 virtual int GetSyncCount(); | 94 virtual int GetSyncCount(); |
| 97 | 95 |
| 98 // Generic versions of AssociatorInterface methods. Called by | 96 // Generic versions of AssociatorInterface methods. Called by |
| 99 // syncer::SyncableServiceAdapter or the DataTypeController. | 97 // syncer::SyncableServiceAdapter or the DataTypeController. |
| 100 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes); | 98 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes); |
| 101 virtual bool CryptoReadyIfNecessary(); | 99 virtual bool CryptoReadyIfNecessary(); |
| 102 | 100 |
| 103 protected: | 101 protected: |
| 104 // ChangeProcessor interface. | 102 // ChangeProcessor interface. |
| 105 virtual void StartImpl() override; // Does nothing. | 103 void StartImpl() override; // Does nothing. |
| 106 virtual syncer::UserShare* share_handle() const override; | 104 syncer::UserShare* share_handle() const override; |
| 107 | 105 |
| 108 private: | 106 private: |
| 109 // Logically part of ProcessSyncChanges. | 107 // Logically part of ProcessSyncChanges. |
| 110 // | 108 // |
| 111 // |new_attachments| is an output parameter containing newly added attachments | 109 // |new_attachments| is an output parameter containing newly added attachments |
| 112 // that need to be stored. This method will append to it. | 110 // that need to be stored. This method will append to it. |
| 113 syncer::SyncError HandleActionAdd(const syncer::SyncChange& change, | 111 syncer::SyncError HandleActionAdd(const syncer::SyncChange& change, |
| 114 const std::string& type_str, | 112 const std::string& type_str, |
| 115 const syncer::WriteTransaction& trans, | 113 const syncer::WriteTransaction& trans, |
| 116 syncer::WriteNode* sync_node, | 114 syncer::WriteNode* sync_node, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 scoped_ptr<syncer::AttachmentServiceProxy> attachment_service_proxy_; | 165 scoped_ptr<syncer::AttachmentServiceProxy> attachment_service_proxy_; |
| 168 | 166 |
| 169 base::WeakPtrFactory<GenericChangeProcessor> weak_ptr_factory_; | 167 base::WeakPtrFactory<GenericChangeProcessor> weak_ptr_factory_; |
| 170 | 168 |
| 171 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); | 169 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); |
| 172 }; | 170 }; |
| 173 | 171 |
| 174 } // namespace sync_driver | 172 } // namespace sync_driver |
| 175 | 173 |
| 176 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ | 174 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ |
| OLD | NEW |