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

Side by Side Diff: chrome/browser/sync/engine/syncer_proto_util.cc

Issue 371029: Remove unique naming. (Closed)
Patch Set: Ready and about to go in! Created 11 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/sync/engine/syncer_proto_util.h" 5 #include "chrome/browser/sync/engine/syncer_proto_util.h"
6 6
7 #include "chrome/browser/sync/engine/net/server_connection_manager.h" 7 #include "chrome/browser/sync/engine/net/server_connection_manager.h"
8 #include "chrome/browser/sync/engine/syncer.h" 8 #include "chrome/browser/sync/engine/syncer.h"
9 #include "chrome/browser/sync/engine/syncer_util.h" 9 #include "chrome/browser/sync/engine/syncer_util.h"
10 #include "chrome/browser/sync/protocol/service_constants.h" 10 #include "chrome/browser/sync/protocol/service_constants.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 break; 160 break;
161 } 161 }
162 162
163 } 163 }
164 return rv; 164 return rv;
165 } 165 }
166 166
167 // static 167 // static
168 bool SyncerProtoUtil::Compare(const syncable::Entry& local_entry, 168 bool SyncerProtoUtil::Compare(const syncable::Entry& local_entry,
169 const SyncEntity& server_entry) { 169 const SyncEntity& server_entry) {
170 SyncName name = NameFromSyncEntity(server_entry); 170 const std::string name = NameFromSyncEntity(server_entry);
171 171
172 CHECK(local_entry.Get(ID) == server_entry.id()) << 172 CHECK(local_entry.Get(ID) == server_entry.id()) <<
173 " SyncerProtoUtil::Compare precondition not met."; 173 " SyncerProtoUtil::Compare precondition not met.";
174 CHECK(server_entry.version() == local_entry.Get(BASE_VERSION)) << 174 CHECK(server_entry.version() == local_entry.Get(BASE_VERSION)) <<
175 " SyncerProtoUtil::Compare precondition not met."; 175 " SyncerProtoUtil::Compare precondition not met.";
176 CHECK(!local_entry.Get(IS_UNSYNCED)) << 176 CHECK(!local_entry.Get(IS_UNSYNCED)) <<
177 " SyncerProtoUtil::Compare precondition not met."; 177 " SyncerProtoUtil::Compare precondition not met.";
178 178
179 if (local_entry.Get(IS_DEL) && server_entry.deleted()) 179 if (local_entry.Get(IS_DEL) && server_entry.deleted())
180 return true; 180 return true;
181 if (!ClientAndServerTimeMatch(local_entry.Get(CTIME), server_entry.ctime())) { 181 if (!ClientAndServerTimeMatch(local_entry.Get(CTIME), server_entry.ctime())) {
182 LOG(WARNING) << "ctime mismatch"; 182 LOG(WARNING) << "ctime mismatch";
183 return false; 183 return false;
184 } 184 }
185 185
186 // These checks are somewhat prolix, but they're easier to debug than a big 186 // These checks are somewhat prolix, but they're easier to debug than a big
187 // boolean statement. 187 // boolean statement.
188 SyncName client_name = local_entry.GetName(); 188 PathString client_name = local_entry.Get(syncable::NON_UNIQUE_NAME);
189 if (client_name != name) { 189 if (client_name != name) {
190 LOG(WARNING) << "Client name mismatch"; 190 LOG(WARNING) << "Client name mismatch";
191 return false; 191 return false;
192 } 192 }
193 if (local_entry.Get(PARENT_ID) != server_entry.parent_id()) { 193 if (local_entry.Get(PARENT_ID) != server_entry.parent_id()) {
194 LOG(WARNING) << "Parent ID mismatch"; 194 LOG(WARNING) << "Parent ID mismatch";
195 return false; 195 return false;
196 } 196 }
197 if (local_entry.Get(IS_DIR) != server_entry.IsFolder()) { 197 if (local_entry.Get(IS_DIR) != server_entry.IsFolder()) {
198 LOG(WARNING) << "Dir field mismatch"; 198 LOG(WARNING) << "Dir field mismatch";
(...skipping 29 matching lines...) Expand all
228 } 228 }
229 229
230 // static 230 // static
231 void SyncerProtoUtil::CopyBlobIntoProtoBytes(const syncable::Blob& blob, 231 void SyncerProtoUtil::CopyBlobIntoProtoBytes(const syncable::Blob& blob,
232 std::string* proto_bytes) { 232 std::string* proto_bytes) {
233 std::string blob_string(blob.begin(), blob.end()); 233 std::string blob_string(blob.begin(), blob.end());
234 proto_bytes->swap(blob_string); 234 proto_bytes->swap(blob_string);
235 } 235 }
236 236
237 // static 237 // static
238 syncable::SyncName SyncerProtoUtil::NameFromSyncEntity( 238 std::string SyncerProtoUtil::NameFromSyncEntity(
239 const SyncEntity& entry) { 239 const SyncEntity& entry) {
240 SyncName result(entry.name()); 240
241 if (entry.has_non_unique_name()) { 241 if (entry.has_non_unique_name()) {
242 result.set_non_unique_value(entry.non_unique_name()); 242 return entry.non_unique_name();
243 } 243 }
244 return result; 244
245 return entry.name();
245 } 246 }
246 247
247 // static 248 // static
248 syncable::SyncName SyncerProtoUtil::NameFromCommitEntryResponse( 249 std::string SyncerProtoUtil::NameFromCommitEntryResponse(
249 const CommitResponse_EntryResponse& entry) { 250 const CommitResponse_EntryResponse& entry) {
250 SyncName result(entry.name()); 251
251 if (entry.has_non_unique_name()) { 252 if (entry.has_non_unique_name()) {
252 result.set_non_unique_value(entry.non_unique_name()); 253 return entry.non_unique_name();
253 } 254 }
254 return result; 255
256 return entry.name();
255 } 257 }
256 258
257 } // namespace browser_sync 259 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_proto_util.h ('k') | chrome/browser/sync/engine/syncer_proto_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698