Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: sync/engine/verify_updates_command.cc

Issue 10795018: [Sync] Remove unneeded 'using syncer::' lines and 'syncer::' scopings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fiix indent Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/engine/verify_updates_command.h ('k') | sync/engine/verify_updates_command_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/engine/verify_updates_command.h" 5 #include "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 "sync/engine/syncer.h" 10 #include "sync/engine/syncer.h"
11 #include "sync/engine/syncer_proto_util.h" 11 #include "sync/engine/syncer_proto_util.h"
12 #include "sync/engine/syncer_types.h" 12 #include "sync/engine/syncer_types.h"
13 #include "sync/engine/syncer_util.h" 13 #include "sync/engine/syncer_util.h"
14 #include "sync/internal_api/public/engine/model_safe_worker.h" 14 #include "sync/internal_api/public/engine/model_safe_worker.h"
15 #include "sync/protocol/bookmark_specifics.pb.h" 15 #include "sync/protocol/bookmark_specifics.pb.h"
16 #include "sync/protocol/sync.pb.h" 16 #include "sync/protocol/sync.pb.h"
17 #include "sync/syncable/entry.h" 17 #include "sync/syncable/entry.h"
18 #include "sync/syncable/mutable_entry.h" 18 #include "sync/syncable/mutable_entry.h"
19 #include "sync/syncable/syncable_proto_util.h" 19 #include "sync/syncable/syncable_proto_util.h"
20 #include "sync/syncable/write_transaction.h" 20 #include "sync/syncable/write_transaction.h"
21 21
22 namespace syncer { 22 namespace syncer {
23 23
24 using syncable::GET_BY_ID; 24 using syncable::GET_BY_ID;
25 using syncer::ModelTypeSet;
26 using syncable::SYNCER; 25 using syncable::SYNCER;
27 using syncable::WriteTransaction; 26 using syncable::WriteTransaction;
28 27
29 namespace { 28 namespace {
30 29
31 // This function attempts to determine whether or not this update is genuinely 30 // This function attempts to determine whether or not this update is genuinely
32 // new, or if it is a reflection of one of our own commits. 31 // new, or if it is a reflection of one of our own commits.
33 // 32 //
34 // There is a known inaccuracy in its implementation. If this update ends up 33 // There is a known inaccuracy in its implementation. If this update ends up
35 // being applied to a local item with a different ID, we will count the change 34 // being applied to a local item with a different ID, we will count the change
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 VerifyUpdatesCommand::~VerifyUpdatesCommand() {} 78 VerifyUpdatesCommand::~VerifyUpdatesCommand() {}
80 79
81 std::set<ModelSafeGroup> VerifyUpdatesCommand::GetGroupsToChange( 80 std::set<ModelSafeGroup> VerifyUpdatesCommand::GetGroupsToChange(
82 const sessions::SyncSession& session) const { 81 const sessions::SyncSession& session) const {
83 std::set<ModelSafeGroup> groups_with_updates; 82 std::set<ModelSafeGroup> groups_with_updates;
84 83
85 const sync_pb::GetUpdatesResponse& updates = 84 const sync_pb::GetUpdatesResponse& updates =
86 session.status_controller().updates_response().get_updates(); 85 session.status_controller().updates_response().get_updates();
87 for (int i = 0; i < updates.entries().size(); i++) { 86 for (int i = 0; i < updates.entries().size(); i++) {
88 groups_with_updates.insert( 87 groups_with_updates.insert(
89 GetGroupForModelType(syncer::GetModelType(updates.entries(i)), 88 GetGroupForModelType(GetModelType(updates.entries(i)),
90 session.routing_info())); 89 session.routing_info()));
91 } 90 }
92 91
93 return groups_with_updates; 92 return groups_with_updates;
94 } 93 }
95 94
96 SyncerError VerifyUpdatesCommand::ModelChangingExecuteImpl( 95 SyncerError VerifyUpdatesCommand::ModelChangingExecuteImpl(
97 sessions::SyncSession* session) { 96 sessions::SyncSession* session) {
98 DVLOG(1) << "Beginning Update Verification"; 97 DVLOG(1) << "Beginning Update Verification";
99 syncable::Directory* dir = session->context()->directory(); 98 syncable::Directory* dir = session->context()->directory();
100 WriteTransaction trans(FROM_HERE, SYNCER, dir); 99 WriteTransaction trans(FROM_HERE, SYNCER, dir);
101 sessions::StatusController* status = session->mutable_status_controller(); 100 sessions::StatusController* status = session->mutable_status_controller();
102 const sync_pb::GetUpdatesResponse& updates = 101 const sync_pb::GetUpdatesResponse& updates =
103 status->updates_response().get_updates(); 102 status->updates_response().get_updates();
104 int update_count = updates.entries().size(); 103 int update_count = updates.entries().size();
105 104
106 ModelTypeSet requested_types = syncer::GetRoutingInfoTypes( 105 ModelTypeSet requested_types = GetRoutingInfoTypes(
107 session->routing_info()); 106 session->routing_info());
108 107
109 DVLOG(1) << update_count << " entries to verify"; 108 DVLOG(1) << update_count << " entries to verify";
110 for (int i = 0; i < update_count; i++) { 109 for (int i = 0; i < update_count; i++) {
111 const sync_pb::SyncEntity& update = updates.entries(i); 110 const sync_pb::SyncEntity& update = updates.entries(i);
112 ModelSafeGroup g = GetGroupForModelType(GetModelType(update), 111 ModelSafeGroup g = GetGroupForModelType(GetModelType(update),
113 session->routing_info()); 112 session->routing_info());
114 if (g != status->group_restriction()) 113 if (g != status->group_restriction())
115 continue; 114 continue;
116 115
(...skipping 13 matching lines...) Expand all
130 129
131 VerifyUpdatesCommand::VerifyUpdateResult VerifyUpdatesCommand::VerifyUpdate( 130 VerifyUpdatesCommand::VerifyUpdateResult VerifyUpdatesCommand::VerifyUpdate(
132 syncable::WriteTransaction* trans, const sync_pb::SyncEntity& entry, 131 syncable::WriteTransaction* trans, const sync_pb::SyncEntity& entry,
133 const ModelTypeSet& requested_types, 132 const ModelTypeSet& requested_types,
134 const ModelSafeRoutingInfo& routes) { 133 const ModelSafeRoutingInfo& routes) {
135 syncable::Id id = SyncableIdFromProto(entry.id_string()); 134 syncable::Id id = SyncableIdFromProto(entry.id_string());
136 VerifyUpdateResult result = {VERIFY_FAIL, GROUP_PASSIVE}; 135 VerifyUpdateResult result = {VERIFY_FAIL, GROUP_PASSIVE};
137 136
138 const bool deleted = entry.has_deleted() && entry.deleted(); 137 const bool deleted = entry.has_deleted() && entry.deleted();
139 const bool is_directory = IsFolder(entry); 138 const bool is_directory = IsFolder(entry);
140 const syncer::ModelType model_type = GetModelType(entry); 139 const ModelType model_type = GetModelType(entry);
141 140
142 if (!id.ServerKnows()) { 141 if (!id.ServerKnows()) {
143 LOG(ERROR) << "Illegal negative id in received updates"; 142 LOG(ERROR) << "Illegal negative id in received updates";
144 return result; 143 return result;
145 } 144 }
146 { 145 {
147 const std::string name = SyncerProtoUtil::NameFromSyncEntity(entry); 146 const std::string name = SyncerProtoUtil::NameFromSyncEntity(entry);
148 if (name.empty() && !deleted) { 147 if (name.empty() && !deleted) {
149 LOG(ERROR) << "Zero length name in non-deleted update"; 148 LOG(ERROR) << "Zero length name in non-deleted update";
150 return result; 149 return result;
151 } 150 }
152 } 151 }
153 152
154 syncable::MutableEntry same_id(trans, GET_BY_ID, id); 153 syncable::MutableEntry same_id(trans, GET_BY_ID, id);
155 result.value = VerifyNewEntry(entry, &same_id, deleted); 154 result.value = VerifyNewEntry(entry, &same_id, deleted);
156 155
157 syncer::ModelType placement_type = !deleted ? GetModelType(entry) 156 ModelType placement_type = !deleted ? GetModelType(entry)
158 : same_id.good() ? same_id.GetModelType() : syncer::UNSPECIFIED; 157 : same_id.good() ? same_id.GetModelType() : UNSPECIFIED;
159 result.placement = GetGroupForModelType(placement_type, routes); 158 result.placement = GetGroupForModelType(placement_type, routes);
160 159
161 if (VERIFY_UNDECIDED == result.value) { 160 if (VERIFY_UNDECIDED == result.value) {
162 result.value = VerifyTagConsistency(entry, same_id); 161 result.value = VerifyTagConsistency(entry, same_id);
163 } 162 }
164 163
165 if (VERIFY_UNDECIDED == result.value) { 164 if (VERIFY_UNDECIDED == result.value) {
166 if (deleted) { 165 if (deleted) {
167 // For deletes the server could send tombostones for items that 166 // For deletes the server could send tombostones for items that
168 // the client did not request. If so ignore those items. 167 // the client did not request. If so ignore those items.
(...skipping 13 matching lines...) Expand all
182 deleted, is_directory, model_type); 181 deleted, is_directory, model_type);
183 } 182 }
184 183
185 if (VERIFY_UNDECIDED == result.value) 184 if (VERIFY_UNDECIDED == result.value)
186 result.value = VERIFY_SUCCESS; // No news is good news. 185 result.value = VERIFY_SUCCESS; // No news is good news.
187 186
188 return result; // This might be VERIFY_SUCCESS as well 187 return result; // This might be VERIFY_SUCCESS as well
189 } 188 }
190 189
191 } // namespace syncer 190 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/verify_updates_command.h ('k') | sync/engine/verify_updates_command_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698