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 "sync/api/fake_syncable_service.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "base/location.h" | |
10 #include "sync/api/sync_error_factory.h" | |
11 | |
12 namespace syncer { | |
13 | |
14 FakeSyncableService::FakeSyncableService() | |
15 : syncing_(false), | |
16 type_(UNSPECIFIED) {} | |
17 | |
18 FakeSyncableService::~FakeSyncableService() {} | |
19 | |
20 void FakeSyncableService::set_merge_data_and_start_syncing_error( | |
21 const SyncError& error) { | |
22 merge_data_and_start_syncing_error_ = error; | |
23 } | |
24 | |
25 void FakeSyncableService::set_process_sync_changes_error( | |
26 const SyncError& error) { | |
27 process_sync_changes_error_ = error; | |
28 } | |
29 | |
30 void FakeSyncableService::set_attachment_store( | |
31 std::unique_ptr<AttachmentStore> attachment_store) { | |
32 attachment_store_ = std::move(attachment_store); | |
33 } | |
34 | |
35 const AttachmentService* FakeSyncableService::attachment_service() const { | |
36 return attachment_service_.get(); | |
37 } | |
38 | |
39 bool FakeSyncableService::syncing() const { | |
40 return syncing_; | |
41 } | |
42 | |
43 // SyncableService implementation. | |
44 SyncMergeResult FakeSyncableService::MergeDataAndStartSyncing( | |
45 ModelType type, | |
46 const SyncDataList& initial_sync_data, | |
47 std::unique_ptr<SyncChangeProcessor> sync_processor, | |
48 std::unique_ptr<SyncErrorFactory> sync_error_factory) { | |
49 SyncMergeResult merge_result(type); | |
50 sync_processor_ = std::move(sync_processor); | |
51 type_ = type; | |
52 if (!merge_data_and_start_syncing_error_.IsSet()) { | |
53 syncing_ = true; | |
54 } else { | |
55 merge_result.set_error(merge_data_and_start_syncing_error_); | |
56 } | |
57 return merge_result; | |
58 } | |
59 | |
60 void FakeSyncableService::StopSyncing(ModelType type) { | |
61 syncing_ = false; | |
62 sync_processor_.reset(); | |
63 } | |
64 | |
65 SyncDataList FakeSyncableService::GetAllSyncData(ModelType type) const { | |
66 return SyncDataList(); | |
67 } | |
68 | |
69 SyncError FakeSyncableService::ProcessSyncChanges( | |
70 const tracked_objects::Location& from_here, | |
71 const SyncChangeList& change_list) { | |
72 return process_sync_changes_error_; | |
73 } | |
74 | |
75 std::unique_ptr<AttachmentStoreForSync> | |
76 FakeSyncableService::GetAttachmentStoreForSync() { | |
77 return attachment_store_ ? attachment_store_->CreateAttachmentStoreForSync() | |
78 : std::unique_ptr<AttachmentStoreForSync>(); | |
79 } | |
80 | |
81 void FakeSyncableService::SetAttachmentService( | |
82 std::unique_ptr<AttachmentService> attachment_service) { | |
83 attachment_service_ = std::move(attachment_service); | |
84 } | |
85 | |
86 } // namespace syncer | |
OLD | NEW |