| 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/api/attachments/attachment_service_proxy.h" | 5 #include "sync/api/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 "sync/api/sync_data.h" | 9 #include "sync/api/sync_data.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // Invokes |callback| with |result| and |attachments| in the |task_runner| | 29 // Invokes |callback| with |result| and |attachments| in the |task_runner| |
| 30 // thread. | 30 // thread. |
| 31 void ProxyDropCallback( | 31 void ProxyDropCallback( |
| 32 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 32 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 33 const AttachmentService::DropCallback& callback, | 33 const AttachmentService::DropCallback& callback, |
| 34 const AttachmentService::DropResult& result) { | 34 const AttachmentService::DropResult& result) { |
| 35 task_runner->PostTask(FROM_HERE, base::Bind(callback, result)); | 35 task_runner->PostTask(FROM_HERE, base::Bind(callback, result)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Invokes |callback| with |result| and |attachments| in the |task_runner| |
| 39 // thread. |
| 40 void ProxyStoreCallback( |
| 41 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 42 const AttachmentService::StoreCallback& callback, |
| 43 const AttachmentService::StoreResult& result) { |
| 44 task_runner->PostTask(FROM_HERE, base::Bind(callback, result)); |
| 45 } |
| 46 |
| 38 } // namespace | 47 } // namespace |
| 39 | 48 |
| 40 AttachmentServiceProxy::AttachmentServiceProxy() { | 49 AttachmentServiceProxy::AttachmentServiceProxy() { |
| 41 } | 50 } |
| 42 | 51 |
| 43 AttachmentServiceProxy::AttachmentServiceProxy( | 52 AttachmentServiceProxy::AttachmentServiceProxy( |
| 44 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, | 53 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, |
| 45 const base::WeakPtr<syncer::AttachmentService>& wrapped) | 54 const base::WeakPtr<syncer::AttachmentService>& wrapped) |
| 46 : wrapped_task_runner_(wrapped_task_runner), core_(new Core(wrapped)) { | 55 : wrapped_task_runner_(wrapped_task_runner), core_(new Core(wrapped)) { |
| 47 DCHECK(wrapped_task_runner_); | 56 DCHECK(wrapped_task_runner_); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 78 DCHECK(wrapped_task_runner_); | 87 DCHECK(wrapped_task_runner_); |
| 79 DropCallback proxy_callback = base::Bind( | 88 DropCallback proxy_callback = base::Bind( |
| 80 &ProxyDropCallback, base::MessageLoopProxy::current(), callback); | 89 &ProxyDropCallback, base::MessageLoopProxy::current(), callback); |
| 81 wrapped_task_runner_->PostTask(FROM_HERE, | 90 wrapped_task_runner_->PostTask(FROM_HERE, |
| 82 base::Bind(&AttachmentService::DropAttachments, | 91 base::Bind(&AttachmentService::DropAttachments, |
| 83 core_, | 92 core_, |
| 84 attachment_ids, | 93 attachment_ids, |
| 85 proxy_callback)); | 94 proxy_callback)); |
| 86 } | 95 } |
| 87 | 96 |
| 88 void AttachmentServiceProxy::OnSyncDataAdd(const SyncData& sync_data) { | 97 void AttachmentServiceProxy::StoreAttachments( |
| 98 const AttachmentList& attachments, |
| 99 const StoreCallback& callback) { |
| 89 DCHECK(wrapped_task_runner_); | 100 DCHECK(wrapped_task_runner_); |
| 101 StoreCallback proxy_callback = base::Bind( |
| 102 &ProxyStoreCallback, base::MessageLoopProxy::current(), callback); |
| 90 wrapped_task_runner_->PostTask( | 103 wrapped_task_runner_->PostTask( |
| 91 FROM_HERE, | 104 FROM_HERE, |
| 92 base::Bind(&AttachmentService::OnSyncDataAdd, core_, sync_data)); | 105 base::Bind(&AttachmentService::StoreAttachments, |
| 106 core_, |
| 107 attachments, |
| 108 proxy_callback)); |
| 93 } | 109 } |
| 94 | 110 |
| 95 void AttachmentServiceProxy::OnSyncDataDelete(const SyncData& sync_data) { | 111 void AttachmentServiceProxy::OnSyncDataDelete(const SyncData& sync_data) { |
| 96 DCHECK(wrapped_task_runner_); | 112 DCHECK(wrapped_task_runner_); |
| 97 wrapped_task_runner_->PostTask( | 113 wrapped_task_runner_->PostTask( |
| 98 FROM_HERE, | 114 FROM_HERE, |
| 99 base::Bind(&AttachmentService::OnSyncDataDelete, core_, sync_data)); | 115 base::Bind(&AttachmentService::OnSyncDataDelete, core_, sync_data)); |
| 100 } | 116 } |
| 101 | 117 |
| 102 void AttachmentServiceProxy::OnSyncDataUpdate( | 118 void AttachmentServiceProxy::OnSyncDataUpdate( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 130 | 146 |
| 131 void AttachmentServiceProxy::Core::DropAttachments( | 147 void AttachmentServiceProxy::Core::DropAttachments( |
| 132 const AttachmentIdList& attachment_ids, | 148 const AttachmentIdList& attachment_ids, |
| 133 const DropCallback& callback) { | 149 const DropCallback& callback) { |
| 134 if (!wrapped_) { | 150 if (!wrapped_) { |
| 135 return; | 151 return; |
| 136 } | 152 } |
| 137 wrapped_->DropAttachments(attachment_ids, callback); | 153 wrapped_->DropAttachments(attachment_ids, callback); |
| 138 } | 154 } |
| 139 | 155 |
| 140 void AttachmentServiceProxy::Core::OnSyncDataAdd(const SyncData& sync_data) { | 156 void AttachmentServiceProxy::Core::StoreAttachments( |
| 157 const AttachmentList& attachments, |
| 158 const StoreCallback& callback) { |
| 141 if (!wrapped_) { | 159 if (!wrapped_) { |
| 142 return; | 160 return; |
| 143 } | 161 } |
| 144 wrapped_->OnSyncDataAdd(sync_data); | 162 wrapped_->StoreAttachments(attachments, callback); |
| 145 } | 163 } |
| 146 | 164 |
| 147 void AttachmentServiceProxy::Core::OnSyncDataDelete(const SyncData& sync_data) { | 165 void AttachmentServiceProxy::Core::OnSyncDataDelete(const SyncData& sync_data) { |
| 148 if (!wrapped_) { | 166 if (!wrapped_) { |
| 149 return; | 167 return; |
| 150 } | 168 } |
| 151 wrapped_->OnSyncDataDelete(sync_data); | 169 wrapped_->OnSyncDataDelete(sync_data); |
| 152 } | 170 } |
| 153 | 171 |
| 154 void AttachmentServiceProxy::Core::OnSyncDataUpdate( | 172 void AttachmentServiceProxy::Core::OnSyncDataUpdate( |
| 155 const AttachmentIdList& old_attachment_ids, | 173 const AttachmentIdList& old_attachment_ids, |
| 156 const SyncData& updated_sync_data) { | 174 const SyncData& updated_sync_data) { |
| 157 if (!wrapped_) { | 175 if (!wrapped_) { |
| 158 return; | 176 return; |
| 159 } | 177 } |
| 160 wrapped_->OnSyncDataUpdate(old_attachment_ids, updated_sync_data); | 178 wrapped_->OnSyncDataUpdate(old_attachment_ids, updated_sync_data); |
| 161 } | 179 } |
| 162 | 180 |
| 163 } // namespace syncer | 181 } // namespace syncer |
| OLD | NEW |