| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/sync/glue/syncable_service_adapter.h" | |
| 6 | |
| 7 #include "chrome/browser/sync/api/syncable_service.h" | |
| 8 #include "chrome/browser/sync/api/sync_data.h" | |
| 9 #include "chrome/browser/sync/glue/generic_change_processor.h" | |
| 10 | |
| 11 namespace browser_sync { | |
| 12 | |
| 13 SyncableServiceAdapter::SyncableServiceAdapter( | |
| 14 syncable::ModelType type, | |
| 15 SyncableService* service, | |
| 16 GenericChangeProcessor* sync_processor) | |
| 17 : syncing_(false), | |
| 18 type_(type), | |
| 19 service_(service), | |
| 20 sync_processor_(sync_processor) { | |
| 21 } | |
| 22 | |
| 23 SyncableServiceAdapter::~SyncableServiceAdapter() { | |
| 24 if (syncing_) { | |
| 25 NOTREACHED(); | |
| 26 LOG(ERROR) << "SyncableServiceAdapter for " | |
| 27 << syncable::ModelTypeToString(type_) << " destroyed before " | |
| 28 << "without being shut down properly."; | |
| 29 service_->StopSyncing(type_); | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 bool SyncableServiceAdapter::AssociateModels(SyncError* error) { | |
| 34 syncing_ = true; | |
| 35 SyncDataList initial_sync_data; | |
| 36 SyncError temp_error = | |
| 37 sync_processor_->GetSyncDataForType(type_, &initial_sync_data); | |
| 38 if (temp_error.IsSet()) { | |
| 39 *error = temp_error; | |
| 40 return false; | |
| 41 } | |
| 42 | |
| 43 // TODO(zea): Have all datatypes take ownership of the sync_processor_. | |
| 44 // Further, refactor the DTC's to not need this class at all | |
| 45 // (crbug.com/100114). | |
| 46 temp_error = service_->MergeDataAndStartSyncing(type_, | |
| 47 initial_sync_data, | |
| 48 sync_processor_); | |
| 49 if (temp_error.IsSet()) { | |
| 50 *error = temp_error; | |
| 51 return false; | |
| 52 } | |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 bool SyncableServiceAdapter::DisassociateModels(SyncError* error) { | |
| 57 service_->StopSyncing(type_); | |
| 58 syncing_ = false; | |
| 59 return true; | |
| 60 } | |
| 61 | |
| 62 bool SyncableServiceAdapter::SyncModelHasUserCreatedNodes(bool* has_nodes) { | |
| 63 return sync_processor_->SyncModelHasUserCreatedNodes(type_, has_nodes); | |
| 64 } | |
| 65 | |
| 66 void SyncableServiceAdapter::AbortAssociation() { | |
| 67 NOTIMPLEMENTED(); | |
| 68 } | |
| 69 | |
| 70 bool SyncableServiceAdapter::CryptoReadyIfNecessary() { | |
| 71 return sync_processor_->CryptoReadyIfNecessary(type_); | |
| 72 } | |
| 73 | |
| 74 } // namespace browser_sync | |
| OLD | NEW |