Chromium Code Reviews| 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..78d06dc12ff045b2e80b287568ff140cd63ff299 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,46 @@ 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); |
| + } |
| + callback.Run(result, store); |
|
maniscalco
2014/10/17 00:00:19
It's not a big deal in this case, but in general i
|
| +} |
| + |
| } // namespace syncer |