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 | 5 |
6 #include "chrome/browser/sync/engine/verify_updates_command.h" | 6 #include "chrome/browser/sync/engine/verify_updates_command.h" |
7 | 7 |
8 #include "chrome/browser/sync/engine/syncer.h" | 8 #include "chrome/browser/sync/engine/syncer.h" |
9 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 9 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
10 #include "chrome/browser/sync/engine/syncer_types.h" | 10 #include "chrome/browser/sync/engine/syncer_types.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 if (!id.ServerKnows()) { | 62 if (!id.ServerKnows()) { |
63 LOG(ERROR) << "Illegal negative id in received updates"; | 63 LOG(ERROR) << "Illegal negative id in received updates"; |
64 return VERIFY_FAIL; | 64 return VERIFY_FAIL; |
65 } | 65 } |
66 if (!entry.parent_id().ServerKnows()) { | 66 if (!entry.parent_id().ServerKnows()) { |
67 LOG(ERROR) << "Illegal parent id in received updates"; | 67 LOG(ERROR) << "Illegal parent id in received updates"; |
68 return VERIFY_FAIL; | 68 return VERIFY_FAIL; |
69 } | 69 } |
70 { | 70 { |
71 SyncName name = SyncerProtoUtil::NameFromSyncEntity(entry); | 71 const std::string name = SyncerProtoUtil::NameFromSyncEntity(entry); |
72 if ((name.value().empty() || name.non_unique_value().empty()) && | 72 if (name.empty() && !deleted) { |
73 !deleted) { | |
74 LOG(ERROR) << "Zero length name in non-deleted update"; | 73 LOG(ERROR) << "Zero length name in non-deleted update"; |
75 return VERIFY_FAIL; | 74 return VERIFY_FAIL; |
76 } | 75 } |
77 } | 76 } |
78 | 77 |
79 syncable::MutableEntry same_id(trans, GET_BY_ID, id); | 78 syncable::MutableEntry same_id(trans, GET_BY_ID, id); |
80 VerifyResult result = VERIFY_UNDECIDED; | 79 VerifyResult result = VERIFY_UNDECIDED; |
81 result = SyncerUtil::VerifyNewEntry(entry, &same_id, deleted); | 80 result = SyncerUtil::VerifyNewEntry(entry, &same_id, deleted); |
82 | 81 |
83 if (VERIFY_UNDECIDED == result) { | 82 if (VERIFY_UNDECIDED == result) { |
84 if (deleted) | 83 if (deleted) |
85 result = VERIFY_SUCCESS; | 84 result = VERIFY_SUCCESS; |
86 } | 85 } |
87 | 86 |
88 // If we have an existing entry, we check here for updates that break | 87 // If we have an existing entry, we check here for updates that break |
89 // consistency rules. | 88 // consistency rules. |
90 if (VERIFY_UNDECIDED == result) { | 89 if (VERIFY_UNDECIDED == result) { |
91 result = SyncerUtil::VerifyUpdateConsistency(trans, entry, &same_id, | 90 result = SyncerUtil::VerifyUpdateConsistency(trans, entry, &same_id, |
92 deleted, is_directory, is_bookmark); | 91 deleted, is_directory, is_bookmark); |
93 } | 92 } |
94 | 93 |
95 if (VERIFY_UNDECIDED == result) | 94 if (VERIFY_UNDECIDED == result) |
96 return VERIFY_SUCCESS; // No news is good news. | 95 return VERIFY_SUCCESS; // No news is good news. |
97 else | 96 else |
98 return result; // This might be VERIFY_SUCCESS as well | 97 return result; // This might be VERIFY_SUCCESS as well |
99 } | 98 } |
100 | 99 |
101 } // namespace browser_sync | 100 } // namespace browser_sync |
OLD | NEW |