diff options
Diffstat (limited to 'sync')
-rw-r--r-- | sync/api/fake_syncable_service.cc | 18 | ||||
-rw-r--r-- | sync/api/fake_syncable_service.h | 13 | ||||
-rw-r--r-- | sync/api/syncable_service.cc | 4 | ||||
-rw-r--r-- | sync/api/syncable_service.h | 11 |
4 files changed, 46 insertions, 0 deletions
diff --git a/sync/api/fake_syncable_service.cc b/sync/api/fake_syncable_service.cc index 0d76f2e..ec7b90c 100644 --- a/sync/api/fake_syncable_service.cc +++ b/sync/api/fake_syncable_service.cc @@ -25,6 +25,15 @@ void FakeSyncableService::set_process_sync_changes_error( process_sync_changes_error_ = error; } +void FakeSyncableService::set_attachment_store( + const scoped_refptr<AttachmentStore>& attachment_store) { + attachment_store_ = attachment_store; +} + +const AttachmentService* FakeSyncableService::attachment_service() const { + return attachment_service_.get(); +} + bool FakeSyncableService::syncing() const { return syncing_; } @@ -61,4 +70,13 @@ SyncError FakeSyncableService::ProcessSyncChanges( return process_sync_changes_error_; } +scoped_refptr<AttachmentStore> FakeSyncableService::GetAttachmentStore() { + return attachment_store_; +} + +void FakeSyncableService::SetAttachmentService( + scoped_ptr<AttachmentService> attachment_service) { + attachment_service_ = attachment_service.Pass(); +} + } // namespace syncer diff --git a/sync/api/fake_syncable_service.h b/sync/api/fake_syncable_service.h index 8ecf05e..7403ef3 100644 --- a/sync/api/fake_syncable_service.h +++ b/sync/api/fake_syncable_service.h @@ -22,6 +22,14 @@ class FakeSyncableService : public SyncableService { void set_merge_data_and_start_syncing_error(const SyncError& error); void set_process_sync_changes_error(const SyncError& error); + // Setter for AttachmentStore. + void set_attachment_store( + const scoped_refptr<AttachmentStore>& attachment_store); + + // AttachmentService should be set when this syncable service is connected, + // just before MergeDataAndStartSyncing. NULL is returned by default. + const AttachmentService* attachment_service() const; + // Whether we're syncing or not. Set on a successful MergeDataAndStartSyncing, // unset on StopSyncing. False by default. bool syncing() const; @@ -36,6 +44,9 @@ class FakeSyncableService : public SyncableService { SyncDataList GetAllSyncData(ModelType type) const override; SyncError ProcessSyncChanges(const tracked_objects::Location& from_here, const SyncChangeList& change_list) override; + scoped_refptr<AttachmentStore> GetAttachmentStore() override; + void SetAttachmentService( + scoped_ptr<AttachmentService> attachment_service) override; private: scoped_ptr<SyncChangeProcessor> sync_processor_; @@ -43,6 +54,8 @@ class FakeSyncableService : public SyncableService { SyncError process_sync_changes_error_; bool syncing_; ModelType type_; + scoped_refptr<AttachmentStore> attachment_store_; + scoped_ptr<AttachmentService> attachment_service_; }; } // namespace syncer diff --git a/sync/api/syncable_service.cc b/sync/api/syncable_service.cc index 9d4773c..7b0a973 100644 --- a/sync/api/syncable_service.cc +++ b/sync/api/syncable_service.cc @@ -12,4 +12,8 @@ scoped_refptr<AttachmentStore> SyncableService::GetAttachmentStore() { return scoped_refptr<AttachmentStore>(); } +void SyncableService::SetAttachmentService( + scoped_ptr<AttachmentService> attachment_service) { +} + } // namespace syncer diff --git a/sync/api/syncable_service.h b/sync/api/syncable_service.h index 17feb63..960abc5 100644 --- a/sync/api/syncable_service.h +++ b/sync/api/syncable_service.h @@ -21,6 +21,7 @@ namespace syncer { +class AttachmentService; class SyncErrorFactory; // TODO(zea): remove SupportsWeakPtr in favor of having all SyncableService @@ -76,6 +77,16 @@ class SYNC_EXPORT SyncableService // to return pointer to it. virtual scoped_refptr<AttachmentStore> GetAttachmentStore(); + // Called by sync to provide AttachmentService to be used to download + // attachments. + // SetAttachmentService is called after GetAttachmentStore and right before + // MergeDataAndStartSyncing and only if GetAttachmentStore has returned a + // non-NULL store instance. Default implementation does nothing. + // Datatype that uses attachments must take ownerhip of the provided + // AttachmentService instance. + virtual void SetAttachmentService( + scoped_ptr<AttachmentService> attachment_service); + protected: ~SyncableService() override; }; |