| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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: |
| 75 pointer_++; | 75 pointer_++; |
| 76 application_results_.AddConflict(entry.Get(syncable::ID)); | 76 application_results_.AddConflict(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 FAILED_UPDATE: |
| 83 application_results_.set_failed_update(); |
| 84 return false; |
| 82 default: | 85 default: |
| 83 NOTREACHED(); | 86 NOTREACHED(); |
| 84 break; | 87 break; |
| 85 } | 88 } |
| 86 VLOG(1) << "Apply Status for " << entry.Get(syncable::META_HANDLE) | 89 VLOG(1) << "Apply Status for " << entry.Get(syncable::META_HANDLE) |
| 87 << " is " << updateResponse; | 90 << " is " << updateResponse; |
| 88 | 91 |
| 89 return true; | 92 return true; |
| 90 } | 93 } |
| 91 | 94 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 119 | 122 |
| 120 void UpdateApplicator::SaveProgressIntoSessionState( | 123 void UpdateApplicator::SaveProgressIntoSessionState( |
| 121 sessions::ConflictProgress* conflict_progress, | 124 sessions::ConflictProgress* conflict_progress, |
| 122 sessions::UpdateProgress* update_progress) { | 125 sessions::UpdateProgress* update_progress) { |
| 123 DCHECK(begin_ == end_ || ((pointer_ == end_) && !progress_)) | 126 DCHECK(begin_ == end_ || ((pointer_ == end_) && !progress_)) |
| 124 << "SaveProgress called before updates exhausted."; | 127 << "SaveProgress called before updates exhausted."; |
| 125 | 128 |
| 126 application_results_.SaveProgress(conflict_progress, update_progress); | 129 application_results_.SaveProgress(conflict_progress, update_progress); |
| 127 } | 130 } |
| 128 | 131 |
| 129 UpdateApplicator::ResultTracker::ResultTracker(size_t num_results) { | 132 bool UpdateApplicator::failed_update() const { |
| 133 return application_results_.failed_udpate(); |
| 134 } |
| 135 |
| 136 UpdateApplicator::ResultTracker::ResultTracker(size_t num_results) : |
| 137 failed_update_(false) { |
| 130 successful_ids_.reserve(num_results); | 138 successful_ids_.reserve(num_results); |
| 131 } | 139 } |
| 132 | 140 |
| 133 UpdateApplicator::ResultTracker::~ResultTracker() { | 141 UpdateApplicator::ResultTracker::~ResultTracker() { |
| 134 } | 142 } |
| 135 | 143 |
| 136 void UpdateApplicator::ResultTracker::AddConflict(syncable::Id id) { | 144 void UpdateApplicator::ResultTracker::AddConflict(syncable::Id id) { |
| 137 conflicting_ids_.push_back(id); | 145 conflicting_ids_.push_back(id); |
| 138 } | 146 } |
| 139 | 147 |
| 140 void UpdateApplicator::ResultTracker::AddEncryptionConflict(syncable::Id id) { | 148 void UpdateApplicator::ResultTracker::AddEncryptionConflict(syncable::Id id) { |
| 141 encryption_conflict_ids_.push_back(id); | 149 encryption_conflict_ids_.push_back(id); |
| 142 } | 150 } |
| 143 | 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 |
| 156 void UpdateApplicator::ResultTracker::set_failed_update() { |
| 157 failed_update_ = true; |
| 158 } |
| 159 |
| 160 bool UpdateApplicator::ResultTracker::failed_udpate() const { |
| 161 return failed_update_; |
| 162 } |
| 163 |
| 148 void UpdateApplicator::ResultTracker::SaveProgress( | 164 void UpdateApplicator::ResultTracker::SaveProgress( |
| 149 sessions::ConflictProgress* conflict_progress, | 165 sessions::ConflictProgress* conflict_progress, |
| 150 sessions::UpdateProgress* update_progress) { | 166 sessions::UpdateProgress* update_progress) { |
| 151 vector<syncable::Id>::const_iterator i; | 167 vector<syncable::Id>::const_iterator i; |
| 152 for (i = conflicting_ids_.begin(); i != conflicting_ids_.end(); ++i) { | 168 for (i = conflicting_ids_.begin(); i != conflicting_ids_.end(); ++i) { |
| 153 conflict_progress->AddConflictingItemById(*i); | 169 conflict_progress->AddConflictingItemById(*i); |
| 154 update_progress->AddAppliedUpdate(CONFLICT, *i); | 170 update_progress->AddAppliedUpdate(CONFLICT, *i); |
| 155 } | 171 } |
| 156 for (i = encryption_conflict_ids_.begin(); | 172 for (i = encryption_conflict_ids_.begin(); |
| 157 i != encryption_conflict_ids_.end(); ++i) { | 173 i != encryption_conflict_ids_.end(); ++i) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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(); |
| 173 } | 189 } |
| 174 | 190 |
| 175 bool UpdateApplicator::ResultTracker::no_conflicts() const { | 191 bool UpdateApplicator::ResultTracker::no_conflicts() const { |
| 176 return conflicting_ids_.empty(); | 192 return conflicting_ids_.empty(); |
| 177 } | 193 } |
| 178 | 194 |
| 179 } // namespace browser_sync | 195 } // namespace browser_sync |
| OLD | NEW |