| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sync/internal_api/public/attachments/attachment_store_handle.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/location.h" | |
| 9 #include "base/sequenced_task_runner.h" | |
| 10 #include "sync/api/attachments/attachment.h" | |
| 11 | |
| 12 namespace syncer { | |
| 13 | |
| 14 AttachmentStoreHandle::AttachmentStoreHandle( | |
| 15 scoped_ptr<AttachmentStoreBase> backend, | |
| 16 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner) | |
| 17 : backend_(backend.Pass()), backend_task_runner_(backend_task_runner) { | |
| 18 DCHECK(backend_); | |
| 19 DCHECK(backend_task_runner_.get()); | |
| 20 } | |
| 21 | |
| 22 AttachmentStoreHandle::~AttachmentStoreHandle() { | |
| 23 DCHECK(backend_); | |
| 24 backend_task_runner_->DeleteSoon(FROM_HERE, backend_.release()); | |
| 25 } | |
| 26 | |
| 27 void AttachmentStoreHandle::Read(const AttachmentIdList& ids, | |
| 28 const ReadCallback& callback) { | |
| 29 DCHECK(CalledOnValidThread()); | |
| 30 backend_task_runner_->PostTask(FROM_HERE, | |
| 31 base::Bind(&AttachmentStoreBase::Read, | |
| 32 base::Unretained(backend_.get()), | |
| 33 ids, | |
| 34 callback)); | |
| 35 } | |
| 36 | |
| 37 void AttachmentStoreHandle::Write(const AttachmentList& attachments, | |
| 38 const WriteCallback& callback) { | |
| 39 DCHECK(CalledOnValidThread()); | |
| 40 backend_task_runner_->PostTask(FROM_HERE, | |
| 41 base::Bind(&AttachmentStoreBase::Write, | |
| 42 base::Unretained(backend_.get()), | |
| 43 attachments, | |
| 44 callback)); | |
| 45 } | |
| 46 | |
| 47 void AttachmentStoreHandle::Drop(const AttachmentIdList& ids, | |
| 48 const DropCallback& callback) { | |
| 49 DCHECK(CalledOnValidThread()); | |
| 50 backend_task_runner_->PostTask(FROM_HERE, | |
| 51 base::Bind(&AttachmentStoreBase::Drop, | |
| 52 base::Unretained(backend_.get()), | |
| 53 ids, | |
| 54 callback)); | |
| 55 } | |
| 56 | |
| 57 } // namespace syncer | |
| OLD | NEW |