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

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

Issue 652723003: Implementation of OnDiskAttachmentStore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More updates Created 6 years, 2 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/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
« no previous file with comments | « sync/api/attachments/attachment_store.h ('k') | sync/internal_api/attachments/attachment_store_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698