| 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 "sync/internal_api/public/attachments/attachment_store_frontend.h" | 5 #include "sync/internal_api/public/attachments/attachment_store_frontend.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/location.h" | 10 #include "base/location.h" |
| 9 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
| 10 #include "sync/api/attachments/attachment.h" | 12 #include "sync/api/attachments/attachment.h" |
| 11 #include "sync/api/attachments/attachment_store_backend.h" | 13 #include "sync/api/attachments/attachment_store_backend.h" |
| 12 | 14 |
| 13 namespace syncer { | 15 namespace syncer { |
| 14 | 16 |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| 17 // NoOp is needed to bind base::Passed(backend) in AttachmentStoreFrontend dtor. | 19 // NoOp is needed to bind base::Passed(backend) in AttachmentStoreFrontend dtor. |
| 18 // It doesn't need to do anything. | 20 // It doesn't need to do anything. |
| 19 void NoOp(scoped_ptr<AttachmentStoreBackend> backend) { | 21 void NoOp(scoped_ptr<AttachmentStoreBackend> backend) { |
| 20 } | 22 } |
| 21 | 23 |
| 22 } // namespace | 24 } // namespace |
| 23 | 25 |
| 24 AttachmentStoreFrontend::AttachmentStoreFrontend( | 26 AttachmentStoreFrontend::AttachmentStoreFrontend( |
| 25 scoped_ptr<AttachmentStoreBackend> backend, | 27 scoped_ptr<AttachmentStoreBackend> backend, |
| 26 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner) | 28 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner) |
| 27 : backend_(backend.Pass()), backend_task_runner_(backend_task_runner) { | 29 : backend_(std::move(backend)), backend_task_runner_(backend_task_runner) { |
| 28 DCHECK(backend_); | 30 DCHECK(backend_); |
| 29 DCHECK(backend_task_runner_.get()); | 31 DCHECK(backend_task_runner_.get()); |
| 30 } | 32 } |
| 31 | 33 |
| 32 AttachmentStoreFrontend::~AttachmentStoreFrontend() { | 34 AttachmentStoreFrontend::~AttachmentStoreFrontend() { |
| 33 DCHECK(backend_); | 35 DCHECK(backend_); |
| 34 // 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 |
| 35 // through base::Passed. This way backend will be deleted regardless whether | 37 // through base::Passed. This way backend will be deleted regardless whether |
| 36 // task runs or not. | 38 // task runs or not. |
| 37 backend_task_runner_->PostTask(FROM_HERE, | 39 backend_task_runner_->PostTask(FROM_HERE, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 AttachmentStore::Component component, | 104 AttachmentStore::Component component, |
| 103 const AttachmentStore::ReadMetadataCallback& callback) { | 105 const AttachmentStore::ReadMetadataCallback& callback) { |
| 104 DCHECK(CalledOnValidThread()); | 106 DCHECK(CalledOnValidThread()); |
| 105 backend_task_runner_->PostTask( | 107 backend_task_runner_->PostTask( |
| 106 FROM_HERE, | 108 FROM_HERE, |
| 107 base::Bind(&AttachmentStoreBackend::ReadMetadata, | 109 base::Bind(&AttachmentStoreBackend::ReadMetadata, |
| 108 base::Unretained(backend_.get()), component, callback)); | 110 base::Unretained(backend_.get()), component, callback)); |
| 109 } | 111 } |
| 110 | 112 |
| 111 } // namespace syncer | 113 } // namespace syncer |
| OLD | NEW |