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" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
13 #include "components/sync_driver/data_type_error_handler.h" | 13 #include "components/sync_driver/data_type_error_handler.h" |
14 #include "sync/api/sync_change_processor.h" | 14 #include "sync/api/sync_change_processor.h" |
15 #include "sync/api/sync_data.h" | 15 #include "sync/api/sync_data.h" |
16 #include "sync/api/sync_error.h" | 16 #include "sync/api/sync_error.h" |
17 #include "sync/api/sync_error_factory.h" | 17 #include "sync/api/sync_error_factory.h" |
18 #include "sync/api/sync_merge_result.h" | 18 #include "sync/api/sync_merge_result.h" |
19 #include "sync/internal_api/public/engine/model_safe_worker.h" | 19 #include "sync/internal_api/public/engine/model_safe_worker.h" |
20 | 20 |
21 namespace syncer { | 21 namespace syncer { |
22 class SyncableService; | 22 class SyncableService; |
23 struct UserShare; | 23 struct UserShare; |
24 } // namespace syncer | 24 } // namespace syncer |
25 | 25 |
26 namespace browser_sync { | 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 SyncApiComponentFactory; |
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 // |
(...skipping 16 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 browser_sync::SyncApiComponentFactory* sync_factory, | 63 SyncApiComponentFactory* sync_factory, |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 scoped_refptr<base::MessageLoopProxy> backend_loop_; | 130 scoped_refptr<base::MessageLoopProxy> backend_loop_; |
131 | 131 |
132 // Used only on |backend_loop_|. | 132 // Used only on |backend_loop_|. |
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 browser_sync | 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 |