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

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

Issue 9305001: sync: Remove the remaining conflict sets code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Additional comments Created 8 years, 10 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_util.h" 5 #include "chrome/browser/sync/engine/syncer_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // Passwords use their own legacy encryption scheme. 326 // Passwords use their own legacy encryption scheme.
327 const sync_pb::PasswordSpecifics& password = 327 const sync_pb::PasswordSpecifics& password =
328 specifics.GetExtension(sync_pb::password); 328 specifics.GetExtension(sync_pb::password);
329 if (!cryptographer->CanDecrypt(password.encrypted())) { 329 if (!cryptographer->CanDecrypt(password.encrypted())) {
330 DVLOG(1) << "Received an undecryptable password update, returning " 330 DVLOG(1) << "Received an undecryptable password update, returning "
331 << "encryption_conflict."; 331 << "encryption_conflict.";
332 return CONFLICT_ENCRYPTION; 332 return CONFLICT_ENCRYPTION;
333 } 333 }
334 } 334 }
335 335
336 if (entry->Get(IS_UNSYNCED)) {
337 DVLOG(1) << "Skipping update, returning conflict for: " << id
338 << " ; it's unsynced.";
339 return CONFLICT;
340 }
341 if (!entry->Get(SERVER_IS_DEL)) { 336 if (!entry->Get(SERVER_IS_DEL)) {
342 syncable::Id new_parent = entry->Get(SERVER_PARENT_ID); 337 syncable::Id new_parent = entry->Get(SERVER_PARENT_ID);
343 Entry parent(trans, GET_BY_ID, new_parent); 338 Entry parent(trans, GET_BY_ID, new_parent);
344 // A note on non-directory parents: 339 // A note on non-directory parents:
345 // We catch most unfixable tree invariant errors at update receipt time, 340 // We catch most unfixable tree invariant errors at update receipt time,
346 // however we deal with this case here because we may receive the child 341 // however we deal with this case here because we may receive the child
347 // first then the illegal parent. Instead of dealing with it twice in 342 // first then the illegal parent. Instead of dealing with it twice in
348 // different ways we deal with it once here to reduce the amount of code and 343 // different ways we deal with it once here to reduce the amount of code and
349 // potential errors. 344 // potential errors.
350 if (!parent.good() || parent.Get(IS_DEL) || !parent.Get(IS_DIR)) { 345 if (!parent.good() || parent.Get(IS_DEL) || !parent.Get(IS_DIR)) {
351 return CONFLICT; 346 return HIERARCHY_CONFLICT;
rlarocque 2012/01/31 19:12:17 There is a subtle side-effect to this change, whic
Nicolas Zea 2012/02/01 19:16:19 So I'm clear, the only side effect here is that we
rlarocque 2012/02/02 00:32:56 Yes, that is correct.
352 } 347 }
353 if (entry->Get(PARENT_ID) != new_parent) { 348 if (entry->Get(PARENT_ID) != new_parent) {
354 if (!entry->Get(IS_DEL) && !IsLegalNewParent(trans, id, new_parent)) { 349 if (!entry->Get(IS_DEL) && !IsLegalNewParent(trans, id, new_parent)) {
355 DVLOG(1) << "Not updating item " << id 350 DVLOG(1) << "Not updating item " << id
356 << ", illegal new parent (would cause loop)."; 351 << ", illegal new parent (would cause loop).";
357 return CONFLICT; 352 return HIERARCHY_CONFLICT;
358 } 353 }
359 } 354 }
360 } else if (entry->Get(IS_DIR)) { 355 } else if (entry->Get(IS_DIR)) {
361 Directory::ChildHandles handles; 356 Directory::ChildHandles handles;
362 trans->directory()->GetChildHandlesById(trans, id, &handles); 357 trans->directory()->GetChildHandlesById(trans, id, &handles);
363 if (!handles.empty()) { 358 if (!handles.empty()) {
364 // If we have still-existing children, then we need to deal with 359 // If we have still-existing children, then we need to deal with
365 // them before we can process this change. 360 // them before we can process this change.
366 DVLOG(1) << "Not deleting directory; it's not empty " << *entry; 361 DVLOG(1) << "Not deleting directory; it's not empty " << *entry;
367 return CONFLICT; 362 return HIERARCHY_CONFLICT;
368 } 363 }
369 } 364 }
370 365
366 if (entry->Get(IS_UNSYNCED)) {
rlarocque 2012/01/31 19:12:17 This was moved down here because it's important th
367 DVLOG(1) << "Skipping update, returning conflict for: " << id
368 << " ; it's unsynced.";
369 return CONFLICT;
370 }
371
371 if (specifics.has_encrypted()) { 372 if (specifics.has_encrypted()) {
372 DVLOG(2) << "Received a decryptable " 373 DVLOG(2) << "Received a decryptable "
373 << syncable::ModelTypeToString(entry->GetServerModelType()) 374 << syncable::ModelTypeToString(entry->GetServerModelType())
374 << " update, applying normally."; 375 << " update, applying normally.";
375 } else { 376 } else {
376 DVLOG(2) << "Received an unencrypted " 377 DVLOG(2) << "Received an unencrypted "
377 << syncable::ModelTypeToString(entry->GetServerModelType()) 378 << syncable::ModelTypeToString(entry->GetServerModelType())
378 << " update, applying normally."; 379 << " update, applying normally.";
379 } 380 }
380 381
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 if (update.version() < target->Get(SERVER_VERSION)) { 772 if (update.version() < target->Get(SERVER_VERSION)) {
772 LOG(WARNING) << "Update older than current server version for " 773 LOG(WARNING) << "Update older than current server version for "
773 << *target << " Update:" 774 << *target << " Update:"
774 << SyncerProtoUtil::SyncEntityDebugString(update); 775 << SyncerProtoUtil::SyncEntityDebugString(update);
775 return VERIFY_SUCCESS; // Expected in new sync protocol. 776 return VERIFY_SUCCESS; // Expected in new sync protocol.
776 } 777 }
777 return VERIFY_UNDECIDED; 778 return VERIFY_UNDECIDED;
778 } 779 }
779 780
780 } // namespace browser_sync 781 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698