| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // which then get converted into SyncChange's and sent to the local service. | 45 // which then get converted into SyncChange's and sent to the local service. |
| 46 // | 46 // |
| 47 // As a rule, the GenericChangeProcessor is not thread safe, and should only | 47 // As a rule, the GenericChangeProcessor is not thread safe, and should only |
| 48 // be used on the same thread in which it was created. | 48 // be used on the same thread in which it was created. |
| 49 class GenericChangeProcessor : public ChangeProcessor, | 49 class GenericChangeProcessor : public ChangeProcessor, |
| 50 public SyncChangeProcessor, | 50 public SyncChangeProcessor, |
| 51 public AttachmentService::Delegate, | 51 public AttachmentService::Delegate, |
| 52 public base::NonThreadSafe { | 52 public base::NonThreadSafe { |
| 53 public: | 53 public: |
| 54 // Create a change processor for |type| and connect it to the syncer. | 54 // Create a change processor for |type| and connect it to the syncer. |
| 55 // |attachment_store| can be NULL which means that datatype will not use sync | 55 // |attachment_store| can be null which means that datatype will not use sync |
| 56 // attachments. | 56 // attachments. |
| 57 GenericChangeProcessor( | 57 GenericChangeProcessor( |
| 58 ModelType type, | 58 ModelType type, |
| 59 std::unique_ptr<DataTypeErrorHandler> error_handler, | 59 std::unique_ptr<DataTypeErrorHandler> error_handler, |
| 60 const base::WeakPtr<SyncableService>& local_service, | 60 const base::WeakPtr<SyncableService>& local_service, |
| 61 const base::WeakPtr<SyncMergeResult>& merge_result, | 61 const base::WeakPtr<SyncMergeResult>& merge_result, |
| 62 UserShare* user_share, | 62 UserShare* user_share, |
| 63 SyncClient* sync_client, | 63 SyncClient* sync_client, |
| 64 std::unique_ptr<AttachmentStoreForSync> attachment_store); | 64 std::unique_ptr<AttachmentStoreForSync> attachment_store); |
| 65 ~GenericChangeProcessor() override; | 65 ~GenericChangeProcessor() override; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel. | 165 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel. |
| 166 SyncChangeList syncer_changes_; | 166 SyncChangeList syncer_changes_; |
| 167 | 167 |
| 168 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to | 168 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to |
| 169 // be able to access the sync model before the change processor begins | 169 // be able to access the sync model before the change processor begins |
| 170 // listening to changes (the local_service_ will be interacting with us | 170 // listening to changes (the local_service_ will be interacting with us |
| 171 // when it starts up). As such we can't wait until Start(_) has been called, | 171 // when it starts up). As such we can't wait until Start(_) has been called, |
| 172 // and have to keep a local pointer to the user_share. | 172 // and have to keep a local pointer to the user_share. |
| 173 UserShare* const share_handle_; | 173 UserShare* const share_handle_; |
| 174 | 174 |
| 175 // AttachmentService for datatype. Can be NULL if datatype doesn't use | 175 // AttachmentService for datatype. Can be null if datatype doesn't use |
| 176 // attachments. | 176 // attachments. |
| 177 std::unique_ptr<AttachmentService> attachment_service_; | 177 std::unique_ptr<AttachmentService> attachment_service_; |
| 178 | 178 |
| 179 // List of observers that want to be notified of local changes being written. | 179 // List of observers that want to be notified of local changes being written. |
| 180 base::ObserverList<LocalChangeObserver> local_change_observers_; | 180 base::ObserverList<LocalChangeObserver> local_change_observers_; |
| 181 | 181 |
| 182 // Must be destroyed before attachment_service_ to ensure WeakPtrs are | 182 // Must be destroyed before attachment_service_ to ensure WeakPtrs are |
| 183 // invalidated before attachment_service_ is destroyed. | 183 // invalidated before attachment_service_ is destroyed. |
| 184 // Can be NULL if attachment_service_ is NULL; | 184 // Can be null if attachment_service_ is null; |
| 185 std::unique_ptr<base::WeakPtrFactory<AttachmentService>> | 185 std::unique_ptr<base::WeakPtrFactory<AttachmentService>> |
| 186 attachment_service_weak_ptr_factory_; | 186 attachment_service_weak_ptr_factory_; |
| 187 AttachmentServiceProxy attachment_service_proxy_; | 187 AttachmentServiceProxy attachment_service_proxy_; |
| 188 base::WeakPtrFactory<GenericChangeProcessor> weak_ptr_factory_; | 188 base::WeakPtrFactory<GenericChangeProcessor> weak_ptr_factory_; |
| 189 | 189 |
| 190 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); | 190 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 } // namespace syncer | 193 } // namespace syncer |
| 194 | 194 |
| 195 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ | 195 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ |
| OLD | NEW |