OLD | NEW |
---|---|
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/update_applicator.h" | 5 #include "chrome/browser/sync/engine/update_applicator.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/browser/sync/engine/syncer_util.h" | 10 #include "chrome/browser/sync/engine/syncer_util.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 | 64 |
65 syncable::MutableEntry entry(trans, syncable::GET_BY_HANDLE, *pointer_); | 65 syncable::MutableEntry entry(trans, syncable::GET_BY_HANDLE, *pointer_); |
66 UpdateAttemptResponse updateResponse = SyncerUtil::AttemptToUpdateEntry( | 66 UpdateAttemptResponse updateResponse = SyncerUtil::AttemptToUpdateEntry( |
67 trans, &entry, resolver_, cryptographer_); | 67 trans, &entry, resolver_, cryptographer_); |
68 switch (updateResponse) { | 68 switch (updateResponse) { |
69 case SUCCESS: | 69 case SUCCESS: |
70 Advance(); | 70 Advance(); |
71 progress_ = true; | 71 progress_ = true; |
72 application_results_.AddSuccess(entry.Get(syncable::ID)); | 72 application_results_.AddSuccess(entry.Get(syncable::ID)); |
73 break; | 73 break; |
74 case CONFLICT: | 74 case CONFLICT_SIMPLE: |
75 pointer_++; | 75 pointer_++; |
76 application_results_.AddConflict(entry.Get(syncable::ID)); | 76 application_results_.AddSimpleConflict(entry.Get(syncable::ID)); |
77 break; | 77 break; |
78 case CONFLICT_ENCRYPTION: | 78 case CONFLICT_ENCRYPTION: |
79 pointer_++; | 79 pointer_++; |
80 application_results_.AddEncryptionConflict(entry.Get(syncable::ID)); | 80 application_results_.AddEncryptionConflict(entry.Get(syncable::ID)); |
81 break; | 81 break; |
82 case CONFLICT_HIERARCHY: | |
83 pointer_++; | |
84 application_results_.AddHierarchyConflict(entry.Get(syncable::ID)); | |
85 break; | |
82 default: | 86 default: |
83 NOTREACHED(); | 87 NOTREACHED(); |
84 break; | 88 break; |
85 } | 89 } |
86 DVLOG(1) << "Apply Status for " << entry.Get(syncable::META_HANDLE) | 90 DVLOG(1) << "Apply Status for " << entry.Get(syncable::META_HANDLE) |
87 << " is " << updateResponse; | 91 << " is " << updateResponse; |
88 | 92 |
89 return true; | 93 return true; |
90 } | 94 } |
91 | 95 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 application_results_.SaveProgress(conflict_progress, update_progress); | 130 application_results_.SaveProgress(conflict_progress, update_progress); |
127 } | 131 } |
128 | 132 |
129 UpdateApplicator::ResultTracker::ResultTracker(size_t num_results) { | 133 UpdateApplicator::ResultTracker::ResultTracker(size_t num_results) { |
130 successful_ids_.reserve(num_results); | 134 successful_ids_.reserve(num_results); |
131 } | 135 } |
132 | 136 |
133 UpdateApplicator::ResultTracker::~ResultTracker() { | 137 UpdateApplicator::ResultTracker::~ResultTracker() { |
134 } | 138 } |
135 | 139 |
136 void UpdateApplicator::ResultTracker::AddConflict(syncable::Id id) { | 140 void UpdateApplicator::ResultTracker::AddSimpleConflict(syncable::Id id) { |
137 conflicting_ids_.push_back(id); | 141 conflicting_ids_.push_back(id); |
138 } | 142 } |
139 | 143 |
140 void UpdateApplicator::ResultTracker::AddEncryptionConflict(syncable::Id id) { | 144 void UpdateApplicator::ResultTracker::AddEncryptionConflict(syncable::Id id) { |
141 encryption_conflict_ids_.push_back(id); | 145 encryption_conflict_ids_.push_back(id); |
142 } | 146 } |
143 | 147 |
148 void UpdateApplicator::ResultTracker::AddHierarchyConflict(syncable::Id id) { | |
149 hierarchy_conflict_ids_.push_back(id); | |
150 } | |
151 | |
144 void UpdateApplicator::ResultTracker::AddSuccess(syncable::Id id) { | 152 void UpdateApplicator::ResultTracker::AddSuccess(syncable::Id id) { |
145 successful_ids_.push_back(id); | 153 successful_ids_.push_back(id); |
146 } | 154 } |
147 | 155 |
148 void UpdateApplicator::ResultTracker::SaveProgress( | 156 void UpdateApplicator::ResultTracker::SaveProgress( |
149 sessions::ConflictProgress* conflict_progress, | 157 sessions::ConflictProgress* conflict_progress, |
150 sessions::UpdateProgress* update_progress) { | 158 sessions::UpdateProgress* update_progress) { |
151 vector<syncable::Id>::const_iterator i; | 159 vector<syncable::Id>::const_iterator i; |
152 for (i = conflicting_ids_.begin(); i != conflicting_ids_.end(); ++i) { | 160 for (i = conflicting_ids_.begin(); i != conflicting_ids_.end(); ++i) { |
153 conflict_progress->AddConflictingItemById(*i); | 161 conflict_progress->AddSimpleConflictingItemById(*i); |
154 update_progress->AddAppliedUpdate(CONFLICT, *i); | 162 update_progress->AddAppliedUpdate(CONFLICT_SIMPLE, *i); |
155 } | 163 } |
156 for (i = encryption_conflict_ids_.begin(); | 164 for (i = encryption_conflict_ids_.begin(); |
157 i != encryption_conflict_ids_.end(); ++i) { | 165 i != encryption_conflict_ids_.end(); ++i) { |
158 // Encryption conflicts should not put the syncer into a stuck state. We | 166 // Encryption conflicts should not put the syncer into a stuck state. We |
159 // mark as conflict, so that we reattempt to apply updates, but add it to | 167 // mark as conflict, so that we reattempt to apply updates, but add it to |
160 // the list of nonblocking conflicts instead of normal conflicts. | 168 // the list of nonblocking conflicts instead of normal conflicts. |
Nicolas Zea
2012/02/02 21:53:41
blocking -> unresolvable
rlarocque
2012/02/03 22:31:15
"Fixed" by removing these comments. This is not t
| |
161 conflict_progress->AddNonblockingConflictingItemById(*i); | 169 conflict_progress->AddEncryptionConflictingItemById(*i); |
162 update_progress->AddAppliedUpdate(CONFLICT, *i); | 170 update_progress->AddAppliedUpdate(CONFLICT_ENCRYPTION, *i); |
171 } | |
172 for (i = hierarchy_conflict_ids_.begin(); | |
173 i != hierarchy_conflict_ids_.end(); ++i) { | |
174 // There's nothing we can do locally to make progress on these conflicts. | |
175 // We add them to the list of non-blocking conflicts, along with the | |
Nicolas Zea
2012/02/02 21:53:41
list of unresolvable conflicts
rlarocque
2012/02/03 22:31:15
See above comment.
| |
176 // encryption conflicts. | |
177 conflict_progress->AddHierarchyConflictingItemById(*i); | |
178 update_progress->AddAppliedUpdate(CONFLICT_HIERARCHY, *i); | |
163 } | 179 } |
164 for (i = successful_ids_.begin(); i != successful_ids_.end(); ++i) { | 180 for (i = successful_ids_.begin(); i != successful_ids_.end(); ++i) { |
165 conflict_progress->EraseConflictingItemById(*i); | 181 conflict_progress->EraseSimpleConflictingItemById(*i); |
166 update_progress->AddAppliedUpdate(SUCCESS, *i); | 182 update_progress->AddAppliedUpdate(SUCCESS, *i); |
167 } | 183 } |
168 } | 184 } |
169 | 185 |
170 void UpdateApplicator::ResultTracker::ClearConflicts() { | 186 void UpdateApplicator::ResultTracker::ClearConflicts() { |
171 conflicting_ids_.clear(); | 187 conflicting_ids_.clear(); |
172 encryption_conflict_ids_.clear(); | 188 encryption_conflict_ids_.clear(); |
189 hierarchy_conflict_ids_.clear(); | |
173 } | 190 } |
174 | 191 |
175 bool UpdateApplicator::ResultTracker::no_conflicts() const { | 192 bool UpdateApplicator::ResultTracker::no_conflicts() const { |
176 return conflicting_ids_.empty(); | 193 return conflicting_ids_.empty(); |
177 } | 194 } |
178 | 195 |
179 } // namespace browser_sync | 196 } // namespace browser_sync |
OLD | NEW |