| 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/verify_updates_command.h" | 5 #include "chrome/browser/sync/engine/verify_updates_command.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "chrome/browser/sync/engine/syncer.h" | 10 #include "chrome/browser/sync/engine/syncer.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 session.status_controller().updates_response().get_updates(); | 35 session.status_controller().updates_response().get_updates(); |
| 36 for (int i = 0; i < updates.entries().size(); i++) { | 36 for (int i = 0; i < updates.entries().size(); i++) { |
| 37 groups_with_updates.insert( | 37 groups_with_updates.insert( |
| 38 GetGroupForModelType(syncable::GetModelType(updates.entries(i)), | 38 GetGroupForModelType(syncable::GetModelType(updates.entries(i)), |
| 39 session.routing_info())); | 39 session.routing_info())); |
| 40 } | 40 } |
| 41 | 41 |
| 42 return groups_with_updates; | 42 return groups_with_updates; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void VerifyUpdatesCommand::ModelChangingExecuteImpl( | 45 SyncerError VerifyUpdatesCommand::ModelChangingExecuteImpl( |
| 46 sessions::SyncSession* session) { | 46 sessions::SyncSession* session) { |
| 47 DVLOG(1) << "Beginning Update Verification"; | 47 DVLOG(1) << "Beginning Update Verification"; |
| 48 ScopedDirLookup dir(session->context()->directory_manager(), | 48 ScopedDirLookup dir(session->context()->directory_manager(), |
| 49 session->context()->account_name()); | 49 session->context()->account_name()); |
| 50 if (!dir.good()) { | 50 if (!dir.good()) { |
| 51 LOG(ERROR) << "Scoped dir lookup failed!"; | 51 LOG(ERROR) << "Scoped dir lookup failed!"; |
| 52 return; | 52 return DIRECTORY_LOOKUP_FAILED; |
| 53 } | 53 } |
| 54 WriteTransaction trans(FROM_HERE, SYNCER, dir); | 54 WriteTransaction trans(FROM_HERE, SYNCER, dir); |
| 55 sessions::StatusController* status = session->mutable_status_controller(); | 55 sessions::StatusController* status = session->mutable_status_controller(); |
| 56 const GetUpdatesResponse& updates = status->updates_response().get_updates(); | 56 const GetUpdatesResponse& updates = status->updates_response().get_updates(); |
| 57 int update_count = updates.entries().size(); | 57 int update_count = updates.entries().size(); |
| 58 | 58 |
| 59 DVLOG(1) << update_count << " entries to verify"; | 59 DVLOG(1) << update_count << " entries to verify"; |
| 60 for (int i = 0; i < update_count; i++) { | 60 for (int i = 0; i < update_count; i++) { |
| 61 const SyncEntity& update = | 61 const SyncEntity& update = |
| 62 *reinterpret_cast<const SyncEntity *>(&(updates.entries(i))); | 62 *reinterpret_cast<const SyncEntity *>(&(updates.entries(i))); |
| 63 ModelSafeGroup g = GetGroupForModelType(update.GetModelType(), | 63 ModelSafeGroup g = GetGroupForModelType(update.GetModelType(), |
| 64 session->routing_info()); | 64 session->routing_info()); |
| 65 if (g != status->group_restriction()) | 65 if (g != status->group_restriction()) |
| 66 continue; | 66 continue; |
| 67 | 67 |
| 68 VerifyUpdateResult result = VerifyUpdate(&trans, update, | 68 VerifyUpdateResult result = VerifyUpdate(&trans, update, |
| 69 session->routing_info()); | 69 session->routing_info()); |
| 70 status->mutable_update_progress()->AddVerifyResult(result.value, update); | 70 status->mutable_update_progress()->AddVerifyResult(result.value, update); |
| 71 status->increment_num_updates_downloaded_by(1); | 71 status->increment_num_updates_downloaded_by(1); |
| 72 if (update.deleted()) | 72 if (update.deleted()) |
| 73 status->increment_num_tombstone_updates_downloaded_by(1); | 73 status->increment_num_tombstone_updates_downloaded_by(1); |
| 74 } | 74 } |
| 75 |
| 76 return NO_ERROR; |
| 75 } | 77 } |
| 76 | 78 |
| 77 namespace { | 79 namespace { |
| 78 // In the event that IDs match, but tags differ AttemptReuniteClient tag | 80 // In the event that IDs match, but tags differ AttemptReuniteClient tag |
| 79 // will have refused to unify the update. | 81 // will have refused to unify the update. |
| 80 // We should not attempt to apply it at all since it violates consistency | 82 // We should not attempt to apply it at all since it violates consistency |
| 81 // rules. | 83 // rules. |
| 82 VerifyResult VerifyTagConsistency(const SyncEntity& entry, | 84 VerifyResult VerifyTagConsistency(const SyncEntity& entry, |
| 83 const syncable::MutableEntry& same_id) { | 85 const syncable::MutableEntry& same_id) { |
| 84 if (entry.has_client_defined_unique_tag() && | 86 if (entry.has_client_defined_unique_tag() && |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 deleted, is_directory, model_type); | 137 deleted, is_directory, model_type); |
| 136 } | 138 } |
| 137 | 139 |
| 138 if (VERIFY_UNDECIDED == result.value) | 140 if (VERIFY_UNDECIDED == result.value) |
| 139 result.value = VERIFY_SUCCESS; // No news is good news. | 141 result.value = VERIFY_SUCCESS; // No news is good news. |
| 140 | 142 |
| 141 return result; // This might be VERIFY_SUCCESS as well | 143 return result; // This might be VERIFY_SUCCESS as well |
| 142 } | 144 } |
| 143 | 145 |
| 144 } // namespace browser_sync | 146 } // namespace browser_sync |
| OLD | NEW |