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

Side by Side Diff: sync/internal_api/write_node.cc

Issue 11637053: sync: Start moving away from PREV_ID and NEXT_ID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 11 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/internal_api/change_reorder_buffer.cc ('k') | sync/syncable/entry.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 (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/internal_api/public/write_node.h" 5 #include "sync/internal_api/public/write_node.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "sync/internal_api/public/base_transaction.h" 9 #include "sync/internal_api/public/base_transaction.h"
10 #include "sync/internal_api/public/write_transaction.h" 10 #include "sync/internal_api/public/write_transaction.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // |predecessor| must be a child of |new_parent| or NULL. 454 // |predecessor| must be a child of |new_parent| or NULL.
455 if (predecessor && predecessor->GetParentId() != new_parent.GetId()) { 455 if (predecessor && predecessor->GetParentId() != new_parent.GetId()) {
456 DCHECK(false); 456 DCHECK(false);
457 return false; 457 return false;
458 } 458 }
459 459
460 syncable::Id new_parent_id = new_parent.GetEntry()->Get(syncable::ID); 460 syncable::Id new_parent_id = new_parent.GetEntry()->Get(syncable::ID);
461 461
462 // Filter out redundant changes if both the parent and the predecessor match. 462 // Filter out redundant changes if both the parent and the predecessor match.
463 if (new_parent_id == entry_->Get(syncable::PARENT_ID)) { 463 if (new_parent_id == entry_->Get(syncable::PARENT_ID)) {
464 const syncable::Id& old = entry_->Get(syncable::PREV_ID); 464 const syncable::Id& old = entry_->GetPredecessorId();
465 if ((!predecessor && old.IsRoot()) || 465 if ((!predecessor && old.IsRoot()) ||
466 (predecessor && (old == predecessor->GetEntry()->Get(syncable::ID)))) { 466 (predecessor && (old == predecessor->GetEntry()->Get(syncable::ID)))) {
467 return true; 467 return true;
468 } 468 }
469 } 469 }
470 470
471 // Atomically change the parent. This will fail if it would 471 // Atomically change the parent. This will fail if it would
472 // introduce a cycle in the hierarchy. 472 // introduce a cycle in the hierarchy.
473 if (!entry_->Put(syncable::PARENT_ID, new_parent_id)) 473 if (!entry_->Put(syncable::PARENT_ID, new_parent_id))
474 return false; 474 return false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 MarkForSyncing(); 506 MarkForSyncing();
507 507
508 return true; 508 return true;
509 } 509 }
510 510
511 void WriteNode::MarkForSyncing() { 511 void WriteNode::MarkForSyncing() {
512 syncable::MarkForSyncing(entry_); 512 syncable::MarkForSyncing(entry_);
513 } 513 }
514 514
515 } // namespace syncer 515 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/change_reorder_buffer.cc ('k') | sync/syncable/entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698