| 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 <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
| 18 #include "components/sync_driver/change_processor.h" | 18 #include "components/sync_driver/change_processor.h" |
| 19 #include "components/sync_driver/data_type_error_handler.h" | 19 #include "components/sync_driver/data_type_error_handler.h" |
| 20 #include "sync/api/attachments/attachment_store.h" | 20 #include "sync/api/attachments/attachment_store.h" |
| 21 #include "sync/api/sync_change_processor.h" | 21 #include "sync/api/sync_change_processor.h" |
| 22 #include "sync/api/sync_merge_result.h" | 22 #include "sync/api/sync_merge_result.h" |
| 23 #include "sync/internal_api/public/attachments/attachment_service.h" | 23 #include "sync/internal_api/public/attachments/attachment_service.h" |
| 24 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" | 24 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" |
| 25 | 25 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 53 // Create a change processor for |type| and connect it to the syncer. | 53 // Create a change processor for |type| and connect it to the syncer. |
| 54 // |attachment_store| can be NULL which means that datatype will not use sync | 54 // |attachment_store| can be NULL which means that datatype will not use sync |
| 55 // attachments. | 55 // attachments. |
| 56 GenericChangeProcessor( | 56 GenericChangeProcessor( |
| 57 syncer::ModelType type, | 57 syncer::ModelType type, |
| 58 DataTypeErrorHandler* error_handler, | 58 DataTypeErrorHandler* error_handler, |
| 59 const base::WeakPtr<syncer::SyncableService>& local_service, | 59 const base::WeakPtr<syncer::SyncableService>& local_service, |
| 60 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, | 60 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, |
| 61 syncer::UserShare* user_share, | 61 syncer::UserShare* user_share, |
| 62 SyncClient* sync_client, | 62 SyncClient* sync_client, |
| 63 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store); | 63 std::unique_ptr<syncer::AttachmentStoreForSync> attachment_store); |
| 64 ~GenericChangeProcessor() override; | 64 ~GenericChangeProcessor() override; |
| 65 | 65 |
| 66 // ChangeProcessor interface. | 66 // ChangeProcessor interface. |
| 67 // Build and store a list of all changes into |syncer_changes_|. | 67 // Build and store a list of all changes into |syncer_changes_|. |
| 68 void ApplyChangesFromSyncModel( | 68 void ApplyChangesFromSyncModel( |
| 69 const syncer::BaseTransaction* trans, | 69 const syncer::BaseTransaction* trans, |
| 70 int64_t version, | 70 int64_t version, |
| 71 const syncer::ImmutableChangeRecordList& changes) override; | 71 const syncer::ImmutableChangeRecordList& changes) override; |
| 72 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto | 72 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto |
| 73 // |local_service_| by way of its ProcessSyncChanges method. | 73 // |local_service_| by way of its ProcessSyncChanges method. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 98 | 98 |
| 99 // Returns the number of items for this type. | 99 // Returns the number of items for this type. |
| 100 virtual int GetSyncCount(); | 100 virtual int GetSyncCount(); |
| 101 | 101 |
| 102 // Generic versions of AssociatorInterface methods. Called by | 102 // Generic versions of AssociatorInterface methods. Called by |
| 103 // syncer::SyncableServiceAdapter or the DataTypeController. | 103 // syncer::SyncableServiceAdapter or the DataTypeController. |
| 104 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes); | 104 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes); |
| 105 virtual bool CryptoReadyIfNecessary(); | 105 virtual bool CryptoReadyIfNecessary(); |
| 106 | 106 |
| 107 // Gets AttachmentService proxy for datatype. | 107 // Gets AttachmentService proxy for datatype. |
| 108 scoped_ptr<syncer::AttachmentService> GetAttachmentService() const; | 108 std::unique_ptr<syncer::AttachmentService> GetAttachmentService() const; |
| 109 | 109 |
| 110 protected: | 110 protected: |
| 111 // ChangeProcessor interface. | 111 // ChangeProcessor interface. |
| 112 void StartImpl() override; // Does nothing. | 112 void StartImpl() override; // Does nothing. |
| 113 syncer::UserShare* share_handle() const override; | 113 syncer::UserShare* share_handle() const override; |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 // Logically part of ProcessSyncChanges. | 116 // Logically part of ProcessSyncChanges. |
| 117 // | 117 // |
| 118 // |new_attachments| is an output parameter containing newly added attachments | 118 // |new_attachments| is an output parameter containing newly added attachments |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to | 158 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to |
| 159 // be able to access the sync model before the change processor begins | 159 // be able to access the sync model before the change processor begins |
| 160 // listening to changes (the local_service_ will be interacting with us | 160 // listening to changes (the local_service_ will be interacting with us |
| 161 // when it starts up). As such we can't wait until Start(_) has been called, | 161 // when it starts up). As such we can't wait until Start(_) has been called, |
| 162 // and have to keep a local pointer to the user_share. | 162 // and have to keep a local pointer to the user_share. |
| 163 syncer::UserShare* const share_handle_; | 163 syncer::UserShare* const share_handle_; |
| 164 | 164 |
| 165 // AttachmentService for datatype. Can be NULL if datatype doesn't use | 165 // AttachmentService for datatype. Can be NULL if datatype doesn't use |
| 166 // attachments. | 166 // attachments. |
| 167 scoped_ptr<syncer::AttachmentService> attachment_service_; | 167 std::unique_ptr<syncer::AttachmentService> attachment_service_; |
| 168 | 168 |
| 169 // Must be destroyed before attachment_service_ to ensure WeakPtrs are | 169 // Must be destroyed before attachment_service_ to ensure WeakPtrs are |
| 170 // invalidated before attachment_service_ is destroyed. | 170 // invalidated before attachment_service_ is destroyed. |
| 171 // Can be NULL if attachment_service_ is NULL; | 171 // Can be NULL if attachment_service_ is NULL; |
| 172 scoped_ptr<base::WeakPtrFactory<syncer::AttachmentService> > | 172 std::unique_ptr<base::WeakPtrFactory<syncer::AttachmentService>> |
| 173 attachment_service_weak_ptr_factory_; | 173 attachment_service_weak_ptr_factory_; |
| 174 syncer::AttachmentServiceProxy attachment_service_proxy_; | 174 syncer::AttachmentServiceProxy attachment_service_proxy_; |
| 175 base::WeakPtrFactory<GenericChangeProcessor> weak_ptr_factory_; | 175 base::WeakPtrFactory<GenericChangeProcessor> weak_ptr_factory_; |
| 176 | 176 |
| 177 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); | 177 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 } // namespace sync_driver | 180 } // namespace sync_driver |
| 181 | 181 |
| 182 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ | 182 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ |
| OLD | NEW |