| 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" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 } else { | 47 } else { |
| 48 DCHECK(!generic_change_processor_); | 48 DCHECK(!generic_change_processor_); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 void SharedChangeProcessor::StartAssociation( | 52 void SharedChangeProcessor::StartAssociation( |
| 53 StartDoneCallback start_done, | 53 StartDoneCallback start_done, |
| 54 SyncClient* const sync_client, | 54 SyncClient* const sync_client, |
| 55 GenericChangeProcessorFactory* processor_factory, |
| 55 UserShare* user_share, | 56 UserShare* user_share, |
| 56 std::unique_ptr<DataTypeErrorHandler> error_handler) { | 57 std::unique_ptr<DataTypeErrorHandler> error_handler) { |
| 57 DCHECK(user_share); | 58 DCHECK(user_share); |
| 58 SyncMergeResult local_merge_result(type_); | 59 SyncMergeResult local_merge_result(type_); |
| 59 SyncMergeResult syncer_merge_result(type_); | 60 SyncMergeResult syncer_merge_result(type_); |
| 60 base::WeakPtrFactory<SyncMergeResult> weak_ptr_factory(&syncer_merge_result); | 61 base::WeakPtrFactory<SyncMergeResult> weak_ptr_factory(&syncer_merge_result); |
| 61 | 62 |
| 62 // Connect |shared_change_processor| to the syncer and get the | 63 // Connect |shared_change_processor| to the syncer and get the |
| 63 // SyncableService associated with type_. | 64 // SyncableService associated with type_. |
| 64 // Note that it's possible the shared_change_processor has already been | 65 // Note that it's possible the shared_change_processor has already been |
| 65 // disconnected at this point, so all our accesses to the syncer from this | 66 // disconnected at this point, so all our accesses to the syncer from this |
| 66 // point on are through it. | 67 // point on are through it. |
| 67 GenericChangeProcessorFactory factory; | |
| 68 local_service_ = | 68 local_service_ = |
| 69 Connect(sync_client, &factory, user_share, std::move(error_handler), | 69 Connect(sync_client, processor_factory, user_share, |
| 70 weak_ptr_factory.GetWeakPtr()); | 70 std::move(error_handler), weak_ptr_factory.GetWeakPtr()); |
| 71 if (!local_service_.get()) { | 71 if (!local_service_.get()) { |
| 72 SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, | 72 SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, |
| 73 "Failed to connect to syncer.", type_); | 73 "Failed to connect to syncer.", type_); |
| 74 local_merge_result.set_error(error); | 74 local_merge_result.set_error(error); |
| 75 start_done.Run(DataTypeController::ASSOCIATION_FAILED, local_merge_result, | 75 start_done.Run(DataTypeController::ASSOCIATION_FAILED, local_merge_result, |
| 76 syncer_merge_result); | 76 syncer_merge_result); |
| 77 return; | 77 return; |
| 78 } | 78 } |
| 79 | 79 |
| 80 if (!CryptoReadyIfNecessary()) { | 80 if (!CryptoReadyIfNecessary()) { |
| (...skipping 236 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 |