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

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

Issue 187303006: Update sync API to support attachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@attachmentapi
Patch Set: Remove AttachmentServiceBase for reals. Created 6 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/fake_attachment_store.cc
diff --git a/sync/api/attachments/fake_attachment_store.cc b/sync/api/attachments/fake_attachment_store.cc
index c3e5e38bc6b7e482059061806cde9ca2df056aeb..53e42a2b49a5f8719ee705a49a238e010ff843d9 100644
--- a/sync/api/attachments/fake_attachment_store.cc
+++ b/sync/api/attachments/fake_attachment_store.cc
@@ -29,20 +29,16 @@ class FakeAttachmentStore::Backend
private:
friend class base::RefCountedThreadSafe<Backend>;
- typedef std::map<AttachmentId, Attachment*> AttachmentMap;
~Backend();
- Result Remove(const AttachmentId& id);
scoped_refptr<base::SingleThreadTaskRunner> frontend_task_runner_;
AttachmentMap attachments_;
- STLValueDeleter<AttachmentMap> attachments_value_deleter_;
};
FakeAttachmentStore::Backend::Backend(
const scoped_refptr<base::SingleThreadTaskRunner>& frontend_task_runner)
- : frontend_task_runner_(frontend_task_runner),
- attachments_value_deleter_(&attachments_) {}
+ : frontend_task_runner_(frontend_task_runner) {}
FakeAttachmentStore::Backend::~Backend() {}
@@ -52,7 +48,7 @@ void FakeAttachmentStore::Backend::Read(const AttachmentId& id,
scoped_ptr<Attachment> attachment;
Result result = NOT_FOUND;
if (iter != attachments_.end()) {
- attachment.reset(new Attachment(*iter->second));
+ attachment.reset(new Attachment(iter->second));
result = SUCCESS;
}
frontend_task_runner_->PostTask(
@@ -62,31 +58,22 @@ void FakeAttachmentStore::Backend::Read(const AttachmentId& id,
void FakeAttachmentStore::Backend::Write(
const scoped_refptr<base::RefCountedMemory>& bytes,
const WriteCallback& callback) {
- scoped_ptr<Attachment> attachment = Attachment::Create(bytes);
- DCHECK(attachment.get());
- AttachmentId attachment_id(attachment->GetId());
- attachments_.insert(
- AttachmentMap::value_type(attachment_id, attachment.release()));
+ Attachment attachment = Attachment::Create(bytes);
+ AttachmentId attachment_id(attachment.GetId());
+ attachments_.insert(AttachmentMap::value_type(attachment_id, attachment));
frontend_task_runner_->PostTask(FROM_HERE,
base::Bind(callback, SUCCESS, attachment_id));
}
void FakeAttachmentStore::Backend::Drop(const AttachmentId& id,
const DropCallback& callback) {
- Result result = Remove(id);
- frontend_task_runner_->PostTask(FROM_HERE, base::Bind(callback, result));
-}
-
-AttachmentStore::Result FakeAttachmentStore::Backend::Remove(
- const AttachmentId& id) {
Result result = NOT_FOUND;
AttachmentMap::iterator iter = attachments_.find(id);
if (iter != attachments_.end()) {
- delete iter->second;
attachments_.erase(iter);
result = SUCCESS;
}
- return result;
+ frontend_task_runner_->PostTask(FROM_HERE, base::Bind(callback, result));
}
FakeAttachmentStore::FakeAttachmentStore(

Powered by Google App Engine
This is Rietveld 408576698