| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "components/sync_driver/data_type_error_handler.h" | |
| 17 #include "sync/api/sync_change_processor.h" | 16 #include "sync/api/sync_change_processor.h" |
| 18 #include "sync/api/sync_data.h" | 17 #include "sync/api/sync_data.h" |
| 19 #include "sync/api/sync_error.h" | 18 #include "sync/api/sync_error.h" |
| 20 #include "sync/api/sync_error_factory.h" | 19 #include "sync/api/sync_error_factory.h" |
| 21 #include "sync/api/sync_merge_result.h" | 20 #include "sync/api/sync_merge_result.h" |
| 22 #include "sync/internal_api/public/engine/model_safe_worker.h" | 21 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 23 | 22 |
| 24 namespace syncer { | 23 namespace syncer { |
| 24 class DataTypeErrorHandler; |
| 25 class SyncableService; | 25 class SyncableService; |
| 26 struct UserShare; | 26 struct UserShare; |
| 27 } // namespace syncer | 27 } // namespace syncer |
| 28 | 28 |
| 29 namespace sync_driver { | 29 namespace sync_driver { |
| 30 | 30 |
| 31 class ChangeProcessor; | 31 class ChangeProcessor; |
| 32 class GenericChangeProcessor; | 32 class GenericChangeProcessor; |
| 33 class GenericChangeProcessorFactory; | 33 class GenericChangeProcessorFactory; |
| 34 class DataTypeErrorHandler; | |
| 35 class SyncClient; | 34 class SyncClient; |
| 36 | 35 |
| 37 // A ref-counted wrapper around a GenericChangeProcessor for use with datatypes | 36 // A ref-counted wrapper around a GenericChangeProcessor for use with datatypes |
| 38 // that don't live on the UI thread. | 37 // that don't live on the UI thread. |
| 39 // | 38 // |
| 40 // We need to make it refcounted as the ownership transfer from the | 39 // We need to make it refcounted as the ownership transfer from the |
| 41 // DataTypeController is dependent on threading, and hence racy. The | 40 // DataTypeController is dependent on threading, and hence racy. The |
| 42 // SharedChangeProcessor should be created on the UI thread, but should only be | 41 // SharedChangeProcessor should be created on the UI thread, but should only be |
| 43 // connected and used on the same thread as the datatype it interacts with. | 42 // connected and used on the same thread as the datatype it interacts with. |
| 44 // | 43 // |
| (...skipping 14 matching lines...) Expand all Loading... |
| 59 | 58 |
| 60 // Connect to the Syncer and prepare to handle changes for |type|. Will | 59 // Connect to the Syncer and prepare to handle changes for |type|. Will |
| 61 // create and store a new GenericChangeProcessor and return a weak pointer to | 60 // create and store a new GenericChangeProcessor and return a weak pointer to |
| 62 // the syncer::SyncableService associated with |type|. | 61 // the syncer::SyncableService associated with |type|. |
| 63 // Note: If this SharedChangeProcessor has been disconnected, or the | 62 // Note: If this SharedChangeProcessor has been disconnected, or the |
| 64 // syncer::SyncableService was not alive, will return a null weak pointer. | 63 // syncer::SyncableService was not alive, will return a null weak pointer. |
| 65 virtual base::WeakPtr<syncer::SyncableService> Connect( | 64 virtual base::WeakPtr<syncer::SyncableService> Connect( |
| 66 SyncClient* sync_client, | 65 SyncClient* sync_client, |
| 67 GenericChangeProcessorFactory* processor_factory, | 66 GenericChangeProcessorFactory* processor_factory, |
| 68 syncer::UserShare* user_share, | 67 syncer::UserShare* user_share, |
| 69 DataTypeErrorHandler* error_handler, | 68 syncer::DataTypeErrorHandler* error_handler, |
| 70 syncer::ModelType type, | 69 syncer::ModelType type, |
| 71 const base::WeakPtr<syncer::SyncMergeResult>& merge_result); | 70 const base::WeakPtr<syncer::SyncMergeResult>& merge_result); |
| 72 | 71 |
| 73 // Disconnects from the generic change processor. May be called from any | 72 // Disconnects from the generic change processor. May be called from any |
| 74 // thread. After this, all attempts to interact with the change processor by | 73 // thread. After this, all attempts to interact with the change processor by |
| 75 // |local_service_| are dropped and return errors. The syncer will be safe to | 74 // |local_service_| are dropped and return errors. The syncer will be safe to |
| 76 // shut down from the point of view of this datatype. | 75 // shut down from the point of view of this datatype. |
| 77 // Note: Once disconnected, you cannot reconnect without creating a new | 76 // Note: Once disconnected, you cannot reconnect without creating a new |
| 78 // SharedChangeProcessor. | 77 // SharedChangeProcessor. |
| 79 // Returns: true if we were previously succesfully connected, false if we were | 78 // Returns: true if we were previously succesfully connected, false if we were |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // destructed and/or disconnected on this loop, see ~SharedChangeProcessor. | 127 // destructed and/or disconnected on this loop, see ~SharedChangeProcessor. |
| 129 const scoped_refptr<const base::SingleThreadTaskRunner> frontend_task_runner_; | 128 const scoped_refptr<const base::SingleThreadTaskRunner> frontend_task_runner_; |
| 130 | 129 |
| 131 // The loop that all methods except the constructor, destructor, and | 130 // The loop that all methods except the constructor, destructor, and |
| 132 // Disconnect() should be called on. Set in Connect(). | 131 // Disconnect() should be called on. Set in Connect(). |
| 133 scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner_; | 132 scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner_; |
| 134 | 133 |
| 135 // Used only on |backend_loop_|. | 134 // Used only on |backend_loop_|. |
| 136 GenericChangeProcessor* generic_change_processor_; | 135 GenericChangeProcessor* generic_change_processor_; |
| 137 | 136 |
| 138 DataTypeErrorHandler* error_handler_; | 137 syncer::DataTypeErrorHandler* error_handler_; |
| 139 | 138 |
| 140 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); | 139 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); |
| 141 }; | 140 }; |
| 142 | 141 |
| 143 } // namespace sync_driver | 142 } // namespace sync_driver |
| 144 | 143 |
| 145 #endif // COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_ | 144 #endif // COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_ |
| OLD | NEW |