| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/sync/engine/attachments/attachment_store_frontend.h" | 5 #include "components/sync/engine/attachments/attachment_store_frontend.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 AttachmentStoreFrontend::AttachmentStoreFrontend( | 25 AttachmentStoreFrontend::AttachmentStoreFrontend( |
| 26 std::unique_ptr<AttachmentStoreBackend> backend, | 26 std::unique_ptr<AttachmentStoreBackend> backend, |
| 27 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner) | 27 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner) |
| 28 : backend_(std::move(backend)), backend_task_runner_(backend_task_runner) { | 28 : backend_(std::move(backend)), backend_task_runner_(backend_task_runner) { |
| 29 DCHECK(backend_); | 29 DCHECK(backend_); |
| 30 DCHECK(backend_task_runner_.get()); | 30 DCHECK(backend_task_runner_.get()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 AttachmentStoreFrontend::~AttachmentStoreFrontend() { | 33 AttachmentStoreFrontend::~AttachmentStoreFrontend() { |
| 34 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 34 DCHECK(backend_); | 35 DCHECK(backend_); |
| 35 // To delete backend post task that doesn't do anything, but binds backend | 36 // To delete backend post task that doesn't do anything, but binds backend |
| 36 // through base::Passed. This way backend will be deleted regardless whether | 37 // through base::Passed. This way backend will be deleted regardless whether |
| 37 // task runs or not. | 38 // task runs or not. |
| 38 backend_task_runner_->PostTask(FROM_HERE, | 39 backend_task_runner_->PostTask(FROM_HERE, |
| 39 base::Bind(&NoOp, base::Passed(&backend_))); | 40 base::Bind(&NoOp, base::Passed(&backend_))); |
| 40 } | 41 } |
| 41 | 42 |
| 42 void AttachmentStoreFrontend::Init( | 43 void AttachmentStoreFrontend::Init( |
| 43 const AttachmentStore::InitCallback& callback) { | 44 const AttachmentStore::InitCallback& callback) { |
| 44 DCHECK(CalledOnValidThread()); | 45 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 45 backend_task_runner_->PostTask( | 46 backend_task_runner_->PostTask( |
| 46 FROM_HERE, base::Bind(&AttachmentStoreBackend::Init, | 47 FROM_HERE, base::Bind(&AttachmentStoreBackend::Init, |
| 47 base::Unretained(backend_.get()), callback)); | 48 base::Unretained(backend_.get()), callback)); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void AttachmentStoreFrontend::Read( | 51 void AttachmentStoreFrontend::Read( |
| 51 AttachmentStore::Component component, | 52 AttachmentStore::Component component, |
| 52 const AttachmentIdList& ids, | 53 const AttachmentIdList& ids, |
| 53 const AttachmentStore::ReadCallback& callback) { | 54 const AttachmentStore::ReadCallback& callback) { |
| 54 DCHECK(CalledOnValidThread()); | 55 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 55 backend_task_runner_->PostTask( | 56 backend_task_runner_->PostTask( |
| 56 FROM_HERE, | 57 FROM_HERE, |
| 57 base::Bind(&AttachmentStoreBackend::Read, | 58 base::Bind(&AttachmentStoreBackend::Read, |
| 58 base::Unretained(backend_.get()), component, ids, callback)); | 59 base::Unretained(backend_.get()), component, ids, callback)); |
| 59 } | 60 } |
| 60 | 61 |
| 61 void AttachmentStoreFrontend::Write( | 62 void AttachmentStoreFrontend::Write( |
| 62 AttachmentStore::Component component, | 63 AttachmentStore::Component component, |
| 63 const AttachmentList& attachments, | 64 const AttachmentList& attachments, |
| 64 const AttachmentStore::WriteCallback& callback) { | 65 const AttachmentStore::WriteCallback& callback) { |
| 65 DCHECK(CalledOnValidThread()); | 66 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 66 backend_task_runner_->PostTask( | 67 backend_task_runner_->PostTask( |
| 67 FROM_HERE, base::Bind(&AttachmentStoreBackend::Write, | 68 FROM_HERE, base::Bind(&AttachmentStoreBackend::Write, |
| 68 base::Unretained(backend_.get()), component, | 69 base::Unretained(backend_.get()), component, |
| 69 attachments, callback)); | 70 attachments, callback)); |
| 70 } | 71 } |
| 71 | 72 |
| 72 void AttachmentStoreFrontend::SetReference(AttachmentStore::Component component, | 73 void AttachmentStoreFrontend::SetReference(AttachmentStore::Component component, |
| 73 const AttachmentIdList& ids) { | 74 const AttachmentIdList& ids) { |
| 74 DCHECK(CalledOnValidThread()); | 75 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 75 backend_task_runner_->PostTask( | 76 backend_task_runner_->PostTask( |
| 76 FROM_HERE, base::Bind(&AttachmentStoreBackend::SetReference, | 77 FROM_HERE, base::Bind(&AttachmentStoreBackend::SetReference, |
| 77 base::Unretained(backend_.get()), component, ids)); | 78 base::Unretained(backend_.get()), component, ids)); |
| 78 } | 79 } |
| 79 | 80 |
| 80 void AttachmentStoreFrontend::DropReference( | 81 void AttachmentStoreFrontend::DropReference( |
| 81 AttachmentStore::Component component, | 82 AttachmentStore::Component component, |
| 82 const AttachmentIdList& ids, | 83 const AttachmentIdList& ids, |
| 83 const AttachmentStore::DropCallback& callback) { | 84 const AttachmentStore::DropCallback& callback) { |
| 84 DCHECK(CalledOnValidThread()); | 85 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 85 backend_task_runner_->PostTask( | 86 backend_task_runner_->PostTask( |
| 86 FROM_HERE, | 87 FROM_HERE, |
| 87 base::Bind(&AttachmentStoreBackend::DropReference, | 88 base::Bind(&AttachmentStoreBackend::DropReference, |
| 88 base::Unretained(backend_.get()), component, ids, callback)); | 89 base::Unretained(backend_.get()), component, ids, callback)); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void AttachmentStoreFrontend::ReadMetadataById( | 92 void AttachmentStoreFrontend::ReadMetadataById( |
| 92 AttachmentStore::Component component, | 93 AttachmentStore::Component component, |
| 93 const AttachmentIdList& ids, | 94 const AttachmentIdList& ids, |
| 94 const AttachmentStore::ReadMetadataCallback& callback) { | 95 const AttachmentStore::ReadMetadataCallback& callback) { |
| 95 DCHECK(CalledOnValidThread()); | 96 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 96 backend_task_runner_->PostTask( | 97 backend_task_runner_->PostTask( |
| 97 FROM_HERE, | 98 FROM_HERE, |
| 98 base::Bind(&AttachmentStoreBackend::ReadMetadataById, | 99 base::Bind(&AttachmentStoreBackend::ReadMetadataById, |
| 99 base::Unretained(backend_.get()), component, ids, callback)); | 100 base::Unretained(backend_.get()), component, ids, callback)); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void AttachmentStoreFrontend::ReadMetadata( | 103 void AttachmentStoreFrontend::ReadMetadata( |
| 103 AttachmentStore::Component component, | 104 AttachmentStore::Component component, |
| 104 const AttachmentStore::ReadMetadataCallback& callback) { | 105 const AttachmentStore::ReadMetadataCallback& callback) { |
| 105 DCHECK(CalledOnValidThread()); | 106 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 106 backend_task_runner_->PostTask( | 107 backend_task_runner_->PostTask( |
| 107 FROM_HERE, | 108 FROM_HERE, |
| 108 base::Bind(&AttachmentStoreBackend::ReadMetadata, | 109 base::Bind(&AttachmentStoreBackend::ReadMetadata, |
| 109 base::Unretained(backend_.get()), component, callback)); | 110 base::Unretained(backend_.get()), component, callback)); |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace syncer | 113 } // namespace syncer |
| OLD | NEW |