OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/build_and_process_conflict_sets_command.h" | 5 #include "chrome/browser/sync/engine/build_and_process_conflict_sets_command.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 syncable::WriteTransaction* trans, SyncerSession* const session) { | 53 syncable::WriteTransaction* trans, SyncerSession* const session) { |
54 bool rv = false; | 54 bool rv = false; |
55 ConflictResolutionView conflict_view(session); | 55 ConflictResolutionView conflict_view(session); |
56 set<ConflictSet*>::const_iterator all_sets_iterator; | 56 set<ConflictSet*>::const_iterator all_sets_iterator; |
57 for(all_sets_iterator = conflict_view.ConflictSetsBegin(); | 57 for(all_sets_iterator = conflict_view.ConflictSetsBegin(); |
58 all_sets_iterator != conflict_view.ConflictSetsEnd() ; ) { | 58 all_sets_iterator != conflict_view.ConflictSetsEnd() ; ) { |
59 const ConflictSet* conflict_set = *all_sets_iterator; | 59 const ConflictSet* conflict_set = *all_sets_iterator; |
60 CHECK(conflict_set->size() >= 2); | 60 CHECK(conflict_set->size() >= 2); |
61 // We scan the set to see if it consists of changes of only one type. | 61 // We scan the set to see if it consists of changes of only one type. |
62 ConflictSet::const_iterator i; | 62 ConflictSet::const_iterator i; |
63 int unsynced_count = 0, unapplied_count = 0; | 63 size_t unsynced_count = 0, unapplied_count = 0; |
64 for (i = conflict_set->begin(); i != conflict_set->end(); ++i) { | 64 for (i = conflict_set->begin(); i != conflict_set->end(); ++i) { |
65 syncable::Entry entry(trans, syncable::GET_BY_ID, *i); | 65 syncable::Entry entry(trans, syncable::GET_BY_ID, *i); |
66 CHECK(entry.good()); | 66 CHECK(entry.good()); |
67 if (entry.Get(syncable::IS_UNSYNCED)) | 67 if (entry.Get(syncable::IS_UNSYNCED)) |
68 unsynced_count++; | 68 unsynced_count++; |
69 if (entry.Get(syncable::IS_UNAPPLIED_UPDATE)) | 69 if (entry.Get(syncable::IS_UNAPPLIED_UPDATE)) |
70 unapplied_count++; | 70 unapplied_count++; |
71 } | 71 } |
72 if (conflict_set->size() == unsynced_count && 0 == unapplied_count) { | 72 if (conflict_set->size() == unsynced_count && 0 == unapplied_count) { |
73 LOG(INFO) << "Skipped transactional commit attempt."; | 73 LOG(INFO) << "Skipped transactional commit attempt."; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 private: | 114 private: |
115 string name_stem_; | 115 string name_stem_; |
116 }; | 116 }; |
117 | 117 |
118 bool RollbackEntry(syncable::WriteTransaction* trans, | 118 bool RollbackEntry(syncable::WriteTransaction* trans, |
119 syncable::EntryKernel* backup) { | 119 syncable::EntryKernel* backup) { |
120 syncable::MutableEntry entry(trans, syncable::GET_BY_HANDLE, | 120 syncable::MutableEntry entry(trans, syncable::GET_BY_HANDLE, |
121 backup->ref(syncable::META_HANDLE)); | 121 backup->ref(syncable::META_HANDLE)); |
122 CHECK(entry.good()); | 122 CHECK(entry.good()); |
123 bool was_del = entry.Get(syncable::IS_DEL); | |
124 | 123 |
125 if (!entry.Put(syncable::IS_DEL, backup->ref(syncable::IS_DEL))) | 124 if (!entry.Put(syncable::IS_DEL, backup->ref(syncable::IS_DEL))) |
126 return false; | 125 return false; |
127 syncable::Name name = syncable::Name::FromEntryKernel(backup); | 126 syncable::Name name = syncable::Name::FromEntryKernel(backup); |
128 if (!entry.PutParentIdAndName(backup->ref(syncable::PARENT_ID), name)) | 127 if (!entry.PutParentIdAndName(backup->ref(syncable::PARENT_ID), name)) |
129 return false; | 128 return false; |
130 | 129 |
131 if (!backup->ref(syncable::IS_DEL)) { | 130 if (!backup->ref(syncable::IS_DEL)) { |
132 if (!entry.PutPredecessor(backup->ref(syncable::PREV_ID))) | 131 if (!entry.PutPredecessor(backup->ref(syncable::PREV_ID))) |
133 return false; | 132 return false; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 return; | 432 return; |
434 LocallyDeletedPathChecker checker; | 433 LocallyDeletedPathChecker checker; |
435 if (!checker.CausingConflict(parent, *entry)) | 434 if (!checker.CausingConflict(parent, *entry)) |
436 return; | 435 return; |
437 view->MergeSets(entry->Get(syncable::ID), parent.Get(syncable::ID)); | 436 view->MergeSets(entry->Get(syncable::ID), parent.Get(syncable::ID)); |
438 CrawlDeletedTreeMergingSets(trans, parent, view, checker); | 437 CrawlDeletedTreeMergingSets(trans, parent, view, checker); |
439 } | 438 } |
440 } | 439 } |
441 | 440 |
442 } // namespace browser_sync | 441 } // namespace browser_sync |
OLD | NEW |