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

Side by Side Diff: sync/api/sync_data.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: Forgot a class keyword. 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/sync_data.h" 5 #include "sync/api/sync_data.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return *wrapper; 58 return *wrapper;
59 } 59 }
60 60
61 void SyncData::ImmutableSyncEntityTraits::Swap(sync_pb::SyncEntity* t1, 61 void SyncData::ImmutableSyncEntityTraits::Swap(sync_pb::SyncEntity* t1,
62 sync_pb::SyncEntity* t2) { 62 sync_pb::SyncEntity* t2) {
63 t1->Swap(t2); 63 t1->Swap(t2);
64 } 64 }
65 65
66 SyncData::SyncData() : id_(kInvalidId), is_valid_(false) {} 66 SyncData::SyncData() : id_(kInvalidId), is_valid_(false) {}
67 67
68 SyncData::SyncData(int64 id, 68 SyncData::SyncData(
69 sync_pb::SyncEntity* entity, 69 int64 id,
70 AttachmentList* attachments, 70 sync_pb::SyncEntity* entity,
71 const base::Time& remote_modification_time, 71 AttachmentList* attachments,
72 const syncer::AttachmentServiceProxy& attachment_service) 72 const base::Time& remote_modification_time,
73 const scoped_refptr<syncer::AttachmentServiceProxy>& attachment_service)
73 : id_(id), 74 : id_(id),
74 remote_modification_time_(remote_modification_time), 75 remote_modification_time_(remote_modification_time),
75 immutable_entity_(entity), 76 immutable_entity_(entity),
76 attachments_(attachments), 77 attachments_(attachments),
77 attachment_service_(attachment_service), 78 attachment_service_(attachment_service),
78 is_valid_(true) {} 79 is_valid_(true) {
80 DCHECK(attachment_service_);
81 }
79 82
80 SyncData::~SyncData() {} 83 SyncData::~SyncData() {}
81 84
82 // Static. 85 // Static.
83 SyncData SyncData::CreateLocalDelete(const std::string& sync_tag, 86 SyncData SyncData::CreateLocalDelete(const std::string& sync_tag,
84 ModelType datatype) { 87 ModelType datatype) {
85 sync_pb::EntitySpecifics specifics; 88 sync_pb::EntitySpecifics specifics;
86 AddDefaultFieldValue(datatype, &specifics); 89 AddDefaultFieldValue(datatype, &specifics);
87 return CreateLocalData(sync_tag, std::string(), specifics); 90 return CreateLocalData(sync_tag, std::string(), specifics);
88 } 91 }
(...skipping 21 matching lines...) Expand all
110 entity.set_non_unique_name(non_unique_title); 113 entity.set_non_unique_name(non_unique_title);
111 entity.mutable_specifics()->CopyFrom(specifics); 114 entity.mutable_specifics()->CopyFrom(specifics);
112 std::transform(attachments.begin(), 115 std::transform(attachments.begin(),
113 attachments.end(), 116 attachments.end(),
114 RepeatedFieldBackInserter(entity.mutable_attachment_id()), 117 RepeatedFieldBackInserter(entity.mutable_attachment_id()),
115 AttachmentToProto); 118 AttachmentToProto);
116 // TODO(maniscalco): Actually pass the attachments to the ctor and make them 119 // TODO(maniscalco): Actually pass the attachments to the ctor and make them
117 // available to the AttachmentService once this SyncData gets passed into 120 // available to the AttachmentService once this SyncData gets passed into
118 // GenericChangeProcesso::ProcessSyncChanges (bug 354530). 121 // GenericChangeProcesso::ProcessSyncChanges (bug 354530).
119 AttachmentList copy_of_attachments(attachments); 122 AttachmentList copy_of_attachments(attachments);
120 return SyncData(kInvalidId, 123 scoped_refptr<AttachmentServiceProxy> proxy(new AttachmentServiceProxy);
121 &entity, 124 return SyncData(
122 &copy_of_attachments, 125 kInvalidId, &entity, &copy_of_attachments, base::Time(), proxy);
123 base::Time(),
124 AttachmentServiceProxy());
125 } 126 }
126 127
127 // Static. 128 // Static.
128 SyncData SyncData::CreateRemoteData( 129 SyncData SyncData::CreateRemoteData(
129 int64 id, 130 int64 id,
130 const sync_pb::EntitySpecifics& specifics, 131 const sync_pb::EntitySpecifics& specifics,
131 const base::Time& modification_time, 132 const base::Time& modification_time,
132 const AttachmentIdList& attachment_ids, 133 const AttachmentIdList& attachment_ids,
133 const AttachmentServiceProxy& attachment_service) { 134 const scoped_refptr<AttachmentServiceProxy>& attachment_service) {
134 DCHECK_NE(id, kInvalidId); 135 DCHECK_NE(id, kInvalidId);
135 sync_pb::SyncEntity entity; 136 sync_pb::SyncEntity entity;
136 entity.mutable_specifics()->CopyFrom(specifics); 137 entity.mutable_specifics()->CopyFrom(specifics);
137 std::transform(attachment_ids.begin(), 138 std::transform(attachment_ids.begin(),
138 attachment_ids.end(), 139 attachment_ids.end(),
139 RepeatedFieldBackInserter(entity.mutable_attachment_id()), 140 RepeatedFieldBackInserter(entity.mutable_attachment_id()),
140 IdToProto); 141 IdToProto);
141 AttachmentList attachments; 142 AttachmentList attachments;
142 return SyncData( 143 return SyncData(
143 id, &entity, &attachments, modification_time, attachment_service); 144 id, &entity, &attachments, modification_time, attachment_service);
144 } 145 }
145 146
146 // Static.
147 SyncData SyncData::CreateRemoteData(int64 id,
148 const sync_pb::EntitySpecifics& specifics,
149 const base::Time& modification_time) {
150 return CreateRemoteData(id,
151 specifics,
152 modification_time,
153 AttachmentIdList(),
154 AttachmentServiceProxy());
155 }
156
157 bool SyncData::IsValid() const { return is_valid_; } 147 bool SyncData::IsValid() const { return is_valid_; }
158 148
159 const sync_pb::EntitySpecifics& SyncData::GetSpecifics() const { 149 const sync_pb::EntitySpecifics& SyncData::GetSpecifics() const {
160 return immutable_entity_.Get().specifics(); 150 return immutable_entity_.Get().specifics();
161 } 151 }
162 152
163 ModelType SyncData::GetDataType() const { 153 ModelType SyncData::GetDataType() const {
164 return GetModelTypeFromSpecifics(GetSpecifics()); 154 return GetModelTypeFromSpecifics(GetSpecifics());
165 } 155 }
166 156
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 return remote_modification_time_; 225 return remote_modification_time_;
236 } 226 }
237 227
238 int64 SyncDataRemote::GetId() const { 228 int64 SyncDataRemote::GetId() const {
239 return id_; 229 return id_;
240 } 230 }
241 231
242 void SyncDataRemote::GetOrDownloadAttachments( 232 void SyncDataRemote::GetOrDownloadAttachments(
243 const AttachmentIdList& attachment_ids, 233 const AttachmentIdList& attachment_ids,
244 const AttachmentService::GetOrDownloadCallback& callback) { 234 const AttachmentService::GetOrDownloadCallback& callback) {
245 attachment_service_.GetOrDownloadAttachments(attachment_ids, callback); 235 attachment_service_->GetOrDownloadAttachments(attachment_ids, callback);
246 } 236 }
247 237
248 void SyncDataRemote::DropAttachments( 238 void SyncDataRemote::DropAttachments(
249 const AttachmentIdList& attachment_ids, 239 const AttachmentIdList& attachment_ids,
250 const AttachmentService::DropCallback& callback) { 240 const AttachmentService::DropCallback& callback) {
251 attachment_service_.DropAttachments(attachment_ids, callback); 241 attachment_service_->DropAttachments(attachment_ids, callback);
252 } 242 }
253 243
254 } // namespace syncer 244 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698