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 #include "components/sync/driver/shared_change_processor.h" | 5 #include "components/sync/driver/shared_change_processor.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "components/sync/api/sync_change.h" | 10 #include "components/sync/api/sync_change.h" |
11 #include "components/sync/api/syncable_service.h" | 11 #include "components/sync/api/syncable_service.h" |
12 #include "components/sync/base/data_type_histogram.h" | 12 #include "components/sync/base/data_type_histogram.h" |
13 #include "components/sync/driver/generic_change_processor.h" | 13 #include "components/sync/driver/generic_change_processor.h" |
14 #include "components/sync/driver/generic_change_processor_factory.h" | 14 #include "components/sync/driver/generic_change_processor_factory.h" |
15 #include "components/sync/driver/shared_change_processor_ref.h" | 15 #include "components/sync/driver/shared_change_processor_ref.h" |
16 #include "components/sync/driver/sync_client.h" | 16 #include "components/sync/driver/sync_client.h" |
17 | 17 |
18 using base::AutoLock; | 18 using base::AutoLock; |
19 | 19 |
20 namespace syncer { | 20 namespace syncer { |
21 class AttachmentService; | 21 class AttachmentService; |
22 } // namespace syncer | 22 } // namespace syncer |
23 | 23 |
24 namespace sync_driver { | 24 namespace syncer { |
25 | 25 |
26 SharedChangeProcessor::SharedChangeProcessor(syncer::ModelType type) | 26 SharedChangeProcessor::SharedChangeProcessor(ModelType type) |
27 : disconnected_(false), | 27 : disconnected_(false), |
28 type_(type), | 28 type_(type), |
29 frontend_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 29 frontend_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
30 generic_change_processor_(NULL) { | 30 generic_change_processor_(NULL) { |
31 DCHECK_NE(type_, syncer::UNSPECIFIED); | 31 DCHECK_NE(type_, UNSPECIFIED); |
32 } | 32 } |
33 | 33 |
34 SharedChangeProcessor::~SharedChangeProcessor() { | 34 SharedChangeProcessor::~SharedChangeProcessor() { |
35 // We can either be deleted when the DTC is destroyed (on UI | 35 // We can either be deleted when the DTC is destroyed (on UI |
36 // thread), or when the syncer::SyncableService stops syncing (datatype | 36 // thread), or when the SyncableService stops syncing (datatype |
37 // thread). |generic_change_processor_|, if non-NULL, must be | 37 // thread). |generic_change_processor_|, if non-NULL, must be |
38 // deleted on |backend_loop_|. | 38 // deleted on |backend_loop_|. |
39 if (backend_task_runner_.get()) { | 39 if (backend_task_runner_.get()) { |
40 if (backend_task_runner_->BelongsToCurrentThread()) { | 40 if (backend_task_runner_->BelongsToCurrentThread()) { |
41 delete generic_change_processor_; | 41 delete generic_change_processor_; |
42 } else { | 42 } else { |
43 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 43 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
44 if (!backend_task_runner_->DeleteSoon(FROM_HERE, | 44 if (!backend_task_runner_->DeleteSoon(FROM_HERE, |
45 generic_change_processor_)) { | 45 generic_change_processor_)) { |
46 NOTREACHED(); | 46 NOTREACHED(); |
47 } | 47 } |
48 } | 48 } |
49 } else { | 49 } else { |
50 DCHECK(!generic_change_processor_); | 50 DCHECK(!generic_change_processor_); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 void SharedChangeProcessor::StartAssociation( | 54 void SharedChangeProcessor::StartAssociation( |
55 StartDoneCallback start_done, | 55 StartDoneCallback start_done, |
56 SyncClient* const sync_client, | 56 SyncClient* const sync_client, |
57 syncer::UserShare* user_share, | 57 UserShare* user_share, |
58 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler) { | 58 std::unique_ptr<DataTypeErrorHandler> error_handler) { |
59 DCHECK(user_share); | 59 DCHECK(user_share); |
60 syncer::SyncMergeResult local_merge_result(type_); | 60 SyncMergeResult local_merge_result(type_); |
61 syncer::SyncMergeResult syncer_merge_result(type_); | 61 SyncMergeResult syncer_merge_result(type_); |
62 base::WeakPtrFactory<syncer::SyncMergeResult> weak_ptr_factory( | 62 base::WeakPtrFactory<SyncMergeResult> weak_ptr_factory(&syncer_merge_result); |
63 &syncer_merge_result); | |
64 | 63 |
65 // Connect |shared_change_processor| to the syncer and get the | 64 // Connect |shared_change_processor| to the syncer and get the |
66 // syncer::SyncableService associated with type_. | 65 // SyncableService associated with type_. |
67 // Note that it's possible the shared_change_processor has already been | 66 // Note that it's possible the shared_change_processor has already been |
68 // disconnected at this point, so all our accesses to the syncer from this | 67 // disconnected at this point, so all our accesses to the syncer from this |
69 // point on are through it. | 68 // point on are through it. |
70 GenericChangeProcessorFactory factory; | 69 GenericChangeProcessorFactory factory; |
71 local_service_ = | 70 local_service_ = |
72 Connect(sync_client, &factory, user_share, std::move(error_handler), | 71 Connect(sync_client, &factory, user_share, std::move(error_handler), |
73 weak_ptr_factory.GetWeakPtr()); | 72 weak_ptr_factory.GetWeakPtr()); |
74 if (!local_service_.get()) { | 73 if (!local_service_.get()) { |
75 syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, | 74 SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, |
76 "Failed to connect to syncer.", type_); | 75 "Failed to connect to syncer.", type_); |
77 local_merge_result.set_error(error); | 76 local_merge_result.set_error(error); |
78 start_done.Run(DataTypeController::ASSOCIATION_FAILED, local_merge_result, | 77 start_done.Run(DataTypeController::ASSOCIATION_FAILED, local_merge_result, |
79 syncer_merge_result); | 78 syncer_merge_result); |
80 return; | 79 return; |
81 } | 80 } |
82 | 81 |
83 if (!CryptoReadyIfNecessary()) { | 82 if (!CryptoReadyIfNecessary()) { |
84 syncer::SyncError error(FROM_HERE, syncer::SyncError::CRYPTO_ERROR, "", | 83 SyncError error(FROM_HERE, SyncError::CRYPTO_ERROR, "", type_); |
85 type_); | |
86 local_merge_result.set_error(error); | 84 local_merge_result.set_error(error); |
87 start_done.Run(DataTypeController::NEEDS_CRYPTO, local_merge_result, | 85 start_done.Run(DataTypeController::NEEDS_CRYPTO, local_merge_result, |
88 syncer_merge_result); | 86 syncer_merge_result); |
89 return; | 87 return; |
90 } | 88 } |
91 | 89 |
92 bool sync_has_nodes = false; | 90 bool sync_has_nodes = false; |
93 if (!SyncModelHasUserCreatedNodes(&sync_has_nodes)) { | 91 if (!SyncModelHasUserCreatedNodes(&sync_has_nodes)) { |
94 syncer::SyncError error(FROM_HERE, syncer::SyncError::UNRECOVERABLE_ERROR, | 92 SyncError error(FROM_HERE, SyncError::UNRECOVERABLE_ERROR, |
95 "Failed to load sync nodes", type_); | 93 "Failed to load sync nodes", type_); |
96 local_merge_result.set_error(error); | 94 local_merge_result.set_error(error); |
97 start_done.Run(DataTypeController::UNRECOVERABLE_ERROR, local_merge_result, | 95 start_done.Run(DataTypeController::UNRECOVERABLE_ERROR, local_merge_result, |
98 syncer_merge_result); | 96 syncer_merge_result); |
99 return; | 97 return; |
100 } | 98 } |
101 | 99 |
102 // Scope for |initial_sync_data| which might be expensive, so we don't want | 100 // Scope for |initial_sync_data| which might be expensive, so we don't want |
103 // to keep it in memory longer than necessary. | 101 // to keep it in memory longer than necessary. |
104 { | 102 { |
105 syncer::SyncDataList initial_sync_data; | 103 SyncDataList initial_sync_data; |
106 | 104 |
107 base::TimeTicks start_time = base::TimeTicks::Now(); | 105 base::TimeTicks start_time = base::TimeTicks::Now(); |
108 syncer::SyncError error = | 106 SyncError error = GetAllSyncDataReturnError(type_, &initial_sync_data); |
109 GetAllSyncDataReturnError(type_, &initial_sync_data); | |
110 if (error.IsSet()) { | 107 if (error.IsSet()) { |
111 local_merge_result.set_error(error); | 108 local_merge_result.set_error(error); |
112 start_done.Run(DataTypeController::ASSOCIATION_FAILED, local_merge_result, | 109 start_done.Run(DataTypeController::ASSOCIATION_FAILED, local_merge_result, |
113 syncer_merge_result); | 110 syncer_merge_result); |
114 return; | 111 return; |
115 } | 112 } |
116 | 113 |
117 std::string datatype_context; | 114 std::string datatype_context; |
118 if (GetDataTypeContext(&datatype_context)) { | 115 if (GetDataTypeContext(&datatype_context)) { |
119 local_service_->UpdateDataTypeContext( | 116 local_service_->UpdateDataTypeContext( |
120 type_, syncer::SyncChangeProcessor::NO_REFRESH, datatype_context); | 117 type_, SyncChangeProcessor::NO_REFRESH, datatype_context); |
121 } | 118 } |
122 | 119 |
123 syncer_merge_result.set_num_items_before_association( | 120 syncer_merge_result.set_num_items_before_association( |
124 initial_sync_data.size()); | 121 initial_sync_data.size()); |
125 // Passes a reference to |shared_change_processor|. | 122 // Passes a reference to |shared_change_processor|. |
126 local_merge_result = local_service_->MergeDataAndStartSyncing( | 123 local_merge_result = local_service_->MergeDataAndStartSyncing( |
127 type_, initial_sync_data, std::unique_ptr<syncer::SyncChangeProcessor>( | 124 type_, initial_sync_data, std::unique_ptr<SyncChangeProcessor>( |
128 new SharedChangeProcessorRef(this)), | 125 new SharedChangeProcessorRef(this)), |
129 std::unique_ptr<syncer::SyncErrorFactory>( | 126 std::unique_ptr<SyncErrorFactory>(new SharedChangeProcessorRef(this))); |
130 new SharedChangeProcessorRef(this))); | |
131 RecordAssociationTime(base::TimeTicks::Now() - start_time); | 127 RecordAssociationTime(base::TimeTicks::Now() - start_time); |
132 if (local_merge_result.error().IsSet()) { | 128 if (local_merge_result.error().IsSet()) { |
133 start_done.Run(DataTypeController::ASSOCIATION_FAILED, local_merge_result, | 129 start_done.Run(DataTypeController::ASSOCIATION_FAILED, local_merge_result, |
134 syncer_merge_result); | 130 syncer_merge_result); |
135 return; | 131 return; |
136 } | 132 } |
137 } | 133 } |
138 | 134 |
139 syncer_merge_result.set_num_items_after_association(GetSyncCount()); | 135 syncer_merge_result.set_num_items_after_association(GetSyncCount()); |
140 | 136 |
141 start_done.Run(!sync_has_nodes ? DataTypeController::OK_FIRST_RUN | 137 start_done.Run(!sync_has_nodes ? DataTypeController::OK_FIRST_RUN |
142 : DataTypeController::OK, | 138 : DataTypeController::OK, |
143 local_merge_result, syncer_merge_result); | 139 local_merge_result, syncer_merge_result); |
144 } | 140 } |
145 | 141 |
146 base::WeakPtr<syncer::SyncableService> SharedChangeProcessor::Connect( | 142 base::WeakPtr<SyncableService> SharedChangeProcessor::Connect( |
147 SyncClient* sync_client, | 143 SyncClient* sync_client, |
148 GenericChangeProcessorFactory* processor_factory, | 144 GenericChangeProcessorFactory* processor_factory, |
149 syncer::UserShare* user_share, | 145 UserShare* user_share, |
150 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler, | 146 std::unique_ptr<DataTypeErrorHandler> error_handler, |
151 const base::WeakPtr<syncer::SyncMergeResult>& merge_result) { | 147 const base::WeakPtr<SyncMergeResult>& merge_result) { |
152 DCHECK(sync_client); | 148 DCHECK(sync_client); |
153 DCHECK(error_handler); | 149 DCHECK(error_handler); |
154 backend_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 150 backend_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
155 AutoLock lock(monitor_lock_); | 151 AutoLock lock(monitor_lock_); |
156 if (disconnected_) | 152 if (disconnected_) |
157 return base::WeakPtr<syncer::SyncableService>(); | 153 return base::WeakPtr<SyncableService>(); |
158 error_handler_ = std::move(error_handler); | 154 error_handler_ = std::move(error_handler); |
159 base::WeakPtr<syncer::SyncableService> local_service = | 155 base::WeakPtr<SyncableService> local_service = |
160 sync_client->GetSyncableServiceForType(type_); | 156 sync_client->GetSyncableServiceForType(type_); |
161 if (!local_service.get()) { | 157 if (!local_service.get()) { |
162 LOG(WARNING) << "SyncableService destroyed before DTC was stopped."; | 158 LOG(WARNING) << "SyncableService destroyed before DTC was stopped."; |
163 disconnected_ = true; | 159 disconnected_ = true; |
164 return base::WeakPtr<syncer::SyncableService>(); | 160 return base::WeakPtr<SyncableService>(); |
165 } | 161 } |
166 | 162 |
167 generic_change_processor_ = processor_factory | 163 generic_change_processor_ = processor_factory |
168 ->CreateGenericChangeProcessor( | 164 ->CreateGenericChangeProcessor( |
169 type_, user_share, error_handler_->Copy(), | 165 type_, user_share, error_handler_->Copy(), |
170 local_service, merge_result, sync_client) | 166 local_service, merge_result, sync_client) |
171 .release(); | 167 .release(); |
172 // If available, propagate attachment service to the syncable service. | 168 // If available, propagate attachment service to the syncable service. |
173 std::unique_ptr<syncer::AttachmentService> attachment_service = | 169 std::unique_ptr<AttachmentService> attachment_service = |
174 generic_change_processor_->GetAttachmentService(); | 170 generic_change_processor_->GetAttachmentService(); |
175 if (attachment_service) { | 171 if (attachment_service) { |
176 local_service->SetAttachmentService(std::move(attachment_service)); | 172 local_service->SetAttachmentService(std::move(attachment_service)); |
177 } | 173 } |
178 return local_service; | 174 return local_service; |
179 } | 175 } |
180 | 176 |
181 bool SharedChangeProcessor::Disconnect() { | 177 bool SharedChangeProcessor::Disconnect() { |
182 // May be called from any thread. | 178 // May be called from any thread. |
183 DVLOG(1) << "Disconnecting change processor."; | 179 DVLOG(1) << "Disconnecting change processor."; |
(...skipping 12 matching lines...) Expand all Loading... |
196 DCHECK(backend_task_runner_.get()); | 192 DCHECK(backend_task_runner_.get()); |
197 DCHECK(backend_task_runner_->BelongsToCurrentThread()); | 193 DCHECK(backend_task_runner_->BelongsToCurrentThread()); |
198 AutoLock lock(monitor_lock_); | 194 AutoLock lock(monitor_lock_); |
199 if (disconnected_) { | 195 if (disconnected_) { |
200 LOG(ERROR) << "Change processor disconnected."; | 196 LOG(ERROR) << "Change processor disconnected."; |
201 return 0; | 197 return 0; |
202 } | 198 } |
203 return generic_change_processor_->GetSyncCount(); | 199 return generic_change_processor_->GetSyncCount(); |
204 } | 200 } |
205 | 201 |
206 syncer::SyncError SharedChangeProcessor::ProcessSyncChanges( | 202 SyncError SharedChangeProcessor::ProcessSyncChanges( |
207 const tracked_objects::Location& from_here, | 203 const tracked_objects::Location& from_here, |
208 const syncer::SyncChangeList& list_of_changes) { | 204 const SyncChangeList& list_of_changes) { |
209 DCHECK(backend_task_runner_.get()); | 205 DCHECK(backend_task_runner_.get()); |
210 DCHECK(backend_task_runner_->BelongsToCurrentThread()); | 206 DCHECK(backend_task_runner_->BelongsToCurrentThread()); |
211 AutoLock lock(monitor_lock_); | 207 AutoLock lock(monitor_lock_); |
212 if (disconnected_) { | 208 if (disconnected_) { |
213 // The DTC that disconnects us must ensure it posts a StopSyncing task. | 209 // The DTC that disconnects us must ensure it posts a StopSyncing task. |
214 // If we reach this, it means it just hasn't executed yet. | 210 // If we reach this, it means it just hasn't executed yet. |
215 syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, | 211 SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, |
216 "Change processor disconnected.", type_); | 212 "Change processor disconnected.", type_); |
217 return error; | 213 return error; |
218 } | 214 } |
219 return generic_change_processor_->ProcessSyncChanges(from_here, | 215 return generic_change_processor_->ProcessSyncChanges(from_here, |
220 list_of_changes); | 216 list_of_changes); |
221 } | 217 } |
222 | 218 |
223 syncer::SyncDataList SharedChangeProcessor::GetAllSyncData( | 219 SyncDataList SharedChangeProcessor::GetAllSyncData(ModelType type) const { |
224 syncer::ModelType type) const { | 220 SyncDataList data; |
225 syncer::SyncDataList data; | |
226 GetAllSyncDataReturnError(type, &data); // Handles the disconnect case. | 221 GetAllSyncDataReturnError(type, &data); // Handles the disconnect case. |
227 return data; | 222 return data; |
228 } | 223 } |
229 | 224 |
230 syncer::SyncError SharedChangeProcessor::GetAllSyncDataReturnError( | 225 SyncError SharedChangeProcessor::GetAllSyncDataReturnError( |
231 syncer::ModelType type, | 226 ModelType type, |
232 syncer::SyncDataList* data) const { | 227 SyncDataList* data) const { |
233 DCHECK(backend_task_runner_.get()); | 228 DCHECK(backend_task_runner_.get()); |
234 DCHECK(backend_task_runner_->BelongsToCurrentThread()); | 229 DCHECK(backend_task_runner_->BelongsToCurrentThread()); |
235 AutoLock lock(monitor_lock_); | 230 AutoLock lock(monitor_lock_); |
236 if (disconnected_) { | 231 if (disconnected_) { |
237 syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, | 232 SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, |
238 "Change processor disconnected.", type_); | 233 "Change processor disconnected.", type_); |
239 return error; | 234 return error; |
240 } | 235 } |
241 return generic_change_processor_->GetAllSyncDataReturnError(data); | 236 return generic_change_processor_->GetAllSyncDataReturnError(data); |
242 } | 237 } |
243 | 238 |
244 syncer::SyncError SharedChangeProcessor::UpdateDataTypeContext( | 239 SyncError SharedChangeProcessor::UpdateDataTypeContext( |
245 syncer::ModelType type, | 240 ModelType type, |
246 syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status, | 241 SyncChangeProcessor::ContextRefreshStatus refresh_status, |
247 const std::string& context) { | 242 const std::string& context) { |
248 DCHECK(backend_task_runner_.get()); | 243 DCHECK(backend_task_runner_.get()); |
249 DCHECK(backend_task_runner_->BelongsToCurrentThread()); | 244 DCHECK(backend_task_runner_->BelongsToCurrentThread()); |
250 AutoLock lock(monitor_lock_); | 245 AutoLock lock(monitor_lock_); |
251 if (disconnected_) { | 246 if (disconnected_) { |
252 syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, | 247 SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, |
253 "Change processor disconnected.", type_); | 248 "Change processor disconnected.", type_); |
254 return error; | 249 return error; |
255 } | 250 } |
256 return generic_change_processor_->UpdateDataTypeContext(type, refresh_status, | 251 return generic_change_processor_->UpdateDataTypeContext(type, refresh_status, |
257 context); | 252 context); |
258 } | 253 } |
259 | 254 |
260 void SharedChangeProcessor::AddLocalChangeObserver( | 255 void SharedChangeProcessor::AddLocalChangeObserver( |
261 syncer::LocalChangeObserver* observer) { | 256 LocalChangeObserver* observer) { |
262 DCHECK(backend_task_runner_.get()); | 257 DCHECK(backend_task_runner_.get()); |
263 DCHECK(backend_task_runner_->BelongsToCurrentThread()); | 258 DCHECK(backend_task_runner_->BelongsToCurrentThread()); |
264 | 259 |
265 generic_change_processor_->AddLocalChangeObserver(observer); | 260 generic_change_processor_->AddLocalChangeObserver(observer); |
266 } | 261 } |
267 | 262 |
268 void SharedChangeProcessor::RemoveLocalChangeObserver( | 263 void SharedChangeProcessor::RemoveLocalChangeObserver( |
269 syncer::LocalChangeObserver* observer) { | 264 LocalChangeObserver* observer) { |
270 DCHECK(backend_task_runner_.get()); | 265 DCHECK(backend_task_runner_.get()); |
271 DCHECK(backend_task_runner_->BelongsToCurrentThread()); | 266 DCHECK(backend_task_runner_->BelongsToCurrentThread()); |
272 | 267 |
273 generic_change_processor_->RemoveLocalChangeObserver(observer); | 268 generic_change_processor_->RemoveLocalChangeObserver(observer); |
274 } | 269 } |
275 | 270 |
276 bool SharedChangeProcessor::SyncModelHasUserCreatedNodes(bool* has_nodes) { | 271 bool SharedChangeProcessor::SyncModelHasUserCreatedNodes(bool* has_nodes) { |
277 DCHECK(backend_task_runner_.get()); | 272 DCHECK(backend_task_runner_.get()); |
278 DCHECK(backend_task_runner_->BelongsToCurrentThread()); | 273 DCHECK(backend_task_runner_->BelongsToCurrentThread()); |
279 AutoLock lock(monitor_lock_); | 274 AutoLock lock(monitor_lock_); |
(...skipping 19 matching lines...) Expand all Loading... |
299 DCHECK(backend_task_runner_.get()); | 294 DCHECK(backend_task_runner_.get()); |
300 DCHECK(backend_task_runner_->BelongsToCurrentThread()); | 295 DCHECK(backend_task_runner_->BelongsToCurrentThread()); |
301 AutoLock lock(monitor_lock_); | 296 AutoLock lock(monitor_lock_); |
302 if (disconnected_) { | 297 if (disconnected_) { |
303 LOG(ERROR) << "Change processor disconnected."; | 298 LOG(ERROR) << "Change processor disconnected."; |
304 return false; | 299 return false; |
305 } | 300 } |
306 return generic_change_processor_->GetDataTypeContext(context); | 301 return generic_change_processor_->GetDataTypeContext(context); |
307 } | 302 } |
308 | 303 |
309 syncer::SyncError SharedChangeProcessor::CreateAndUploadError( | 304 SyncError SharedChangeProcessor::CreateAndUploadError( |
310 const tracked_objects::Location& location, | 305 const tracked_objects::Location& location, |
311 const std::string& message) { | 306 const std::string& message) { |
312 AutoLock lock(monitor_lock_); | 307 AutoLock lock(monitor_lock_); |
313 if (!disconnected_) { | 308 if (!disconnected_) { |
314 return error_handler_->CreateAndUploadError(location, message, type_); | 309 return error_handler_->CreateAndUploadError(location, message, type_); |
315 } else { | 310 } else { |
316 return syncer::SyncError(location, syncer::SyncError::DATATYPE_ERROR, | 311 return SyncError(location, SyncError::DATATYPE_ERROR, message, type_); |
317 message, type_); | |
318 } | 312 } |
319 } | 313 } |
320 | 314 |
321 void SharedChangeProcessor::RecordAssociationTime(base::TimeDelta time) { | 315 void SharedChangeProcessor::RecordAssociationTime(base::TimeDelta time) { |
322 #define PER_DATA_TYPE_MACRO(type_str) \ | 316 #define PER_DATA_TYPE_MACRO(type_str) \ |
323 UMA_HISTOGRAM_TIMES("Sync." type_str "AssociationTime", time); | 317 UMA_HISTOGRAM_TIMES("Sync." type_str "AssociationTime", time); |
324 SYNC_DATA_TYPE_HISTOGRAM(type_); | 318 SYNC_DATA_TYPE_HISTOGRAM(type_); |
325 #undef PER_DATA_TYPE_MACRO | 319 #undef PER_DATA_TYPE_MACRO |
326 } | 320 } |
327 | 321 |
328 void SharedChangeProcessor::StopLocalService() { | 322 void SharedChangeProcessor::StopLocalService() { |
329 if (local_service_.get()) | 323 if (local_service_.get()) |
330 local_service_->StopSyncing(type_); | 324 local_service_->StopSyncing(type_); |
331 local_service_.reset(); | 325 local_service_.reset(); |
332 } | 326 } |
333 | 327 |
334 } // namespace sync_driver | 328 } // namespace syncer |
OLD | NEW |