diff options
author | stanisc <stanisc@chromium.org> | 2014-12-09 11:39:04 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-09 19:39:29 +0000 |
commit | fbc3e52958fbab4eba1b8d6e96f5a086011b0385 (patch) | |
tree | edef898235a59cff397b57120050402fdf1a013d /sync/api | |
parent | fbc420a86fdaa548def1ea20204349c0768a139a (diff) | |
download | chromium_src-fbc3e52958fbab4eba1b8d6e96f5a086011b0385.zip chromium_src-fbc3e52958fbab4eba1b8d6e96f5a086011b0385.tar.gz chromium_src-fbc3e52958fbab4eba1b8d6e96f5a086011b0385.tar.bz2 |
Make AttachmentService accessible directly from
SyncableService without having to have SyncData.
Added a new method SetAttachmentService to SyncableService
interface. It should be implemented by a syncable service that
supports attachments. By default this method does nothing.
This method is called SharedChangeProcessor when it gets
connected to an attachment enabled syncable service (which
provides a non-default implementation GetAttachmentStore).
Added a new test case that tests attachment specific
integration code in GenericChangeProcessor and SyncableService.
BUG=439510
Review URL: https://codereview.chromium.org/769913003
Cr-Commit-Position: refs/heads/master@{#307520}
Diffstat (limited to 'sync/api')
-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; }; |