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

Side by Side Diff: components/sync_driver/shared_change_processor.h

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

Powered by Google App Engine
This is Rietveld 408576698