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 "base/thread_task_runner_handle.h" |
9 #include "sync/api/sync_data.h" | 10 #include "sync/api/sync_data.h" |
10 | 11 |
11 namespace syncer { | 12 namespace syncer { |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // These ProxyFooCallback functions are used to invoke a callback in a specific | 16 // These ProxyFooCallback functions are used to invoke a callback in a specific |
16 // thread. | 17 // thread. |
17 | 18 |
18 // Invokes |callback| with |result| and |attachments| in the |task_runner| | 19 // Invokes |callback| with |result| and |attachments| in the |task_runner| |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 DCHECK(core_); | 65 DCHECK(core_); |
65 } | 66 } |
66 | 67 |
67 AttachmentServiceProxy::~AttachmentServiceProxy() { | 68 AttachmentServiceProxy::~AttachmentServiceProxy() { |
68 } | 69 } |
69 | 70 |
70 void AttachmentServiceProxy::GetOrDownloadAttachments( | 71 void AttachmentServiceProxy::GetOrDownloadAttachments( |
71 const AttachmentIdList& attachment_ids, | 72 const AttachmentIdList& attachment_ids, |
72 const GetOrDownloadCallback& callback) { | 73 const GetOrDownloadCallback& callback) { |
73 DCHECK(wrapped_task_runner_); | 74 DCHECK(wrapped_task_runner_); |
74 GetOrDownloadCallback proxy_callback = base::Bind( | 75 GetOrDownloadCallback proxy_callback = |
75 &ProxyGetOrDownloadCallback, base::MessageLoopProxy::current(), callback); | 76 base::Bind(&ProxyGetOrDownloadCallback, |
| 77 base::ThreadTaskRunnerHandle::Get(), |
| 78 callback); |
76 wrapped_task_runner_->PostTask( | 79 wrapped_task_runner_->PostTask( |
77 FROM_HERE, | 80 FROM_HERE, |
78 base::Bind(&AttachmentService::GetOrDownloadAttachments, | 81 base::Bind(&AttachmentService::GetOrDownloadAttachments, |
79 core_, | 82 core_, |
80 attachment_ids, | 83 attachment_ids, |
81 proxy_callback)); | 84 proxy_callback)); |
82 } | 85 } |
83 | 86 |
84 void AttachmentServiceProxy::DropAttachments( | 87 void AttachmentServiceProxy::DropAttachments( |
85 const AttachmentIdList& attachment_ids, | 88 const AttachmentIdList& attachment_ids, |
86 const DropCallback& callback) { | 89 const DropCallback& callback) { |
87 DCHECK(wrapped_task_runner_); | 90 DCHECK(wrapped_task_runner_); |
88 DropCallback proxy_callback = base::Bind( | 91 DropCallback proxy_callback = base::Bind( |
89 &ProxyDropCallback, base::MessageLoopProxy::current(), callback); | 92 &ProxyDropCallback, base::ThreadTaskRunnerHandle::Get(), callback); |
90 wrapped_task_runner_->PostTask(FROM_HERE, | 93 wrapped_task_runner_->PostTask(FROM_HERE, |
91 base::Bind(&AttachmentService::DropAttachments, | 94 base::Bind(&AttachmentService::DropAttachments, |
92 core_, | 95 core_, |
93 attachment_ids, | 96 attachment_ids, |
94 proxy_callback)); | 97 proxy_callback)); |
95 } | 98 } |
96 | 99 |
97 void AttachmentServiceProxy::StoreAttachments(const AttachmentList& attachments, | 100 void AttachmentServiceProxy::StoreAttachments(const AttachmentList& attachments, |
98 const StoreCallback& callback) { | 101 const StoreCallback& callback) { |
99 DCHECK(wrapped_task_runner_); | 102 DCHECK(wrapped_task_runner_); |
100 StoreCallback proxy_callback = base::Bind( | 103 StoreCallback proxy_callback = base::Bind( |
101 &ProxyStoreCallback, base::MessageLoopProxy::current(), callback); | 104 &ProxyStoreCallback, base::ThreadTaskRunnerHandle::Get(), callback); |
102 wrapped_task_runner_->PostTask( | 105 wrapped_task_runner_->PostTask( |
103 FROM_HERE, | 106 FROM_HERE, |
104 base::Bind(&AttachmentService::StoreAttachments, | 107 base::Bind(&AttachmentService::StoreAttachments, |
105 core_, | 108 core_, |
106 attachments, | 109 attachments, |
107 proxy_callback)); | 110 proxy_callback)); |
108 } | 111 } |
109 | 112 |
110 AttachmentServiceProxy::Core::Core( | 113 AttachmentServiceProxy::Core::Core( |
111 const base::WeakPtr<syncer::AttachmentService>& wrapped) | 114 const base::WeakPtr<syncer::AttachmentService>& wrapped) |
(...skipping 24 matching lines...) Expand all Loading... |
136 void AttachmentServiceProxy::Core::StoreAttachments( | 139 void AttachmentServiceProxy::Core::StoreAttachments( |
137 const AttachmentList& attachments, | 140 const AttachmentList& attachments, |
138 const StoreCallback& callback) { | 141 const StoreCallback& callback) { |
139 if (!wrapped_) { | 142 if (!wrapped_) { |
140 return; | 143 return; |
141 } | 144 } |
142 wrapped_->StoreAttachments(attachments, callback); | 145 wrapped_->StoreAttachments(attachments, callback); |
143 } | 146 } |
144 | 147 |
145 } // namespace syncer | 148 } // namespace syncer |
OLD | NEW |