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

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

Issue 23694004: sync: Remove IDs from OrderedCommitSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/commit.cc ('k') | sync/engine/process_commit_response_command.h » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/get_commit_ids_command.h" 5 #include "sync/engine/get_commit_ids_command.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 requested_types_, 67 requested_types_,
68 encrypted_types, 68 encrypted_types,
69 passphrase_missing, 69 passphrase_missing,
70 all_unsynced_handles, 70 all_unsynced_handles,
71 &ready_unsynced_set); 71 &ready_unsynced_set);
72 72
73 BuildCommitIds(trans_, 73 BuildCommitIds(trans_,
74 session->context()->routing_info(), 74 session->context()->routing_info(),
75 ready_unsynced_set); 75 ready_unsynced_set);
76 76
77 const vector<syncable::Id>& verified_commit_ids =
78 commit_set_->GetAllCommitIds();
79
80 for (size_t i = 0; i < verified_commit_ids.size(); i++)
81 DVLOG(1) << "Debug commit batch result:" << verified_commit_ids[i];
82
83 return SYNCER_OK; 77 return SYNCER_OK;
84 } 78 }
85 79
86 namespace { 80 namespace {
87 81
88 bool IsEntryInConflict(const syncable::Entry& entry) { 82 bool IsEntryInConflict(const syncable::Entry& entry) {
89 if (entry.Get(syncable::IS_UNSYNCED) && 83 if (entry.Get(syncable::IS_UNSYNCED) &&
90 entry.Get(syncable::SERVER_VERSION) > 0 && 84 entry.Get(syncable::SERVER_VERSION) > 0 &&
91 (entry.Get(syncable::SERVER_VERSION) > 85 (entry.Get(syncable::SERVER_VERSION) >
92 entry.Get(syncable::BASE_VERSION))) { 86 entry.Get(syncable::BASE_VERSION))) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 return true; 212 return true;
219 } 213 }
220 214
221 // Adds the given item to the list if it is unsynced and ready for commit. 215 // Adds the given item to the list if it is unsynced and ready for commit.
222 void GetCommitIdsCommand::TryAddItem(const std::set<int64>& ready_unsynced_set, 216 void GetCommitIdsCommand::TryAddItem(const std::set<int64>& ready_unsynced_set,
223 const syncable::Entry& item, 217 const syncable::Entry& item,
224 OrderedCommitSet* result) const { 218 OrderedCommitSet* result) const {
225 DCHECK(item.Get(syncable::IS_UNSYNCED)); 219 DCHECK(item.Get(syncable::IS_UNSYNCED));
226 int64 item_handle = item.Get(syncable::META_HANDLE); 220 int64 item_handle = item.Get(syncable::META_HANDLE);
227 if (ready_unsynced_set.count(item_handle) != 0) { 221 if (ready_unsynced_set.count(item_handle) != 0) {
228 result->AddCommitItem(item_handle, item.Get(syncable::ID), 222 result->AddCommitItem(item_handle, item.GetModelType());
229 item.GetModelType());
230 } 223 }
231 } 224 }
232 225
233 // Adds the given item, and all its unsynced predecessors. The traversal will 226 // Adds the given item, and all its unsynced predecessors. The traversal will
234 // be cut short if any item along the traversal is not IS_UNSYNCED, or if we 227 // be cut short if any item along the traversal is not IS_UNSYNCED, or if we
235 // detect that this area of the tree has already been traversed. Items that are 228 // detect that this area of the tree has already been traversed. Items that are
236 // not 'ready' for commit (see IsEntryReadyForCommit()) will not be added to the 229 // not 'ready' for commit (see IsEntryReadyForCommit()) will not be added to the
237 // list, though they will not stop the traversal. 230 // list, though they will not stop the traversal.
238 void GetCommitIdsCommand::AddItemThenPredecessors( 231 void GetCommitIdsCommand::AddItemThenPredecessors(
239 syncable::BaseTransaction* trans, 232 syncable::BaseTransaction* trans,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // then we'll miss it in the roll up. We have to add it in manually. 352 // then we'll miss it in the roll up. We have to add it in manually.
360 // TODO(chron): Unit test for move / delete cases: 353 // TODO(chron): Unit test for move / delete cases:
361 // Case 1: Locally moved, then parent deleted 354 // Case 1: Locally moved, then parent deleted
362 // Case 2: Server moved, then locally issue recursive delete. 355 // Case 2: Server moved, then locally issue recursive delete.
363 if (entry.Get(syncable::ID).ServerKnows() && 356 if (entry.Get(syncable::ID).ServerKnows() &&
364 entry.Get(syncable::PARENT_ID) != 357 entry.Get(syncable::PARENT_ID) !=
365 entry.Get(syncable::SERVER_PARENT_ID)) { 358 entry.Get(syncable::SERVER_PARENT_ID)) {
366 DVLOG(1) << "Inserting moved and deleted entry, will be missed by " 359 DVLOG(1) << "Inserting moved and deleted entry, will be missed by "
367 << "delete roll." << entry.Get(syncable::ID); 360 << "delete roll." << entry.Get(syncable::ID);
368 361
369 commit_set_->AddCommitItem(metahandle, 362 commit_set_->AddCommitItem(metahandle, entry.GetModelType());
370 entry.Get(syncable::ID),
371 entry.GetModelType());
372 } 363 }
373 364
374 // Skip this entry since it's a child of a parent that will be 365 // Skip this entry since it's a child of a parent that will be
375 // deleted. The server will unroll the delete and delete the 366 // deleted. The server will unroll the delete and delete the
376 // child as well. 367 // child as well.
377 continue; 368 continue;
378 } 369 }
379 370
380 legal_delete_parents.insert(entry.Get(syncable::PARENT_ID)); 371 legal_delete_parents.insert(entry.Get(syncable::PARENT_ID));
381 } 372 }
(...skipping 15 matching lines...) Expand all
397 for (std::set<int64>::const_iterator iter = ready_unsynced_set.begin(); 388 for (std::set<int64>::const_iterator iter = ready_unsynced_set.begin();
398 !IsCommitBatchFull() && iter != ready_unsynced_set.end(); ++iter) { 389 !IsCommitBatchFull() && iter != ready_unsynced_set.end(); ++iter) {
399 int64 metahandle = *iter; 390 int64 metahandle = *iter;
400 if (commit_set_->HaveCommitItem(metahandle)) 391 if (commit_set_->HaveCommitItem(metahandle))
401 continue; 392 continue;
402 syncable::Entry entry(trans, syncable::GET_BY_HANDLE, 393 syncable::Entry entry(trans, syncable::GET_BY_HANDLE,
403 metahandle); 394 metahandle);
404 if (entry.Get(syncable::IS_DEL)) { 395 if (entry.Get(syncable::IS_DEL)) {
405 syncable::Id parent_id = entry.Get(syncable::PARENT_ID); 396 syncable::Id parent_id = entry.Get(syncable::PARENT_ID);
406 if (legal_delete_parents.count(parent_id)) { 397 if (legal_delete_parents.count(parent_id)) {
407 commit_set_->AddCommitItem(metahandle, entry.Get(syncable::ID), 398 commit_set_->AddCommitItem(metahandle, entry.GetModelType());
408 entry.GetModelType());
409 } 399 }
410 } 400 }
411 } 401 }
412 } 402 }
413 403
414 void GetCommitIdsCommand::BuildCommitIds( 404 void GetCommitIdsCommand::BuildCommitIds(
415 syncable::BaseTransaction* trans, 405 syncable::BaseTransaction* trans,
416 const ModelSafeRoutingInfo& routes, 406 const ModelSafeRoutingInfo& routes,
417 const std::set<int64>& ready_unsynced_set) { 407 const std::set<int64>& ready_unsynced_set) {
418 // Commits follow these rules: 408 // Commits follow these rules:
419 // 1. Moves or creates are preceded by needed folder creates, from 409 // 1. Moves or creates are preceded by needed folder creates, from
420 // root to leaf. For folders whose contents are ordered, moves 410 // root to leaf. For folders whose contents are ordered, moves
421 // and creates appear in order. 411 // and creates appear in order.
422 // 2. Moves/Creates before deletes. 412 // 2. Moves/Creates before deletes.
423 // 3. Deletes, collapsed. 413 // 3. Deletes, collapsed.
424 // We commit deleted moves under deleted items as moves when collapsing 414 // We commit deleted moves under deleted items as moves when collapsing
425 // delete trees. 415 // delete trees.
426 416
427 // Add moves and creates, and prepend their uncommitted parents. 417 // Add moves and creates, and prepend their uncommitted parents.
428 AddCreatesAndMoves(trans, routes, ready_unsynced_set); 418 AddCreatesAndMoves(trans, routes, ready_unsynced_set);
429 419
430 // Add all deletes. 420 // Add all deletes.
431 AddDeletes(trans, ready_unsynced_set); 421 AddDeletes(trans, ready_unsynced_set);
432 } 422 }
433 423
434 } // namespace syncer 424 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/commit.cc ('k') | sync/engine/process_commit_response_command.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698