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

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

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
« no previous file with comments | « sync/api/attachments/attachment_store.h ('k') | sync/api/attachments/attachment_store_backend.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/api/attachments/attachment_store.cc
diff --git a/sync/api/attachments/attachment_store.cc b/sync/api/attachments/attachment_store.cc
index 7cf774e93175c5172a50363869baa2449731255a..b945c9f9c556c6f28f0fc9163ae870d06587c7ed 100644
--- a/sync/api/attachments/attachment_store.cc
+++ b/sync/api/attachments/attachment_store.cc
@@ -16,10 +16,16 @@
namespace syncer {
+namespace {
+
+void NoOpDropCallback(const AttachmentStore::Result& result) {
+}
+}
+
AttachmentStore::AttachmentStore(
const scoped_refptr<AttachmentStoreFrontend>& frontend,
- AttachmentReferrer referrer)
- : frontend_(frontend), referrer_(referrer) {
+ Component component)
+ : frontend_(frontend), component_(component) {
}
AttachmentStore::~AttachmentStore() {
@@ -32,12 +38,12 @@ void AttachmentStore::Read(const AttachmentIdList& ids,
void AttachmentStore::Write(const AttachmentList& attachments,
const WriteCallback& callback) {
- frontend_->Write(referrer_, attachments, callback);
+ frontend_->Write(component_, attachments, callback);
}
void AttachmentStore::Drop(const AttachmentIdList& ids,
const DropCallback& callback) {
- frontend_->Drop(referrer_, ids, callback);
+ frontend_->DropReference(component_, ids, callback);
}
void AttachmentStore::ReadMetadata(const AttachmentIdList& ids,
@@ -46,14 +52,14 @@ void AttachmentStore::ReadMetadata(const AttachmentIdList& ids,
}
void AttachmentStore::ReadAllMetadata(const ReadMetadataCallback& callback) {
- frontend_->ReadAllMetadata(referrer_, callback);
+ frontend_->ReadAllMetadata(component_, callback);
}
-scoped_ptr<AttachmentStore> AttachmentStore::CreateAttachmentStoreForSync()
- const {
- scoped_ptr<AttachmentStore> attachment_store(
- new AttachmentStore(frontend_, SYNC));
- return attachment_store.Pass();
+scoped_ptr<AttachmentStoreForSync>
+AttachmentStore::CreateAttachmentStoreForSync() const {
+ scoped_ptr<AttachmentStoreForSync> attachment_store_for_sync(
+ new AttachmentStoreForSync(frontend_, component_, SYNC));
+ return attachment_store_for_sync.Pass();
}
scoped_ptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() {
@@ -103,4 +109,21 @@ scoped_ptr<AttachmentStore> AttachmentStore::CreateMockStoreForTest(
return attachment_store.Pass();
}
+AttachmentStoreForSync::AttachmentStoreForSync(
+ const scoped_refptr<AttachmentStoreFrontend>& frontend,
+ Component consumer_component,
+ Component sync_component)
+ : AttachmentStore(frontend, consumer_component),
+ sync_component_(sync_component) {
+}
+
+void AttachmentStoreForSync::SetSyncReference(const AttachmentIdList& ids) {
+ frontend()->SetReference(sync_component_, ids);
+}
+
+void AttachmentStoreForSync::DropSyncReference(const AttachmentIdList& ids) {
+ frontend()->DropReference(sync_component_, ids,
+ base::Bind(&NoOpDropCallback));
+}
+
} // namespace syncer
« no previous file with comments | « sync/api/attachments/attachment_store.h ('k') | sync/api/attachments/attachment_store_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698