| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_service_proxy.h" | 5 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 AttachmentServiceProxy::AttachmentServiceProxy() { | 49 AttachmentServiceProxy::AttachmentServiceProxy() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 AttachmentServiceProxy::AttachmentServiceProxy( | 52 AttachmentServiceProxy::AttachmentServiceProxy( |
| 53 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, | 53 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, |
| 54 const base::WeakPtr<syncer::AttachmentService>& wrapped) | 54 const base::WeakPtr<syncer::AttachmentService>& wrapped) |
| 55 : wrapped_task_runner_(wrapped_task_runner), core_(new Core(wrapped)) { | 55 : wrapped_task_runner_(wrapped_task_runner), core_(new Core(wrapped)) { |
| 56 DCHECK(wrapped_task_runner_); | 56 DCHECK(wrapped_task_runner_.get()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 AttachmentServiceProxy::AttachmentServiceProxy( | 59 AttachmentServiceProxy::AttachmentServiceProxy( |
| 60 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, | 60 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, |
| 61 const scoped_refptr<Core>& core) | 61 const scoped_refptr<Core>& core) |
| 62 : wrapped_task_runner_(wrapped_task_runner), core_(core) { | 62 : wrapped_task_runner_(wrapped_task_runner), core_(core) { |
| 63 DCHECK(wrapped_task_runner_); | 63 DCHECK(wrapped_task_runner_.get()); |
| 64 DCHECK(core_); | 64 DCHECK(core_.get()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 AttachmentServiceProxy::~AttachmentServiceProxy() { | 67 AttachmentServiceProxy::~AttachmentServiceProxy() { |
| 68 } | 68 } |
| 69 | 69 |
| 70 void AttachmentServiceProxy::GetOrDownloadAttachments( | 70 void AttachmentServiceProxy::GetOrDownloadAttachments( |
| 71 const AttachmentIdList& attachment_ids, | 71 const AttachmentIdList& attachment_ids, |
| 72 const GetOrDownloadCallback& callback) { | 72 const GetOrDownloadCallback& callback) { |
| 73 DCHECK(wrapped_task_runner_); | 73 DCHECK(wrapped_task_runner_.get()); |
| 74 GetOrDownloadCallback proxy_callback = | 74 GetOrDownloadCallback proxy_callback = |
| 75 base::Bind(&ProxyGetOrDownloadCallback, | 75 base::Bind(&ProxyGetOrDownloadCallback, |
| 76 base::ThreadTaskRunnerHandle::Get(), | 76 base::ThreadTaskRunnerHandle::Get(), |
| 77 callback); | 77 callback); |
| 78 wrapped_task_runner_->PostTask( | 78 wrapped_task_runner_->PostTask( |
| 79 FROM_HERE, | 79 FROM_HERE, |
| 80 base::Bind(&AttachmentService::GetOrDownloadAttachments, | 80 base::Bind(&AttachmentService::GetOrDownloadAttachments, |
| 81 core_, | 81 core_, |
| 82 attachment_ids, | 82 attachment_ids, |
| 83 proxy_callback)); | 83 proxy_callback)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void AttachmentServiceProxy::DropAttachments( | 86 void AttachmentServiceProxy::DropAttachments( |
| 87 const AttachmentIdList& attachment_ids, | 87 const AttachmentIdList& attachment_ids, |
| 88 const DropCallback& callback) { | 88 const DropCallback& callback) { |
| 89 DCHECK(wrapped_task_runner_); | 89 DCHECK(wrapped_task_runner_.get()); |
| 90 DropCallback proxy_callback = base::Bind( | 90 DropCallback proxy_callback = base::Bind( |
| 91 &ProxyDropCallback, base::ThreadTaskRunnerHandle::Get(), callback); | 91 &ProxyDropCallback, base::ThreadTaskRunnerHandle::Get(), callback); |
| 92 wrapped_task_runner_->PostTask(FROM_HERE, | 92 wrapped_task_runner_->PostTask(FROM_HERE, |
| 93 base::Bind(&AttachmentService::DropAttachments, | 93 base::Bind(&AttachmentService::DropAttachments, |
| 94 core_, | 94 core_, |
| 95 attachment_ids, | 95 attachment_ids, |
| 96 proxy_callback)); | 96 proxy_callback)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void AttachmentServiceProxy::StoreAttachments(const AttachmentList& attachments, | 99 void AttachmentServiceProxy::StoreAttachments(const AttachmentList& attachments, |
| 100 const StoreCallback& callback) { | 100 const StoreCallback& callback) { |
| 101 DCHECK(wrapped_task_runner_); | 101 DCHECK(wrapped_task_runner_.get()); |
| 102 StoreCallback proxy_callback = base::Bind( | 102 StoreCallback proxy_callback = base::Bind( |
| 103 &ProxyStoreCallback, base::ThreadTaskRunnerHandle::Get(), callback); | 103 &ProxyStoreCallback, base::ThreadTaskRunnerHandle::Get(), callback); |
| 104 wrapped_task_runner_->PostTask( | 104 wrapped_task_runner_->PostTask( |
| 105 FROM_HERE, | 105 FROM_HERE, |
| 106 base::Bind(&AttachmentService::StoreAttachments, | 106 base::Bind(&AttachmentService::StoreAttachments, |
| 107 core_, | 107 core_, |
| 108 attachments, | 108 attachments, |
| 109 proxy_callback)); | 109 proxy_callback)); |
| 110 } | 110 } |
| 111 | 111 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 138 void AttachmentServiceProxy::Core::StoreAttachments( | 138 void AttachmentServiceProxy::Core::StoreAttachments( |
| 139 const AttachmentList& attachments, | 139 const AttachmentList& attachments, |
| 140 const StoreCallback& callback) { | 140 const StoreCallback& callback) { |
| 141 if (!wrapped_) { | 141 if (!wrapped_) { |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 wrapped_->StoreAttachments(attachments, callback); | 144 wrapped_->StoreAttachments(attachments, callback); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace syncer | 147 } // namespace syncer |
| OLD | NEW |