Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: components/sync/driver/shared_change_processor.h

Issue 2289143003: [Sync] Convert DTCs to be not RefCounted and NonThreadSafe. (Closed)
Patch Set: Rebase. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 9 #include <string>
9 10
10 #include "base/location.h" 11 #include "base/location.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "components/sync/api/data_type_error_handler.h"
16 #include "components/sync/api/sync_change_processor.h" 18 #include "components/sync/api/sync_change_processor.h"
17 #include "components/sync/api/sync_data.h" 19 #include "components/sync/api/sync_data.h"
18 #include "components/sync/api/sync_error.h" 20 #include "components/sync/api/sync_error.h"
19 #include "components/sync/api/sync_error_factory.h" 21 #include "components/sync/api/sync_error_factory.h"
20 #include "components/sync/api/sync_merge_result.h" 22 #include "components/sync/api/sync_merge_result.h"
21 #include "components/sync/driver/data_type_controller.h" 23 #include "components/sync/driver/data_type_controller.h"
22 #include "components/sync/engine/model_safe_worker.h" 24 #include "components/sync/engine/model_safe_worker.h"
23 25
24 namespace syncer { 26 namespace syncer {
25 class DataTypeErrorHandler;
26 class SyncableService; 27 class SyncableService;
27 struct UserShare; 28 struct UserShare;
28 } // namespace syncer 29 } // namespace syncer
29 30
30 namespace sync_driver { 31 namespace sync_driver {
31 32
32 class ChangeProcessor; 33 class ChangeProcessor;
33 class GenericChangeProcessor; 34 class GenericChangeProcessor;
34 class GenericChangeProcessorFactory; 35 class GenericChangeProcessorFactory;
35 class SyncClient; 36 class SyncClient;
(...skipping 20 matching lines...) Expand all
56 public: 57 public:
57 typedef base::Callback<void( 58 typedef base::Callback<void(
58 DataTypeController::ConfigureResult start_result, 59 DataTypeController::ConfigureResult start_result,
59 const syncer::SyncMergeResult& local_merge_result, 60 const syncer::SyncMergeResult& local_merge_result,
60 const syncer::SyncMergeResult& syncer_merge_result)> 61 const syncer::SyncMergeResult& syncer_merge_result)>
61 StartDoneCallback; 62 StartDoneCallback;
62 63
63 // Create an uninitialized SharedChangeProcessor. 64 // Create an uninitialized SharedChangeProcessor.
64 explicit SharedChangeProcessor(syncer::ModelType type); 65 explicit SharedChangeProcessor(syncer::ModelType type);
65 66
66 void StartAssociation(StartDoneCallback start_done, 67 void StartAssociation(
67 SyncClient* const sync_client, 68 StartDoneCallback start_done,
68 syncer::UserShare* user_share, 69 SyncClient* const sync_client,
69 syncer::DataTypeErrorHandler* error_handler); 70 syncer::UserShare* user_share,
71 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler);
70 72
71 // Connect to the Syncer and prepare to handle changes for |type|. Will 73 // Connect to the Syncer and prepare to handle changes for |type|. Will
72 // create and store a new GenericChangeProcessor and return a weak pointer to 74 // create and store a new GenericChangeProcessor and return a weak pointer to
73 // the syncer::SyncableService associated with |type|. 75 // the syncer::SyncableService associated with |type|.
74 // Note: If this SharedChangeProcessor has been disconnected, or the 76 // Note: If this SharedChangeProcessor has been disconnected, or the
75 // syncer::SyncableService was not alive, will return a null weak pointer. 77 // syncer::SyncableService was not alive, will return a null weak pointer.
76 virtual base::WeakPtr<syncer::SyncableService> Connect( 78 virtual base::WeakPtr<syncer::SyncableService> Connect(
77 SyncClient* sync_client, 79 SyncClient* sync_client,
78 GenericChangeProcessorFactory* processor_factory, 80 GenericChangeProcessorFactory* processor_factory,
79 syncer::UserShare* user_share, 81 syncer::UserShare* user_share,
80 syncer::DataTypeErrorHandler* error_handler, 82 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler,
81 const base::WeakPtr<syncer::SyncMergeResult>& merge_result); 83 const base::WeakPtr<syncer::SyncMergeResult>& merge_result);
82 84
83 // Disconnects from the generic change processor. May be called from any 85 // Disconnects from the generic change processor. May be called from any
84 // thread. After this, all attempts to interact with the change processor by 86 // thread. After this, all attempts to interact with the change processor by
85 // |local_service_| are dropped and return errors. The syncer will be safe to 87 // |local_service_| are dropped and return errors. The syncer will be safe to
86 // shut down from the point of view of this datatype. 88 // shut down from the point of view of this datatype.
87 // Note: Once disconnected, you cannot reconnect without creating a new 89 // Note: Once disconnected, you cannot reconnect without creating a new
88 // SharedChangeProcessor. 90 // SharedChangeProcessor.
89 // Returns: true if we were previously succesfully connected, false if we were 91 // Returns: true if we were previously succesfully connected, false if we were
90 // already disconnected. 92 // already disconnected.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // destructed and/or disconnected on this loop, see ~SharedChangeProcessor. 146 // destructed and/or disconnected on this loop, see ~SharedChangeProcessor.
145 const scoped_refptr<const base::SingleThreadTaskRunner> frontend_task_runner_; 147 const scoped_refptr<const base::SingleThreadTaskRunner> frontend_task_runner_;
146 148
147 // The loop that all methods except the constructor, destructor, and 149 // The loop that all methods except the constructor, destructor, and
148 // Disconnect() should be called on. Set in Connect(). 150 // Disconnect() should be called on. Set in Connect().
149 scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner_; 151 scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner_;
150 152
151 // Used only on |backend_loop_|. 153 // Used only on |backend_loop_|.
152 GenericChangeProcessor* generic_change_processor_; 154 GenericChangeProcessor* generic_change_processor_;
153 155
154 syncer::DataTypeErrorHandler* error_handler_; 156 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler_;
155 157
156 // The local service for this type. Only set if the DTC for the type uses 158 // The local service for this type. Only set if the DTC for the type uses
157 // SharedChangeProcessor::StartAssociation(). 159 // SharedChangeProcessor::StartAssociation().
158 base::WeakPtr<syncer::SyncableService> local_service_; 160 base::WeakPtr<syncer::SyncableService> local_service_;
159 161
160 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); 162 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor);
161 }; 163 };
162 164
163 } // namespace sync_driver 165 } // namespace sync_driver
164 166
165 #endif // COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_ 167 #endif // COMPONENTS_SYNC_DRIVER_SHARED_CHANGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « components/sync/driver/proxy_data_type_controller.cc ('k') | components/sync/driver/shared_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698