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 "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
8 #include "components/sync_driver/generic_change_processor.h" | 8 #include "components/sync_driver/generic_change_processor.h" |
9 #include "components/sync_driver/generic_change_processor_factory.h" | 9 #include "components/sync_driver/generic_change_processor_factory.h" |
10 #include "components/sync_driver/sync_api_component_factory.h" | 10 #include "components/sync_driver/sync_api_component_factory.h" |
11 #include "sync/api/sync_change.h" | 11 #include "sync/api/sync_change.h" |
12 | 12 |
13 using base::AutoLock; | 13 using base::AutoLock; |
14 | 14 |
15 namespace sync_driver { | 15 namespace sync_driver { |
16 | 16 |
17 SharedChangeProcessor::SharedChangeProcessor() | 17 SharedChangeProcessor::SharedChangeProcessor() |
18 : disconnected_(false), | 18 : disconnected_(false), |
19 type_(syncer::UNSPECIFIED), | 19 type_(syncer::UNSPECIFIED), |
20 frontend_loop_(base::MessageLoopProxy::current()), | 20 frontend_loop_(base::MessageLoopProxy::current()), |
21 generic_change_processor_(NULL), | 21 generic_change_processor_(NULL), |
22 error_handler_(NULL) { | 22 error_handler_(NULL) { |
23 } | 23 } |
24 | 24 |
25 SharedChangeProcessor::~SharedChangeProcessor() { | 25 SharedChangeProcessor::~SharedChangeProcessor() { |
26 // We can either be deleted when the DTC is destroyed (on UI | 26 // We can either be deleted when the DTC is destroyed (on UI |
27 // thread), or when the syncer::SyncableService stop's syncing (datatype | 27 // thread), or when the syncer::SyncableService stops syncing (datatype |
28 // thread). |generic_change_processor_|, if non-NULL, must be | 28 // thread). |generic_change_processor_|, if non-NULL, must be |
29 // deleted on |backend_loop_|. | 29 // deleted on |backend_loop_|. |
30 if (frontend_loop_->BelongsToCurrentThread()) { | 30 if (backend_loop_.get()) { |
31 if (backend_loop_.get()) { | 31 if (backend_loop_->BelongsToCurrentThread()) { |
| 32 delete generic_change_processor_; |
| 33 } else { |
| 34 DCHECK(frontend_loop_->BelongsToCurrentThread()); |
32 if (!backend_loop_->DeleteSoon(FROM_HERE, generic_change_processor_)) { | 35 if (!backend_loop_->DeleteSoon(FROM_HERE, generic_change_processor_)) { |
33 NOTREACHED(); | 36 NOTREACHED(); |
34 } | 37 } |
35 } else { | |
36 DCHECK(!generic_change_processor_); | |
37 } | 38 } |
38 } else { | 39 } else { |
39 DCHECK(backend_loop_.get()); | 40 DCHECK(!generic_change_processor_); |
40 DCHECK(backend_loop_->BelongsToCurrentThread()); | |
41 delete generic_change_processor_; | |
42 } | 41 } |
43 } | 42 } |
44 | 43 |
45 base::WeakPtr<syncer::SyncableService> SharedChangeProcessor::Connect( | 44 base::WeakPtr<syncer::SyncableService> SharedChangeProcessor::Connect( |
46 SyncApiComponentFactory* sync_factory, | 45 SyncApiComponentFactory* sync_factory, |
47 GenericChangeProcessorFactory* processor_factory, | 46 GenericChangeProcessorFactory* processor_factory, |
48 syncer::UserShare* user_share, | 47 syncer::UserShare* user_share, |
49 DataTypeErrorHandler* error_handler, | 48 DataTypeErrorHandler* error_handler, |
50 syncer::ModelType type, | 49 syncer::ModelType type, |
51 const base::WeakPtr<syncer::SyncMergeResult>& merge_result) { | 50 const base::WeakPtr<syncer::SyncMergeResult>& merge_result) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 return error_handler_->CreateAndUploadError(location, message, type_); | 201 return error_handler_->CreateAndUploadError(location, message, type_); |
203 } else { | 202 } else { |
204 return syncer::SyncError(location, | 203 return syncer::SyncError(location, |
205 syncer::SyncError::DATATYPE_ERROR, | 204 syncer::SyncError::DATATYPE_ERROR, |
206 message, | 205 message, |
207 type_); | 206 type_); |
208 } | 207 } |
209 } | 208 } |
210 | 209 |
211 } // namespace sync_driver | 210 } // namespace sync_driver |
OLD | NEW |