Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Unified Diff: sync/api/attachments/attachment_store.h

Issue 1002263005: [Sync] Introduce AttachmentStoreForSync class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sync/api/attachments/attachment_store.h
diff --git a/sync/api/attachments/attachment_store.h b/sync/api/attachments/attachment_store.h
index e8d8f5c718c923b2328fbbaf68f0996f3e61c416..cc83619022c00a31cde749eec968a634de8d46fa 100644
--- a/sync/api/attachments/attachment_store.h
+++ b/sync/api/attachments/attachment_store.h
@@ -20,8 +20,9 @@ class SequencedTaskRunner;
namespace syncer {
-class AttachmentStoreFrontend;
class AttachmentStoreBackend;
+class AttachmentStoreForSync;
+class AttachmentStoreFrontend;
// AttachmentStore is a place to locally store and access Attachments.
//
@@ -50,7 +51,7 @@ class SYNC_EXPORT AttachmentStore {
// Each attachment can have references from sync or model type. Tracking these
// references is needed for lifetime management of attachment, it can only be
// deleted from the store when it doesn't have references.
- enum AttachmentReferrer {
+ enum Component {
MODEL_TYPE,
SYNC,
};
@@ -121,7 +122,7 @@ class SYNC_EXPORT AttachmentStore {
// Given current AttachmentStore (this) creates separate AttachmentStore that
// will be used by sync components (AttachmentService). Resulting
// AttachmentStore is backed by the same frontend/backend.
- scoped_ptr<AttachmentStore> CreateAttachmentStoreForSync() const;
+ scoped_ptr<AttachmentStoreForSync> CreateAttachmentStoreForSync() const;
// Creates an AttachmentStore backed by in-memory implementation of attachment
// store. For now frontend lives on the same thread as backend.
@@ -145,18 +146,47 @@ class SYNC_EXPORT AttachmentStore {
static scoped_ptr<AttachmentStore> CreateMockStoreForTest(
scoped_ptr<AttachmentStoreBackend> backend);
- private:
+ protected:
AttachmentStore(const scoped_refptr<AttachmentStoreFrontend>& frontend,
- AttachmentReferrer referrer);
+ Component component);
+
+ const scoped_refptr<AttachmentStoreFrontend>& frontend() { return frontend_; }
+ private:
scoped_refptr<AttachmentStoreFrontend> frontend_;
// Modification operations with attachment store will be performed on behalf
- // of |referrer_|.
- const AttachmentReferrer referrer_;
+ // of |component_|.
+ const Component component_;
DISALLOW_COPY_AND_ASSIGN(AttachmentStore);
};
+// AttachmentStoreForSync extends AttachmentStore and provides additional
+// functions necessary for AttachmentService. These are needed when
+// AttachmentService writes attachment on behalf of model type after download
+// and takes reference on attachment for the duration of upload.
+// Model type implementation shouldn't use this interface.
+class AttachmentStoreForSync : public AttachmentStore {
+ public:
+ // Asynchronously adds reference from sync to attachments.
+ void SetSyncReference(const AttachmentIdList& ids);
+
+ // Asynchronously drops sync reference from attachments.
+ void DropSyncReference(const AttachmentIdList& ids);
+
+ private:
+ friend class AttachmentStore;
+ AttachmentStoreForSync(const scoped_refptr<AttachmentStoreFrontend>& frontend,
+ Component consumer_component,
+ Component sync_component);
+
+ // |sync_component_| is passed to frontend when sync related operations are
+ // perfromed.
+ const Component sync_component_;
+
+ DISALLOW_COPY_AND_ASSIGN(AttachmentStoreForSync);
+};
+
} // namespace syncer
#endif // SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_H_
« no previous file with comments | « components/sync_driver/ui_data_type_controller_unittest.cc ('k') | sync/api/attachments/attachment_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698