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..91b3f956f85593c33daa3da4441907bc6b6f7415 100644 |
--- a/sync/api/attachments/attachment_store.cc |
+++ b/sync/api/attachments/attachment_store.cc |
@@ -10,53 +10,16 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/sequenced_task_runner.h" |
#include "base/thread_task_runner_handle.h" |
-#include "sync/internal_api/public/attachments/attachment_store_frontend.h" |
+#include "sync/internal_api/public/attachments/attachment_store_handle.h" |
#include "sync/internal_api/public/attachments/in_memory_attachment_store.h" |
#include "sync/internal_api/public/attachments/on_disk_attachment_store.h" |
namespace syncer { |
-AttachmentStore::AttachmentStore( |
- const scoped_refptr<AttachmentStoreFrontend>& frontend, |
- AttachmentReferrer referrer) |
- : frontend_(frontend), referrer_(referrer) { |
-} |
+AttachmentStore::AttachmentStore() {} |
+AttachmentStore::~AttachmentStore() {} |
-AttachmentStore::~AttachmentStore() { |
-} |
- |
-void AttachmentStore::Read(const AttachmentIdList& ids, |
- const ReadCallback& callback) { |
- frontend_->Read(ids, callback); |
-} |
- |
-void AttachmentStore::Write(const AttachmentList& attachments, |
- const WriteCallback& callback) { |
- frontend_->Write(referrer_, attachments, callback); |
-} |
- |
-void AttachmentStore::Drop(const AttachmentIdList& ids, |
- const DropCallback& callback) { |
- frontend_->Drop(referrer_, ids, callback); |
-} |
- |
-void AttachmentStore::ReadMetadata(const AttachmentIdList& ids, |
- const ReadMetadataCallback& callback) { |
- frontend_->ReadMetadata(ids, callback); |
-} |
- |
-void AttachmentStore::ReadAllMetadata(const ReadMetadataCallback& callback) { |
- frontend_->ReadAllMetadata(referrer_, callback); |
-} |
- |
-scoped_ptr<AttachmentStore> AttachmentStore::CreateAttachmentStoreForSync() |
- const { |
- scoped_ptr<AttachmentStore> attachment_store( |
- new AttachmentStore(frontend_, SYNC)); |
- return attachment_store.Pass(); |
-} |
- |
-scoped_ptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() { |
+scoped_refptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() { |
// Both frontend and backend of attachment store will live on current thread. |
scoped_refptr<base::SingleThreadTaskRunner> runner; |
if (base::ThreadTaskRunnerHandle::IsSet()) { |
@@ -69,38 +32,34 @@ |
} |
scoped_ptr<AttachmentStoreBackend> backend( |
new InMemoryAttachmentStore(runner)); |
- scoped_refptr<AttachmentStoreFrontend> frontend( |
- new AttachmentStoreFrontend(backend.Pass(), runner)); |
- scoped_ptr<AttachmentStore> attachment_store( |
- new AttachmentStore(frontend, MODEL_TYPE)); |
- return attachment_store.Pass(); |
+ return scoped_refptr<AttachmentStore>( |
+ new AttachmentStoreHandle(backend.Pass(), runner)); |
} |
-scoped_ptr<AttachmentStore> AttachmentStore::CreateOnDiskStore( |
+scoped_refptr<AttachmentStore> AttachmentStore::CreateOnDiskStore( |
const base::FilePath& path, |
const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner, |
const InitCallback& callback) { |
scoped_ptr<OnDiskAttachmentStore> backend( |
new OnDiskAttachmentStore(base::ThreadTaskRunnerHandle::Get(), path)); |
- scoped_refptr<AttachmentStoreFrontend> frontend = |
- new AttachmentStoreFrontend(backend.Pass(), backend_task_runner); |
- scoped_ptr<AttachmentStore> attachment_store( |
- new AttachmentStore(frontend, MODEL_TYPE)); |
- frontend->Init(callback); |
+ scoped_refptr<AttachmentStore> attachment_store = |
+ new AttachmentStoreHandle(backend.Pass(), backend_task_runner); |
+ attachment_store->Init(callback); |
- return attachment_store.Pass(); |
+ return attachment_store; |
} |
-scoped_ptr<AttachmentStore> AttachmentStore::CreateMockStoreForTest( |
- scoped_ptr<AttachmentStoreBackend> backend) { |
- scoped_refptr<base::SingleThreadTaskRunner> runner = |
- base::ThreadTaskRunnerHandle::Get(); |
- scoped_refptr<AttachmentStoreFrontend> attachment_store_frontend( |
- new AttachmentStoreFrontend(backend.Pass(), runner)); |
- scoped_ptr<AttachmentStore> attachment_store( |
- new AttachmentStore(attachment_store_frontend, MODEL_TYPE)); |
- return attachment_store.Pass(); |
+AttachmentStoreBackend::AttachmentStoreBackend( |
+ const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner) |
+ : callback_task_runner_(callback_task_runner) { |
+} |
+ |
+AttachmentStoreBackend::~AttachmentStoreBackend() { |
+} |
+ |
+void AttachmentStoreBackend::PostCallback(const base::Closure& callback) { |
+ callback_task_runner_->PostTask(FROM_HERE, callback); |
} |
} // namespace syncer |