Chromium Code Reviews| 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_SHARED_CHANGE_PROCESSOR_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_ | 6 #define COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/sequenced_task_runner.h" | |
| 15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
|
gab
2016/12/20 20:11:29
rm?
fdoray
2016/12/20 20:34:39
Still needed for |frontend_task_runner_|.
| |
| 16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 17 #include "components/sync/driver/data_type_controller.h" | 18 #include "components/sync/driver/data_type_controller.h" |
| 18 #include "components/sync/engine/model_safe_worker.h" | 19 #include "components/sync/engine/model_safe_worker.h" |
| 19 #include "components/sync/model/data_type_error_handler.h" | 20 #include "components/sync/model/data_type_error_handler.h" |
| 20 #include "components/sync/model/sync_change_processor.h" | 21 #include "components/sync/model/sync_change_processor.h" |
| 21 #include "components/sync/model/sync_data.h" | 22 #include "components/sync/model/sync_data.h" |
| 22 #include "components/sync/model/sync_error.h" | 23 #include "components/sync/model/sync_error.h" |
| 23 #include "components/sync/model/sync_error_factory.h" | 24 #include "components/sync/model/sync_error_factory.h" |
| 24 #include "components/sync/model/sync_merge_result.h" | 25 #include "components/sync/model/sync_merge_result.h" |
| 25 | 26 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 // Note: If this SharedChangeProcessor has been disconnected, or the | 73 // Note: If this SharedChangeProcessor has been disconnected, or the |
| 73 // SyncableService was not alive, will return a null weak pointer. | 74 // SyncableService was not alive, will return a null weak pointer. |
| 74 virtual base::WeakPtr<SyncableService> Connect( | 75 virtual base::WeakPtr<SyncableService> Connect( |
| 75 SyncClient* sync_client, | 76 SyncClient* sync_client, |
| 76 GenericChangeProcessorFactory* processor_factory, | 77 GenericChangeProcessorFactory* processor_factory, |
| 77 UserShare* user_share, | 78 UserShare* user_share, |
| 78 std::unique_ptr<DataTypeErrorHandler> error_handler, | 79 std::unique_ptr<DataTypeErrorHandler> error_handler, |
| 79 const base::WeakPtr<SyncMergeResult>& merge_result); | 80 const base::WeakPtr<SyncMergeResult>& merge_result); |
| 80 | 81 |
| 81 // Disconnects from the generic change processor. May be called from any | 82 // Disconnects from the generic change processor. May be called from any |
| 82 // thread. After this, all attempts to interact with the change processor by | 83 // sequence. After this, all attempts to interact with the change processor by |
|
gab
2016/12/20 20:11:29
s/May be called from any thread./This method is th
fdoray
2016/12/20 20:34:39
Done.
| |
| 83 // |local_service_| are dropped and return errors. The syncer will be safe to | 84 // |local_service_| are dropped and return errors. The syncer will be safe to |
| 84 // shut down from the point of view of this datatype. | 85 // shut down from the point of view of this datatype. |
| 85 // Note: Once disconnected, you cannot reconnect without creating a new | 86 // Note: Once disconnected, you cannot reconnect without creating a new |
| 86 // SharedChangeProcessor. | 87 // SharedChangeProcessor. |
| 87 // Returns: true if we were previously succesfully connected, false if we were | 88 // Returns: true if we were previously succesfully connected, false if we were |
| 88 // already disconnected. | 89 // already disconnected. |
| 89 virtual bool Disconnect(); | 90 virtual bool Disconnect(); |
| 90 | 91 |
| 91 // GenericChangeProcessor stubs (with disconnect support). | 92 // GenericChangeProcessor stubs (with disconnect support). |
| 92 // Should only be called on the same thread the datatype resides. | 93 // Should only be called on the same sequence the datatype resides. |
| 93 virtual int GetSyncCount(); | 94 virtual int GetSyncCount(); |
| 94 virtual SyncError ProcessSyncChanges( | 95 virtual SyncError ProcessSyncChanges( |
| 95 const tracked_objects::Location& from_here, | 96 const tracked_objects::Location& from_here, |
| 96 const SyncChangeList& change_list); | 97 const SyncChangeList& change_list); |
| 97 virtual SyncDataList GetAllSyncData(ModelType type) const; | 98 virtual SyncDataList GetAllSyncData(ModelType type) const; |
| 98 virtual SyncError GetAllSyncDataReturnError(ModelType type, | 99 virtual SyncError GetAllSyncDataReturnError(ModelType type, |
| 99 SyncDataList* data) const; | 100 SyncDataList* data) const; |
| 100 virtual SyncError UpdateDataTypeContext( | 101 virtual SyncError UpdateDataTypeContext( |
| 101 ModelType type, | 102 ModelType type, |
| 102 SyncChangeProcessor::ContextRefreshStatus refresh_status, | 103 SyncChangeProcessor::ContextRefreshStatus refresh_status, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 mutable base::Lock monitor_lock_; | 137 mutable base::Lock monitor_lock_; |
| 137 bool disconnected_; | 138 bool disconnected_; |
| 138 | 139 |
| 139 // The sync datatype we process changes for. | 140 // The sync datatype we process changes for. |
| 140 const ModelType type_; | 141 const ModelType type_; |
| 141 | 142 |
| 142 // The frontend / UI MessageLoop this object is constructed on. May also be | 143 // The frontend / UI MessageLoop this object is constructed on. May also be |
| 143 // destructed and/or disconnected on this loop, see ~SharedChangeProcessor. | 144 // destructed and/or disconnected on this loop, see ~SharedChangeProcessor. |
| 144 const scoped_refptr<const base::SingleThreadTaskRunner> frontend_task_runner_; | 145 const scoped_refptr<const base::SingleThreadTaskRunner> frontend_task_runner_; |
| 145 | 146 |
| 146 // The loop that all methods except the constructor, destructor, and | 147 // The sequence that all methods except the constructor, destructor, and |
| 147 // Disconnect() should be called on. Set in Connect(). | 148 // Disconnect() should be called on. Set in Connect(). |
| 148 scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner_; | 149 scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; |
| 149 | 150 |
| 150 // Used only on |backend_loop_|. | 151 // Used only on |backend_task_runner_|. |
| 151 GenericChangeProcessor* generic_change_processor_; | 152 GenericChangeProcessor* generic_change_processor_; |
| 152 | 153 |
| 153 std::unique_ptr<DataTypeErrorHandler> error_handler_; | 154 std::unique_ptr<DataTypeErrorHandler> error_handler_; |
| 154 | 155 |
| 155 // The local service for this type. Only set if the DTC for the type uses | 156 // The local service for this type. Only set if the DTC for the type uses |
| 156 // SharedChangeProcessor::StartAssociation(). | 157 // SharedChangeProcessor::StartAssociation(). |
| 157 base::WeakPtr<SyncableService> local_service_; | 158 base::WeakPtr<SyncableService> local_service_; |
| 158 | 159 |
| 159 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); | 160 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); |
| 160 }; | 161 }; |
| 161 | 162 |
| 162 } // namespace syncer | 163 } // namespace syncer |
| 163 | 164 |
| 164 #endif // COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_ | 165 #endif // COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_ |
| OLD | NEW |