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

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: Changes from self-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 22 matching lines...) Expand all
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 AttachmentServiceProxy::AttachmentServiceProxy( 41 AttachmentServiceProxy::AttachmentServiceProxy(
42 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, 42 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
43 base::WeakPtr<syncer::AttachmentService> wrapped) 43 const base::WeakPtr<syncer::AttachmentService>& wrapped)
44 : wrapped_task_runner_(wrapped_task_runner), wrapped_(wrapped) { 44 : wrapped_task_runner_(wrapped_task_runner),
45 core_(new ForwardingCore(wrapped)) {
45 DCHECK(wrapped_task_runner_); 46 DCHECK(wrapped_task_runner_);
46 } 47 }
47 48
49 AttachmentServiceProxy::AttachmentServiceProxy(
50 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
51 const scoped_refptr<ForwardingCore>& core)
52 : wrapped_task_runner_(wrapped_task_runner), core_(core) {
53 DCHECK(wrapped_task_runner_);
54 DCHECK(core_);
55 }
56
48 AttachmentServiceProxy::~AttachmentServiceProxy() {} 57 AttachmentServiceProxy::~AttachmentServiceProxy() {}
49 58
50 void AttachmentServiceProxy::GetOrDownloadAttachments( 59 void AttachmentServiceProxy::GetOrDownloadAttachments(
51 const AttachmentIdList& attachment_ids, 60 const AttachmentIdList& attachment_ids,
52 const GetOrDownloadCallback& callback) { 61 const GetOrDownloadCallback& callback) {
53 DCHECK(wrapped_task_runner_); 62 DCHECK(wrapped_task_runner_);
54 GetOrDownloadCallback proxy_callback = base::Bind( 63 GetOrDownloadCallback proxy_callback = base::Bind(
55 &ProxyGetOrDownloadCallback, base::MessageLoopProxy::current(), callback); 64 &ProxyGetOrDownloadCallback, base::MessageLoopProxy::current(), callback);
56 wrapped_task_runner_->PostTask( 65 wrapped_task_runner_->PostTask(
57 FROM_HERE, 66 FROM_HERE,
58 base::Bind(&AttachmentService::GetOrDownloadAttachments, 67 base::Bind(&AttachmentService::GetOrDownloadAttachments,
59 wrapped_, 68 core_,
60 attachment_ids, 69 attachment_ids,
61 proxy_callback)); 70 proxy_callback));
62 } 71 }
63 72
64 void AttachmentServiceProxy::DropAttachments( 73 void AttachmentServiceProxy::DropAttachments(
65 const AttachmentIdList& attachment_ids, 74 const AttachmentIdList& attachment_ids,
66 const DropCallback& callback) { 75 const DropCallback& callback) {
67 DCHECK(wrapped_task_runner_); 76 DCHECK(wrapped_task_runner_);
68 DropCallback proxy_callback = base::Bind( 77 DropCallback proxy_callback = base::Bind(
69 &ProxyDropCallback, base::MessageLoopProxy::current(), callback); 78 &ProxyDropCallback, base::MessageLoopProxy::current(), callback);
70 wrapped_task_runner_->PostTask(FROM_HERE, 79 wrapped_task_runner_->PostTask(FROM_HERE,
71 base::Bind(&AttachmentService::DropAttachments, 80 base::Bind(&AttachmentService::DropAttachments,
72 wrapped_, 81 core_,
73 attachment_ids, 82 attachment_ids,
74 proxy_callback)); 83 proxy_callback));
75 } 84 }
76 85
77 void AttachmentServiceProxy::OnSyncDataAdd(const SyncData& sync_data) { 86 void AttachmentServiceProxy::OnSyncDataAdd(const SyncData& sync_data) {
78 DCHECK(wrapped_task_runner_); 87 DCHECK(wrapped_task_runner_);
79 wrapped_task_runner_->PostTask( 88 wrapped_task_runner_->PostTask(
80 FROM_HERE, 89 FROM_HERE,
81 base::Bind(&AttachmentService::OnSyncDataAdd, wrapped_, sync_data)); 90 base::Bind(&AttachmentService::OnSyncDataAdd, core_, sync_data));
82 } 91 }
83 92
84 void AttachmentServiceProxy::OnSyncDataDelete(const SyncData& sync_data) { 93 void AttachmentServiceProxy::OnSyncDataDelete(const SyncData& sync_data) {
85 DCHECK(wrapped_task_runner_); 94 DCHECK(wrapped_task_runner_);
86 wrapped_task_runner_->PostTask( 95 wrapped_task_runner_->PostTask(
87 FROM_HERE, 96 FROM_HERE,
88 base::Bind(&AttachmentService::OnSyncDataDelete, wrapped_, sync_data)); 97 base::Bind(&AttachmentService::OnSyncDataDelete, core_, sync_data));
89 } 98 }
90 99
91 void AttachmentServiceProxy::OnSyncDataUpdate( 100 void AttachmentServiceProxy::OnSyncDataUpdate(
92 const AttachmentIdList& old_attachment_ids, 101 const AttachmentIdList& old_attachment_ids,
93 const SyncData& updated_sync_data) { 102 const SyncData& updated_sync_data) {
94 DCHECK(wrapped_task_runner_); 103 DCHECK(wrapped_task_runner_);
95 wrapped_task_runner_->PostTask( 104 wrapped_task_runner_->PostTask(
96 FROM_HERE, 105 FROM_HERE,
97 base::Bind(&AttachmentService::OnSyncDataUpdate, 106 base::Bind(&AttachmentService::OnSyncDataUpdate,
98 wrapped_, 107 core_,
99 old_attachment_ids, 108 old_attachment_ids,
100 updated_sync_data)); 109 updated_sync_data));
101 } 110 }
102 111
112 AttachmentServiceProxy::ForwardingCore::ForwardingCore(
113 const base::WeakPtr<syncer::AttachmentService>& wrapped)
114 : wrapped_(wrapped) {}
115
116 AttachmentServiceProxy::ForwardingCore::~ForwardingCore() {}
117
118 void AttachmentServiceProxy::ForwardingCore::GetOrDownloadAttachments(
119 const AttachmentIdList& attachment_ids,
120 const GetOrDownloadCallback& callback) {
121 if (!wrapped_) {
122 return;
123 }
124 wrapped_->GetOrDownloadAttachments(attachment_ids, callback);
125 }
126
127 void AttachmentServiceProxy::ForwardingCore::DropAttachments(
128 const AttachmentIdList& attachment_ids,
129 const DropCallback& callback) {
130 if (!wrapped_) {
131 return;
132 }
133 wrapped_->DropAttachments(attachment_ids, callback);
134 }
135
136 void AttachmentServiceProxy::ForwardingCore::OnSyncDataAdd(
137 const SyncData& sync_data) {
138 if (!wrapped_) {
139 return;
140 }
141 wrapped_->OnSyncDataAdd(sync_data);
142 }
143
144 void AttachmentServiceProxy::ForwardingCore::OnSyncDataDelete(
145 const SyncData& sync_data) {
146 if (!wrapped_) {
147 return;
148 }
149 wrapped_->OnSyncDataDelete(sync_data);
150 }
151
152 void AttachmentServiceProxy::ForwardingCore::OnSyncDataUpdate(
153 const AttachmentIdList& old_attachment_ids,
154 const SyncData& updated_sync_data) {
155 if (!wrapped_) {
156 return;
157 }
158 wrapped_->OnSyncDataUpdate(old_attachment_ids, updated_sync_data);
159 }
160
103 } // namespace syncer 161 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698