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 "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 class SyncableService; | 22 class SyncableService; |
23 struct UserShare; | 23 struct UserShare; |
24 } // namespace syncer | 24 } // namespace syncer |
25 | 25 |
26 namespace sync_driver { | 26 namespace sync_driver { |
27 | 27 |
28 class ChangeProcessor; | 28 class ChangeProcessor; |
29 class GenericChangeProcessor; | 29 class GenericChangeProcessor; |
30 class GenericChangeProcessorFactory; | 30 class GenericChangeProcessorFactory; |
31 class DataTypeErrorHandler; | 31 class DataTypeErrorHandler; |
32 class SyncApiComponentFactory; | 32 class SyncClient; |
33 | 33 |
34 // A ref-counted wrapper around a GenericChangeProcessor for use with datatypes | 34 // A ref-counted wrapper around a GenericChangeProcessor for use with datatypes |
35 // that don't live on the UI thread. | 35 // that don't live on the UI thread. |
36 // | 36 // |
37 // We need to make it refcounted as the ownership transfer from the | 37 // We need to make it refcounted as the ownership transfer from the |
38 // DataTypeController is dependent on threading, and hence racy. The | 38 // DataTypeController is dependent on threading, and hence racy. The |
39 // SharedChangeProcessor should be created on the UI thread, but should only be | 39 // SharedChangeProcessor should be created on the UI thread, but should only be |
40 // connected and used on the same thread as the datatype it interacts with. | 40 // connected and used on the same thread as the datatype it interacts with. |
41 // | 41 // |
42 // The only thread-safe method is Disconnect, which will disconnect from the | 42 // The only thread-safe method is Disconnect, which will disconnect from the |
(...skipping 10 matching lines...) Expand all Loading... |
53 public: | 53 public: |
54 // Create an uninitialized SharedChangeProcessor. | 54 // Create an uninitialized SharedChangeProcessor. |
55 SharedChangeProcessor(); | 55 SharedChangeProcessor(); |
56 | 56 |
57 // Connect to the Syncer and prepare to handle changes for |type|. Will | 57 // Connect to the Syncer and prepare to handle changes for |type|. Will |
58 // create and store a new GenericChangeProcessor and return a weak pointer to | 58 // create and store a new GenericChangeProcessor and return a weak pointer to |
59 // the syncer::SyncableService associated with |type|. | 59 // the syncer::SyncableService associated with |type|. |
60 // Note: If this SharedChangeProcessor has been disconnected, or the | 60 // Note: If this SharedChangeProcessor has been disconnected, or the |
61 // syncer::SyncableService was not alive, will return a null weak pointer. | 61 // syncer::SyncableService was not alive, will return a null weak pointer. |
62 virtual base::WeakPtr<syncer::SyncableService> Connect( | 62 virtual base::WeakPtr<syncer::SyncableService> Connect( |
63 SyncApiComponentFactory* sync_factory, | 63 SyncClient* sync_client, |
64 GenericChangeProcessorFactory* processor_factory, | 64 GenericChangeProcessorFactory* processor_factory, |
65 syncer::UserShare* user_share, | 65 syncer::UserShare* user_share, |
66 DataTypeErrorHandler* error_handler, | 66 DataTypeErrorHandler* error_handler, |
67 syncer::ModelType type, | 67 syncer::ModelType type, |
68 const base::WeakPtr<syncer::SyncMergeResult>& merge_result); | 68 const base::WeakPtr<syncer::SyncMergeResult>& merge_result); |
69 | 69 |
70 // Disconnects from the generic change processor. May be called from any | 70 // Disconnects from the generic change processor. May be called from any |
71 // thread. After this, all attempts to interact with the change processor by | 71 // thread. After this, all attempts to interact with the change processor by |
72 // |local_service_| are dropped and return errors. The syncer will be safe to | 72 // |local_service_| are dropped and return errors. The syncer will be safe to |
73 // shut down from the point of view of this datatype. | 73 // shut down from the point of view of this datatype. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 GenericChangeProcessor* generic_change_processor_; | 133 GenericChangeProcessor* generic_change_processor_; |
134 | 134 |
135 DataTypeErrorHandler* error_handler_; | 135 DataTypeErrorHandler* error_handler_; |
136 | 136 |
137 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); | 137 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); |
138 }; | 138 }; |
139 | 139 |
140 } // namespace sync_driver | 140 } // namespace sync_driver |
141 | 141 |
142 #endif // COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_ | 142 #endif // COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_ |
OLD | NEW |