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

Unified Diff: sync/internal_api/attachments/attachment_store_handle.cc

Issue 601553004: Refactor FakeAttachmentStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes after feedback. Handle unittest. Created 6 years, 3 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/internal_api/attachments/attachment_store_handle.cc
diff --git a/sync/internal_api/attachments/attachment_store_handle.cc b/sync/internal_api/attachments/attachment_store_handle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d964c03442b5ca3ee723a9e65f5969d1304e5ff3
--- /dev/null
+++ b/sync/internal_api/attachments/attachment_store_handle.cc
@@ -0,0 +1,57 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/internal_api/public/attachments/attachment_store_handle.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/sequenced_task_runner.h"
+#include "sync/api/attachments/attachment.h"
+
+namespace syncer {
+
+AttachmentStoreHandle::AttachmentStoreHandle(
+ scoped_ptr<AttachmentStoreBase> backend,
+ const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner)
+ : backend_(backend.Pass()), backend_task_runner_(backend_task_runner) {
+ DCHECK(backend_);
+ DCHECK(backend_task_runner_.get());
+}
+
+AttachmentStoreHandle::~AttachmentStoreHandle() {
+ DCHECK(backend_);
+ backend_task_runner_->DeleteSoon(FROM_HERE, backend_.release());
+}
+
+void AttachmentStoreHandle::Read(const AttachmentIdList& ids,
+ const ReadCallback& callback) {
+ DCHECK(CalledOnValidThread());
+ backend_task_runner_->PostTask(FROM_HERE,
+ base::Bind(&AttachmentStoreBase::Read,
+ base::Unretained(backend_.get()),
+ ids,
+ callback));
+}
+
+void AttachmentStoreHandle::Write(const AttachmentList& attachments,
+ const WriteCallback& callback) {
+ DCHECK(CalledOnValidThread());
+ backend_task_runner_->PostTask(FROM_HERE,
+ base::Bind(&AttachmentStoreBase::Write,
+ base::Unretained(backend_.get()),
+ attachments,
+ callback));
+}
+
+void AttachmentStoreHandle::Drop(const AttachmentIdList& ids,
+ const DropCallback& callback) {
+ DCHECK(CalledOnValidThread());
+ backend_task_runner_->PostTask(FROM_HERE,
+ base::Bind(&AttachmentStoreBase::Drop,
+ base::Unretained(backend_.get()),
+ ids,
+ callback));
+}
+
+} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698