Remove unused parameter.
[chromium-blink-merge.git] / sync / internal_api / attachments / attachment_store_frontend.cc
blobb9d69950700911e85c4933cecd7b947c292bb91f
1 // Copyright 2015 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.
5 #include "sync/internal_api/public/attachments/attachment_store_frontend.h"
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 #include "sync/api/attachments/attachment_store_backend.h"
13 namespace syncer {
15 namespace {
17 // NoOp is needed to bind base::Passed(backend) in AttachmentStoreFrontend dtor.
18 // It doesn't need to do anything.
19 void NoOp(scoped_ptr<AttachmentStoreBackend> backend) {
22 } // namespace
24 AttachmentStoreFrontend::AttachmentStoreFrontend(
25 scoped_ptr<AttachmentStoreBackend> backend,
26 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner)
27 : backend_(backend.Pass()), backend_task_runner_(backend_task_runner) {
28 DCHECK(backend_);
29 DCHECK(backend_task_runner_.get());
32 AttachmentStoreFrontend::~AttachmentStoreFrontend() {
33 DCHECK(backend_);
34 // To delete backend post task that doesn't do anything, but binds backend
35 // through base::Passed. This way backend will be deleted regardless whether
36 // task runs or not.
37 backend_task_runner_->PostTask(FROM_HERE,
38 base::Bind(&NoOp, base::Passed(&backend_)));
41 void AttachmentStoreFrontend::Init(
42 const AttachmentStore::InitCallback& callback) {
43 DCHECK(CalledOnValidThread());
44 backend_task_runner_->PostTask(
45 FROM_HERE, base::Bind(&AttachmentStoreBackend::Init,
46 base::Unretained(backend_.get()), callback));
49 void AttachmentStoreFrontend::Read(
50 const AttachmentIdList& ids,
51 const AttachmentStore::ReadCallback& callback) {
52 DCHECK(CalledOnValidThread());
53 backend_task_runner_->PostTask(
54 FROM_HERE, base::Bind(&AttachmentStoreBackend::Read,
55 base::Unretained(backend_.get()), ids, callback));
58 void AttachmentStoreFrontend::Write(
59 AttachmentStore::Component component,
60 const AttachmentList& attachments,
61 const AttachmentStore::WriteCallback& callback) {
62 DCHECK(CalledOnValidThread());
63 backend_task_runner_->PostTask(
64 FROM_HERE, base::Bind(&AttachmentStoreBackend::Write,
65 base::Unretained(backend_.get()), component,
66 attachments, callback));
69 void AttachmentStoreFrontend::SetReference(AttachmentStore::Component component,
70 const AttachmentIdList& ids) {
71 DCHECK(CalledOnValidThread());
72 backend_task_runner_->PostTask(
73 FROM_HERE, base::Bind(&AttachmentStoreBackend::SetReference,
74 base::Unretained(backend_.get()), component, ids));
77 void AttachmentStoreFrontend::DropReference(
78 AttachmentStore::Component component,
79 const AttachmentIdList& ids,
80 const AttachmentStore::DropCallback& callback) {
81 DCHECK(CalledOnValidThread());
82 backend_task_runner_->PostTask(
83 FROM_HERE,
84 base::Bind(&AttachmentStoreBackend::DropReference,
85 base::Unretained(backend_.get()), component, ids, callback));
88 void AttachmentStoreFrontend::ReadMetadata(
89 const AttachmentIdList& ids,
90 const AttachmentStore::ReadMetadataCallback& callback) {
91 DCHECK(CalledOnValidThread());
92 backend_task_runner_->PostTask(
93 FROM_HERE, base::Bind(&AttachmentStoreBackend::ReadMetadata,
94 base::Unretained(backend_.get()), ids, callback));
97 void AttachmentStoreFrontend::ReadAllMetadata(
98 AttachmentStore::Component component,
99 const AttachmentStore::ReadMetadataCallback& callback) {
100 DCHECK(CalledOnValidThread());
101 backend_task_runner_->PostTask(
102 FROM_HERE,
103 base::Bind(&AttachmentStoreBackend::ReadAllMetadata,
104 base::Unretained(backend_.get()), component, callback));
107 } // namespace syncer