OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |