| OLD | NEW |
| (Empty) | |
| 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 "chrome/browser/sync/glue/generic_change_processor_fake.h" |
| 6 |
| 7 #include "base/location.h" |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "chrome/browser/sync/api/syncable_service.h" |
| 10 |
| 11 namespace browser_sync { |
| 12 |
| 13 GenericChangeProcessorFake::GenericChangeProcessorFake() |
| 14 : GenericChangeProcessor(NULL, base::WeakPtr<SyncableService>(), NULL) { |
| 15 Reset(); |
| 16 } |
| 17 GenericChangeProcessorFake::~GenericChangeProcessorFake() {} |
| 18 |
| 19 void GenericChangeProcessorFake::Reset() { |
| 20 process_success_= true; |
| 21 get_sync_data_success_ = true; |
| 22 has_nodes_ = true; |
| 23 has_nodes_success_ = true; |
| 24 crypto_ready_ = true; |
| 25 type_ = syncable::UNSPECIFIED; |
| 26 } |
| 27 |
| 28 void GenericChangeProcessorFake::set_process_success(bool success) { |
| 29 process_success_ = success; |
| 30 } |
| 31 void GenericChangeProcessorFake::set_get_sync_data_success(bool success) { |
| 32 get_sync_data_success_ = success; |
| 33 } |
| 34 void GenericChangeProcessorFake::set_has_nodes(bool has_nodes) { |
| 35 has_nodes_ = has_nodes; |
| 36 } |
| 37 void GenericChangeProcessorFake::set_has_nodes_success(bool success) { |
| 38 has_nodes_success_ = success; |
| 39 } |
| 40 void GenericChangeProcessorFake::set_crypto_ready(bool crypto_ready) { |
| 41 crypto_ready_ = crypto_ready; |
| 42 } |
| 43 |
| 44 SyncError GenericChangeProcessorFake::ProcessSyncChanges( |
| 45 const tracked_objects::Location& from_here, |
| 46 const SyncChangeList& change_list) { |
| 47 if (process_success_) |
| 48 return SyncError(); |
| 49 return SyncError(FROM_HERE, "Process error", type_); |
| 50 } |
| 51 |
| 52 SyncError GenericChangeProcessorFake::GetSyncDataForType( |
| 53 syncable::ModelType type, SyncDataList* current_sync_data) { |
| 54 type_ = type; |
| 55 if (get_sync_data_success_) |
| 56 return SyncError(); |
| 57 return SyncError(FROM_HERE, "GetSyncData error", type); |
| 58 } |
| 59 |
| 60 bool GenericChangeProcessorFake::SyncModelHasUserCreatedNodes( |
| 61 syncable::ModelType type, bool* has_nodes) { |
| 62 type_ = type; |
| 63 *has_nodes = has_nodes_; |
| 64 return has_nodes_success_; |
| 65 } |
| 66 |
| 67 bool GenericChangeProcessorFake::CryptoReadyIfNecessary( |
| 68 syncable::ModelType type) { |
| 69 type_ = type; |
| 70 return crypto_ready_; |
| 71 } |
| 72 |
| 73 } // namespace browser_sync |
| OLD | NEW |