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 #ifndef COMPONENTS_SYNC_API_FAKE_SYNCABLE_SERVICE_H_ | |
6 #define COMPONENTS_SYNC_API_FAKE_SYNCABLE_SERVICE_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "components/sync/api/syncable_service.h" | |
11 | |
12 namespace syncer { | |
13 | |
14 class SyncErrorFactory; | |
15 | |
16 // A fake SyncableService that can return arbitrary values and maintains the | |
17 // syncing status. | |
18 class FakeSyncableService : public SyncableService { | |
19 public: | |
20 FakeSyncableService(); | |
21 ~FakeSyncableService() override; | |
22 | |
23 // Setters for SyncableService implementation results. | |
24 void set_merge_data_and_start_syncing_error(const SyncError& error); | |
25 void set_process_sync_changes_error(const SyncError& error); | |
26 | |
27 // Setter for AttachmentStore. | |
28 void set_attachment_store(std::unique_ptr<AttachmentStore> attachment_store); | |
29 | |
30 // AttachmentService should be set when this syncable service is connected, | |
31 // just before MergeDataAndStartSyncing. NULL is returned by default. | |
32 const AttachmentService* attachment_service() const; | |
33 | |
34 // Whether we're syncing or not. Set on a successful MergeDataAndStartSyncing, | |
35 // unset on StopSyncing. False by default. | |
36 bool syncing() const; | |
37 | |
38 // SyncableService implementation. | |
39 SyncMergeResult MergeDataAndStartSyncing( | |
40 ModelType type, | |
41 const SyncDataList& initial_sync_data, | |
42 std::unique_ptr<SyncChangeProcessor> sync_processor, | |
43 std::unique_ptr<SyncErrorFactory> sync_error_factory) override; | |
44 void StopSyncing(ModelType type) override; | |
45 SyncDataList GetAllSyncData(ModelType type) const override; | |
46 SyncError ProcessSyncChanges(const tracked_objects::Location& from_here, | |
47 const SyncChangeList& change_list) override; | |
48 std::unique_ptr<AttachmentStoreForSync> GetAttachmentStoreForSync() override; | |
49 void SetAttachmentService( | |
50 std::unique_ptr<AttachmentService> attachment_service) override; | |
51 | |
52 private: | |
53 std::unique_ptr<SyncChangeProcessor> sync_processor_; | |
54 SyncError merge_data_and_start_syncing_error_; | |
55 SyncError process_sync_changes_error_; | |
56 bool syncing_; | |
57 ModelType type_; | |
58 std::unique_ptr<AttachmentStore> attachment_store_; | |
59 std::unique_ptr<AttachmentService> attachment_service_; | |
60 }; | |
61 | |
62 } // namespace syncer | |
63 | |
64 #endif // COMPONENTS_SYNC_API_FAKE_SYNCABLE_SERVICE_H_ | |
OLD | NEW |