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

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

Issue 213003004: Replace calls to 3-arg SyncData::CreateLocalData with 5-arg version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@syncapi
Patch Set: Apply feedback from review Created 6 years, 8 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
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 18 matching lines...) Expand all
29 // thread. 29 // thread.
30 void ProxyDropCallback( 30 void ProxyDropCallback(
31 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 31 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
32 const AttachmentService::DropCallback& callback, 32 const AttachmentService::DropCallback& callback,
33 const AttachmentService::DropResult& result) { 33 const AttachmentService::DropResult& result) {
34 task_runner->PostTask(FROM_HERE, base::Bind(callback, result)); 34 task_runner->PostTask(FROM_HERE, base::Bind(callback, result));
35 } 35 }
36 36
37 } // namespace 37 } // namespace
38 38
39 AttachmentServiceProxy::AttachmentServiceProxy() {} 39 AttachmentServiceProxy::AttachmentServiceProxy() {
40 }
40 41
41 AttachmentServiceProxy::AttachmentServiceProxy( 42 AttachmentServiceProxy::AttachmentServiceProxy(
42 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, 43 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
43 base::WeakPtr<syncer::AttachmentService> wrapped) 44 const base::WeakPtr<syncer::AttachmentService>& wrapped)
44 : wrapped_task_runner_(wrapped_task_runner), wrapped_(wrapped) { 45 : wrapped_task_runner_(wrapped_task_runner), core_(new Core(wrapped)) {
45 DCHECK(wrapped_task_runner_); 46 DCHECK(wrapped_task_runner_);
46 } 47 }
47 48
48 AttachmentServiceProxy::~AttachmentServiceProxy() {} 49 AttachmentServiceProxy::AttachmentServiceProxy(
50 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
51 const scoped_refptr<Core>& core)
52 : wrapped_task_runner_(wrapped_task_runner), core_(core) {
53 DCHECK(wrapped_task_runner_);
54 DCHECK(core_);
55 }
56
57 AttachmentServiceProxy::~AttachmentServiceProxy() {
58 }
49 59
50 void AttachmentServiceProxy::GetOrDownloadAttachments( 60 void AttachmentServiceProxy::GetOrDownloadAttachments(
51 const AttachmentIdList& attachment_ids, 61 const AttachmentIdList& attachment_ids,
52 const GetOrDownloadCallback& callback) { 62 const GetOrDownloadCallback& callback) {
53 DCHECK(wrapped_task_runner_); 63 DCHECK(wrapped_task_runner_);
54 GetOrDownloadCallback proxy_callback = base::Bind( 64 GetOrDownloadCallback proxy_callback = base::Bind(
55 &ProxyGetOrDownloadCallback, base::MessageLoopProxy::current(), callback); 65 &ProxyGetOrDownloadCallback, base::MessageLoopProxy::current(), callback);
56 wrapped_task_runner_->PostTask( 66 wrapped_task_runner_->PostTask(
57 FROM_HERE, 67 FROM_HERE,
58 base::Bind(&AttachmentService::GetOrDownloadAttachments, 68 base::Bind(&AttachmentService::GetOrDownloadAttachments,
59 wrapped_, 69 core_,
60 attachment_ids, 70 attachment_ids,
61 proxy_callback)); 71 proxy_callback));
62 } 72 }
63 73
64 void AttachmentServiceProxy::DropAttachments( 74 void AttachmentServiceProxy::DropAttachments(
65 const AttachmentIdList& attachment_ids, 75 const AttachmentIdList& attachment_ids,
66 const DropCallback& callback) { 76 const DropCallback& callback) {
67 DCHECK(wrapped_task_runner_); 77 DCHECK(wrapped_task_runner_);
68 DropCallback proxy_callback = base::Bind( 78 DropCallback proxy_callback = base::Bind(
69 &ProxyDropCallback, base::MessageLoopProxy::current(), callback); 79 &ProxyDropCallback, base::MessageLoopProxy::current(), callback);
70 wrapped_task_runner_->PostTask(FROM_HERE, 80 wrapped_task_runner_->PostTask(FROM_HERE,
71 base::Bind(&AttachmentService::DropAttachments, 81 base::Bind(&AttachmentService::DropAttachments,
72 wrapped_, 82 core_,
73 attachment_ids, 83 attachment_ids,
74 proxy_callback)); 84 proxy_callback));
75 } 85 }
76 86
77 void AttachmentServiceProxy::OnSyncDataAdd(const SyncData& sync_data) { 87 void AttachmentServiceProxy::OnSyncDataAdd(const SyncData& sync_data) {
78 DCHECK(wrapped_task_runner_); 88 DCHECK(wrapped_task_runner_);
79 wrapped_task_runner_->PostTask( 89 wrapped_task_runner_->PostTask(
80 FROM_HERE, 90 FROM_HERE,
81 base::Bind(&AttachmentService::OnSyncDataAdd, wrapped_, sync_data)); 91 base::Bind(&AttachmentService::OnSyncDataAdd, core_, sync_data));
82 } 92 }
83 93
84 void AttachmentServiceProxy::OnSyncDataDelete(const SyncData& sync_data) { 94 void AttachmentServiceProxy::OnSyncDataDelete(const SyncData& sync_data) {
85 DCHECK(wrapped_task_runner_); 95 DCHECK(wrapped_task_runner_);
86 wrapped_task_runner_->PostTask( 96 wrapped_task_runner_->PostTask(
87 FROM_HERE, 97 FROM_HERE,
88 base::Bind(&AttachmentService::OnSyncDataDelete, wrapped_, sync_data)); 98 base::Bind(&AttachmentService::OnSyncDataDelete, core_, sync_data));
89 } 99 }
90 100
91 void AttachmentServiceProxy::OnSyncDataUpdate( 101 void AttachmentServiceProxy::OnSyncDataUpdate(
92 const AttachmentIdList& old_attachment_ids, 102 const AttachmentIdList& old_attachment_ids,
93 const SyncData& updated_sync_data) { 103 const SyncData& updated_sync_data) {
94 DCHECK(wrapped_task_runner_); 104 DCHECK(wrapped_task_runner_);
95 wrapped_task_runner_->PostTask( 105 wrapped_task_runner_->PostTask(
96 FROM_HERE, 106 FROM_HERE,
97 base::Bind(&AttachmentService::OnSyncDataUpdate, 107 base::Bind(&AttachmentService::OnSyncDataUpdate,
98 wrapped_, 108 core_,
99 old_attachment_ids, 109 old_attachment_ids,
100 updated_sync_data)); 110 updated_sync_data));
101 } 111 }
102 112
113 AttachmentServiceProxy::Core::Core(
114 const base::WeakPtr<syncer::AttachmentService>& wrapped)
115 : wrapped_(wrapped) {
116 }
117
118 AttachmentServiceProxy::Core::~Core() {
119 }
120
121 void AttachmentServiceProxy::Core::GetOrDownloadAttachments(
122 const AttachmentIdList& attachment_ids,
123 const GetOrDownloadCallback& callback) {
124 if (!wrapped_) {
125 return;
126 }
127 wrapped_->GetOrDownloadAttachments(attachment_ids, callback);
128 }
129
130 void AttachmentServiceProxy::Core::DropAttachments(
131 const AttachmentIdList& attachment_ids,
132 const DropCallback& callback) {
133 if (!wrapped_) {
134 return;
135 }
136 wrapped_->DropAttachments(attachment_ids, callback);
137 }
138
139 void AttachmentServiceProxy::Core::OnSyncDataAdd(const SyncData& sync_data) {
140 if (!wrapped_) {
141 return;
142 }
143 wrapped_->OnSyncDataAdd(sync_data);
144 }
145
146 void AttachmentServiceProxy::Core::OnSyncDataDelete(const SyncData& sync_data) {
147 if (!wrapped_) {
148 return;
149 }
150 wrapped_->OnSyncDataDelete(sync_data);
151 }
152
153 void AttachmentServiceProxy::Core::OnSyncDataUpdate(
154 const AttachmentIdList& old_attachment_ids,
155 const SyncData& updated_sync_data) {
156 if (!wrapped_) {
157 return;
158 }
159 wrapped_->OnSyncDataUpdate(old_attachment_ids, updated_sync_data);
160 }
161
103 } // namespace syncer 162 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/attachments/attachment_service_proxy.h ('k') | sync/api/attachments/attachment_service_proxy_for_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698