| 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/base/data_type_histogram.h" | 10 #include "components/sync/base/data_type_histogram.h" |
| 11 #include "components/sync/driver/generic_change_processor.h" | 11 #include "components/sync/driver/generic_change_processor.h" |
| 12 #include "components/sync/driver/generic_change_processor_factory.h" | 12 #include "components/sync/driver/generic_change_processor_factory.h" |
| 13 #include "components/sync/driver/shared_change_processor_ref.h" | 13 #include "components/sync/driver/shared_change_processor_ref.h" |
| 14 #include "components/sync/driver/sync_client.h" | 14 #include "components/sync/driver/sync_client.h" |
| 15 #include "components/sync/model/sync_change.h" | 15 #include "components/sync/model/sync_change.h" |
| 16 #include "components/sync/model/syncable_service.h" | 16 #include "components/sync/model/syncable_service.h" |
| 17 | 17 |
| 18 using base::AutoLock; | 18 using base::AutoLock; |
| 19 | 19 |
| 20 namespace syncer { | 20 namespace syncer { |
| 21 | 21 |
| 22 class AttachmentService; | 22 class AttachmentService; |
| 23 | 23 |
| 24 SharedChangeProcessor::SharedChangeProcessor(ModelType type) | 24 SharedChangeProcessor::SharedChangeProcessor(ModelType type) |
| 25 : disconnected_(false), | 25 : disconnected_(false), |
| 26 type_(type), | 26 type_(type), |
| 27 frontend_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 27 frontend_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 28 generic_change_processor_(NULL) { | 28 generic_change_processor_(nullptr) { |
| 29 DCHECK_NE(type_, UNSPECIFIED); | 29 DCHECK_NE(type_, UNSPECIFIED); |
| 30 } | 30 } |
| 31 | 31 |
| 32 SharedChangeProcessor::~SharedChangeProcessor() { | 32 SharedChangeProcessor::~SharedChangeProcessor() { |
| 33 // We can either be deleted when the DTC is destroyed (on UI | 33 // We can either be deleted when the DTC is destroyed (on UI |
| 34 // thread), or when the SyncableService stops syncing (datatype | 34 // thread), or when the SyncableService stops syncing (datatype |
| 35 // thread). |generic_change_processor_|, if non-NULL, must be | 35 // thread). |generic_change_processor_|, if non-null, must be |
| 36 // deleted on |backend_loop_|. | 36 // deleted on |backend_loop_|. |
| 37 if (backend_task_runner_.get()) { | 37 if (backend_task_runner_.get()) { |
| 38 if (backend_task_runner_->BelongsToCurrentThread()) { | 38 if (backend_task_runner_->BelongsToCurrentThread()) { |
| 39 delete generic_change_processor_; | 39 delete generic_change_processor_; |
| 40 } else { | 40 } else { |
| 41 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 41 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 42 if (!backend_task_runner_->DeleteSoon(FROM_HERE, | 42 if (!backend_task_runner_->DeleteSoon(FROM_HERE, |
| 43 generic_change_processor_)) { | 43 generic_change_processor_)) { |
| 44 NOTREACHED(); | 44 NOTREACHED(); |
| 45 } | 45 } |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 #undef PER_DATA_TYPE_MACRO | 317 #undef PER_DATA_TYPE_MACRO |
| 318 } | 318 } |
| 319 | 319 |
| 320 void SharedChangeProcessor::StopLocalService() { | 320 void SharedChangeProcessor::StopLocalService() { |
| 321 if (local_service_.get()) | 321 if (local_service_.get()) |
| 322 local_service_->StopSyncing(type_); | 322 local_service_->StopSyncing(type_); |
| 323 local_service_.reset(); | 323 local_service_.reset(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 } // namespace syncer | 326 } // namespace syncer |
| OLD | NEW |