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

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

Issue 8922015: [Sync] Don't commit items with predecessors/parents in conflict. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ensure we clear BASE_SERVER_SPECIFICS Created 8 years, 11 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 536 }
537 537
538 entry->Put(CTIME, entry->Get(SERVER_CTIME)); 538 entry->Put(CTIME, entry->Get(SERVER_CTIME));
539 entry->Put(MTIME, entry->Get(SERVER_MTIME)); 539 entry->Put(MTIME, entry->Get(SERVER_MTIME));
540 entry->Put(BASE_VERSION, entry->Get(SERVER_VERSION)); 540 entry->Put(BASE_VERSION, entry->Get(SERVER_VERSION));
541 entry->Put(IS_DEL, entry->Get(SERVER_IS_DEL)); 541 entry->Put(IS_DEL, entry->Get(SERVER_IS_DEL));
542 entry->Put(IS_UNAPPLIED_UPDATE, false); 542 entry->Put(IS_UNAPPLIED_UPDATE, false);
543 } 543 }
544 544
545 // static 545 // static
546 VerifyCommitResult SyncerUtil::ValidateCommitEntry(
547 syncable::Entry* entry) {
548 syncable::Id id = entry->Get(ID);
549 if (id == entry->Get(PARENT_ID)) {
550 CHECK(id.IsRoot()) << "Non-root item is self parenting." << *entry;
551 // If the root becomes unsynced it can cause us problems.
552 LOG(ERROR) << "Root item became unsynced " << *entry;
553 return VERIFY_UNSYNCABLE;
554 }
555 if (entry->IsRoot()) {
556 LOG(ERROR) << "Permanent item became unsynced " << *entry;
557 return VERIFY_UNSYNCABLE;
558 }
559 if (entry->Get(IS_DEL) && !entry->Get(ID).ServerKnows()) {
560 // Drop deleted uncommitted entries.
561 return VERIFY_UNSYNCABLE;
562 }
563 return VERIFY_OK;
564 }
565
566 // static
567 bool SyncerUtil::AddItemThenPredecessors( 546 bool SyncerUtil::AddItemThenPredecessors(
568 syncable::BaseTransaction* trans, 547 syncable::BaseTransaction* trans,
569 syncable::Entry* item, 548 syncable::Entry* item,
570 syncable::IndexedBitField inclusion_filter, 549 syncable::IndexedBitField inclusion_filter,
571 syncable::MetahandleSet* inserted_items, 550 syncable::MetahandleSet* inserted_items,
572 std::vector<syncable::Id>* commit_ids) { 551 std::vector<syncable::Id>* commit_ids) {
573 552
574 if (!inserted_items->insert(item->Get(META_HANDLE)).second) 553 if (!inserted_items->insert(item->Get(META_HANDLE)).second)
575 return false; 554 return false;
576 commit_ids->push_back(item->Get(ID)); 555 commit_ids->push_back(item->Get(ID));
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 if (update.version() < target->Get(SERVER_VERSION)) { 750 if (update.version() < target->Get(SERVER_VERSION)) {
772 LOG(WARNING) << "Update older than current server version for " 751 LOG(WARNING) << "Update older than current server version for "
773 << *target << " Update:" 752 << *target << " Update:"
774 << SyncerProtoUtil::SyncEntityDebugString(update); 753 << SyncerProtoUtil::SyncEntityDebugString(update);
775 return VERIFY_SUCCESS; // Expected in new sync protocol. 754 return VERIFY_SUCCESS; // Expected in new sync protocol.
776 } 755 }
777 return VERIFY_UNDECIDED; 756 return VERIFY_UNDECIDED;
778 } 757 }
779 758
780 } // namespace browser_sync 759 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698