| Index: sync/api/attachments/attachment_store.cc
|
| diff --git a/sync/api/attachments/attachment_store.cc b/sync/api/attachments/attachment_store.cc
|
| index ad4489e8d8db63b1d376b75d94fedc803599614f..df785bbf39f6242b391b5ab583a063b0427b6e7b 100644
|
| --- a/sync/api/attachments/attachment_store.cc
|
| +++ b/sync/api/attachments/attachment_store.cc
|
| @@ -4,9 +4,14 @@
|
|
|
| #include "sync/api/attachments/attachment_store.h"
|
|
|
| +#include "base/bind.h"
|
| +#include "base/callback.h"
|
| +#include "base/location.h"
|
| +#include "base/sequenced_task_runner.h"
|
| #include "base/thread_task_runner_handle.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 {
|
|
|
| @@ -24,4 +29,47 @@ scoped_refptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() {
|
| backend.Pass(), base::ThreadTaskRunnerHandle::Get()));
|
| }
|
|
|
| +void AttachmentStore::CreateOnDiskStore(
|
| + const base::FilePath& path,
|
| + const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner,
|
| + const CreateCallback& callback) {
|
| + scoped_refptr<base::SequencedTaskRunner> frontend_task_runner =
|
| + base::ThreadTaskRunnerHandle::Get();
|
| + backend_task_runner->PostTask(FROM_HERE,
|
| + base::Bind(&CreateOnDiskStoreOnBackendThread,
|
| + path,
|
| + frontend_task_runner,
|
| + callback));
|
| +}
|
| +
|
| +void AttachmentStore::CreateOnDiskStoreOnBackendThread(
|
| + const base::FilePath& path,
|
| + const scoped_refptr<base::SequencedTaskRunner>& frontend_task_runner,
|
| + const CreateCallback& callback) {
|
| + scoped_ptr<OnDiskAttachmentStore> store(
|
| + new OnDiskAttachmentStore(frontend_task_runner));
|
| + Result result = store->OpenOrCreate(path);
|
| + if (result != SUCCESS)
|
| + store.reset();
|
| + frontend_task_runner->PostTask(FROM_HERE,
|
| + base::Bind(&CreateBackendDone,
|
| + result,
|
| + base::Passed(&store),
|
| + base::ThreadTaskRunnerHandle::Get(),
|
| + callback));
|
| +}
|
| +
|
| +void AttachmentStore::CreateBackendDone(
|
| + const Result& result,
|
| + scoped_ptr<AttachmentStoreBase> backend,
|
| + const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner,
|
| + const CreateCallback& callback) {
|
| + scoped_refptr<AttachmentStore> store;
|
| + if (result == SUCCESS) {
|
| + store = new AttachmentStoreHandle(backend.Pass(), backend_task_runner);
|
| + }
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE, base::Bind(callback, result, store));
|
| +}
|
| +
|
| } // namespace syncer
|
|
|