Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: sync/api/attachments/attachment_service_proxy.cc

Issue 264793007: Keep track of which attachments are referenced by which sync entries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leak. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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(const AttachmentList& attachments,
98 const StoreCallback& callback) {
89 DCHECK(wrapped_task_runner_); 99 DCHECK(wrapped_task_runner_);
100 StoreCallback proxy_callback = base::Bind(
101 &ProxyStoreCallback, base::MessageLoopProxy::current(), callback);
90 wrapped_task_runner_->PostTask( 102 wrapped_task_runner_->PostTask(
91 FROM_HERE, 103 FROM_HERE,
92 base::Bind(&AttachmentService::OnSyncDataAdd, core_, sync_data)); 104 base::Bind(&AttachmentService::StoreAttachments,
105 core_,
106 attachments,
107 proxy_callback));
93 } 108 }
94 109
95 void AttachmentServiceProxy::OnSyncDataDelete(const SyncData& sync_data) { 110 void AttachmentServiceProxy::OnSyncDataDelete(const SyncData& sync_data) {
96 DCHECK(wrapped_task_runner_); 111 DCHECK(wrapped_task_runner_);
97 wrapped_task_runner_->PostTask( 112 wrapped_task_runner_->PostTask(
98 FROM_HERE, 113 FROM_HERE,
99 base::Bind(&AttachmentService::OnSyncDataDelete, core_, sync_data)); 114 base::Bind(&AttachmentService::OnSyncDataDelete, core_, sync_data));
100 } 115 }
101 116
102 void AttachmentServiceProxy::OnSyncDataUpdate( 117 void AttachmentServiceProxy::OnSyncDataUpdate(
(...skipping 27 matching lines...) Expand all
130 145
131 void AttachmentServiceProxy::Core::DropAttachments( 146 void AttachmentServiceProxy::Core::DropAttachments(
132 const AttachmentIdList& attachment_ids, 147 const AttachmentIdList& attachment_ids,
133 const DropCallback& callback) { 148 const DropCallback& callback) {
134 if (!wrapped_) { 149 if (!wrapped_) {
135 return; 150 return;
136 } 151 }
137 wrapped_->DropAttachments(attachment_ids, callback); 152 wrapped_->DropAttachments(attachment_ids, callback);
138 } 153 }
139 154
140 void AttachmentServiceProxy::Core::OnSyncDataAdd(const SyncData& sync_data) { 155 void AttachmentServiceProxy::Core::StoreAttachments(
156 const AttachmentList& attachments,
157 const StoreCallback& callback) {
141 if (!wrapped_) { 158 if (!wrapped_) {
142 return; 159 return;
143 } 160 }
144 wrapped_->OnSyncDataAdd(sync_data); 161 wrapped_->StoreAttachments(attachments, callback);
145 } 162 }
146 163
147 void AttachmentServiceProxy::Core::OnSyncDataDelete(const SyncData& sync_data) { 164 void AttachmentServiceProxy::Core::OnSyncDataDelete(const SyncData& sync_data) {
148 if (!wrapped_) { 165 if (!wrapped_) {
149 return; 166 return;
150 } 167 }
151 wrapped_->OnSyncDataDelete(sync_data); 168 wrapped_->OnSyncDataDelete(sync_data);
152 } 169 }
153 170
154 void AttachmentServiceProxy::Core::OnSyncDataUpdate( 171 void AttachmentServiceProxy::Core::OnSyncDataUpdate(
155 const AttachmentIdList& old_attachment_ids, 172 const AttachmentIdList& old_attachment_ids,
156 const SyncData& updated_sync_data) { 173 const SyncData& updated_sync_data) {
157 if (!wrapped_) { 174 if (!wrapped_) {
158 return; 175 return;
159 } 176 }
160 wrapped_->OnSyncDataUpdate(old_attachment_ids, updated_sync_data); 177 wrapped_->OnSyncDataUpdate(old_attachment_ids, updated_sync_data);
161 } 178 }
162 179
163 } // namespace syncer 180 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/attachments/attachment_service_proxy.h ('k') | sync/api/attachments/attachment_service_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698