| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/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" |
| 11 #include "chrome/browser/sync/sessions/session_state.h" | 11 #include "chrome/browser/sync/sessions/session_state.h" |
| 12 #include "chrome/browser/sync/syncable/syncable.h" | 12 #include "chrome/browser/sync/syncable/syncable.h" |
| 13 #include "chrome/browser/sync/syncable/syncable_id.h" | 13 #include "chrome/browser/sync/syncable/syncable_id.h" |
| 14 | 14 |
| 15 using std::vector; | 15 using std::vector; |
| 16 | 16 |
| 17 namespace browser_sync { | 17 namespace browser_sync { |
| 18 | 18 |
| 19 UpdateApplicator::UpdateApplicator(ConflictResolver* resolver, | 19 UpdateApplicator::UpdateApplicator(ConflictResolver* resolver, |
| 20 Cryptographer* cryptographer, |
| 20 const UpdateIterator& begin, | 21 const UpdateIterator& begin, |
| 21 const UpdateIterator& end, | 22 const UpdateIterator& end, |
| 22 const ModelSafeRoutingInfo& routes, | 23 const ModelSafeRoutingInfo& routes, |
| 23 ModelSafeGroup group_filter) | 24 ModelSafeGroup group_filter) |
| 24 : resolver_(resolver), | 25 : resolver_(resolver), |
| 26 cryptographer_(cryptographer), |
| 25 begin_(begin), | 27 begin_(begin), |
| 26 end_(end), | 28 end_(end), |
| 27 pointer_(begin), | 29 pointer_(begin), |
| 28 group_filter_(group_filter), | 30 group_filter_(group_filter), |
| 29 progress_(false), | 31 progress_(false), |
| 30 routing_info_(routes) { | 32 routing_info_(routes) { |
| 31 size_t item_count = end - begin; | 33 size_t item_count = end - begin; |
| 32 LOG(INFO) << "UpdateApplicator created for " << item_count << " items."; | 34 LOG(INFO) << "UpdateApplicator created for " << item_count << " items."; |
| 33 successful_ids_.reserve(item_count); | 35 successful_ids_.reserve(item_count); |
| 34 } | 36 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 51 conflicting_ids_.clear(); | 53 conflicting_ids_.clear(); |
| 52 } | 54 } |
| 53 | 55 |
| 54 syncable::Entry read_only(trans, syncable::GET_BY_HANDLE, *pointer_); | 56 syncable::Entry read_only(trans, syncable::GET_BY_HANDLE, *pointer_); |
| 55 if (SkipUpdate(read_only)) { | 57 if (SkipUpdate(read_only)) { |
| 56 Advance(); | 58 Advance(); |
| 57 return true; | 59 return true; |
| 58 } | 60 } |
| 59 | 61 |
| 60 syncable::MutableEntry entry(trans, syncable::GET_BY_HANDLE, *pointer_); | 62 syncable::MutableEntry entry(trans, syncable::GET_BY_HANDLE, *pointer_); |
| 61 UpdateAttemptResponse updateResponse = | 63 UpdateAttemptResponse updateResponse = SyncerUtil::AttemptToUpdateEntry( |
| 62 SyncerUtil::AttemptToUpdateEntry(trans, &entry, resolver_); | 64 trans, &entry, resolver_, cryptographer_); |
| 63 switch (updateResponse) { | 65 switch (updateResponse) { |
| 64 case SUCCESS: | 66 case SUCCESS: |
| 65 Advance(); | 67 Advance(); |
| 66 progress_ = true; | 68 progress_ = true; |
| 67 successful_ids_.push_back(entry.Get(syncable::ID)); | 69 successful_ids_.push_back(entry.Get(syncable::ID)); |
| 68 break; | 70 break; |
| 69 case CONFLICT: | 71 case CONFLICT: |
| 70 pointer_++; | 72 pointer_++; |
| 71 conflicting_ids_.push_back(entry.Get(syncable::ID)); | 73 conflicting_ids_.push_back(entry.Get(syncable::ID)); |
| 72 break; | 74 break; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 conflict_progress->AddConflictingItemById(*i); | 110 conflict_progress->AddConflictingItemById(*i); |
| 109 update_progress->AddAppliedUpdate(CONFLICT, *i); | 111 update_progress->AddAppliedUpdate(CONFLICT, *i); |
| 110 } | 112 } |
| 111 for (i = successful_ids_.begin(); i != successful_ids_.end(); ++i) { | 113 for (i = successful_ids_.begin(); i != successful_ids_.end(); ++i) { |
| 112 conflict_progress->EraseConflictingItemById(*i); | 114 conflict_progress->EraseConflictingItemById(*i); |
| 113 update_progress->AddAppliedUpdate(SUCCESS, *i); | 115 update_progress->AddAppliedUpdate(SUCCESS, *i); |
| 114 } | 116 } |
| 115 } | 117 } |
| 116 | 118 |
| 117 } // namespace browser_sync | 119 } // namespace browser_sync |
| OLD | NEW |