1 // Copyright (c) 2012 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 "sync/api/fake_syncable_service.h" 6 7 #include "base/location.h" 8 #include "sync/api/sync_error_factory.h" 9 10 namespace syncer { 11 FakeSyncableService()12FakeSyncableService::FakeSyncableService() 13 : syncing_(false), 14 type_(UNSPECIFIED) {} 15 ~FakeSyncableService()16FakeSyncableService::~FakeSyncableService() {} 17 set_merge_data_and_start_syncing_error(const SyncError & error)18void FakeSyncableService::set_merge_data_and_start_syncing_error( 19 const SyncError& error) { 20 merge_data_and_start_syncing_error_ = error; 21 } 22 set_process_sync_changes_error(const SyncError & error)23void FakeSyncableService::set_process_sync_changes_error( 24 const SyncError& error) { 25 process_sync_changes_error_ = error; 26 } 27 syncing() const28bool FakeSyncableService::syncing() const { 29 return syncing_; 30 } 31 32 // SyncableService implementation. MergeDataAndStartSyncing(ModelType type,const SyncDataList & initial_sync_data,scoped_ptr<SyncChangeProcessor> sync_processor,scoped_ptr<SyncErrorFactory> sync_error_factory)33SyncMergeResult FakeSyncableService::MergeDataAndStartSyncing( 34 ModelType type, 35 const SyncDataList& initial_sync_data, 36 scoped_ptr<SyncChangeProcessor> sync_processor, 37 scoped_ptr<SyncErrorFactory> sync_error_factory) { 38 SyncMergeResult merge_result(type); 39 sync_processor_ = sync_processor.Pass(); 40 type_ = type; 41 if (!merge_data_and_start_syncing_error_.IsSet()) { 42 syncing_ = true; 43 } else { 44 merge_result.set_error(merge_data_and_start_syncing_error_); 45 } 46 return merge_result; 47 } 48 StopSyncing(ModelType type)49void FakeSyncableService::StopSyncing(ModelType type) { 50 syncing_ = false; 51 sync_processor_.reset(); 52 } 53 GetAllSyncData(ModelType type) const54SyncDataList FakeSyncableService::GetAllSyncData(ModelType type) const { 55 return SyncDataList(); 56 } 57 ProcessSyncChanges(const tracked_objects::Location & from_here,const SyncChangeList & change_list)58SyncError FakeSyncableService::ProcessSyncChanges( 59 const tracked_objects::Location& from_here, 60 const SyncChangeList& change_list) { 61 return process_sync_changes_error_; 62 } 63 64 } // namespace syncer 65