Chromium Code Reviews| Index: sync/internal_api/attachments/attachment_store_proxy.cc |
| diff --git a/sync/internal_api/attachments/attachment_store_proxy.cc b/sync/internal_api/attachments/attachment_store_proxy.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cfbe6cd10ca573c7e1f4feed90dc736cffa6af25 |
| --- /dev/null |
| +++ b/sync/internal_api/attachments/attachment_store_proxy.cc |
| @@ -0,0 +1,59 @@ |
| +// 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_proxy.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/location.h" |
| +#include "base/sequenced_task_runner.h" |
| +#include "sync/api/attachments/attachment.h" |
| + |
| +namespace syncer { |
| + |
| +AttachmentStoreProxy::AttachmentStoreProxy( |
| + scoped_ptr<AttachmentStoreBase> backend, |
| + const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner) |
| + : backend_(backend.Pass()), backend_task_runner_(backend_task_runner) { |
| + DCHECK(backend_); |
|
maniscalco
2014/09/29 20:57:52
DCHECK on task runner as well?
pavely
2014/09/29 23:27:08
Done.
|
| +} |
| + |
| +AttachmentStoreProxy::~AttachmentStoreProxy() { |
| + DCHECK(backend_); |
| + backend_task_runner_->DeleteSoon(FROM_HERE, backend_.release()); |
| +} |
| + |
| +void AttachmentStoreProxy::Read(const AttachmentIdList& ids, |
| + const ReadCallback& callback) { |
| + DCHECK(CalledOnValidThread()); |
| + DCHECK(backend_); |
|
maniscalco
2014/09/29 20:57:52
Since the ctor guarantees backend_ starts off as n
pavely
2014/09/29 23:27:08
Done.
|
| + backend_task_runner_->PostTask(FROM_HERE, |
| + base::Bind(&AttachmentStoreBase::Read, |
| + base::Unretained(backend_.get()), |
| + ids, |
| + callback)); |
| +} |
| + |
| +void AttachmentStoreProxy::Write(const AttachmentList& attachments, |
| + const WriteCallback& callback) { |
| + DCHECK(CalledOnValidThread()); |
| + DCHECK(backend_); |
| + backend_task_runner_->PostTask(FROM_HERE, |
| + base::Bind(&AttachmentStoreBase::Write, |
| + base::Unretained(backend_.get()), |
| + attachments, |
| + callback)); |
| +} |
| + |
| +void AttachmentStoreProxy::Drop(const AttachmentIdList& ids, |
| + const DropCallback& callback) { |
| + DCHECK(CalledOnValidThread()); |
| + DCHECK(backend_); |
| + backend_task_runner_->PostTask(FROM_HERE, |
| + base::Bind(&AttachmentStoreBase::Drop, |
| + base::Unretained(backend_.get()), |
| + ids, |
| + callback)); |
| +} |
| + |
| +} // namespace syncer |