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