OLD | NEW |
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/syncable/mutable_entry.h" | 5 #include "sync/syncable/mutable_entry.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "sync/internal_api/public/base/node_ordinal.h" | 8 #include "sync/internal_api/public/base/node_ordinal.h" |
9 #include "sync/syncable/directory.h" | 9 #include "sync/syncable/directory.h" |
10 #include "sync/syncable/scoped_index_updater.h" | 10 #include "sync/syncable/scoped_index_updater.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 Id successor_id; | 382 Id successor_id; |
383 if (!predecessor_id.IsRoot()) { | 383 if (!predecessor_id.IsRoot()) { |
384 MutableEntry predecessor(write_transaction(), GET_BY_ID, predecessor_id); | 384 MutableEntry predecessor(write_transaction(), GET_BY_ID, predecessor_id); |
385 if (!predecessor.good()) { | 385 if (!predecessor.good()) { |
386 LOG(ERROR) << "Predecessor is not good : " | 386 LOG(ERROR) << "Predecessor is not good : " |
387 << predecessor_id.GetServerId(); | 387 << predecessor_id.GetServerId(); |
388 return false; | 388 return false; |
389 } | 389 } |
390 if (predecessor.Get(PARENT_ID) != Get(PARENT_ID)) | 390 if (predecessor.Get(PARENT_ID) != Get(PARENT_ID)) |
391 return false; | 391 return false; |
392 successor_id = predecessor.Get(NEXT_ID); | 392 successor_id = predecessor.GetSuccessorId(); |
393 predecessor.Put(NEXT_ID, Get(ID)); | 393 predecessor.Put(NEXT_ID, Get(ID)); |
394 } else { | 394 } else { |
395 syncable::Directory* dir = trans()->directory(); | 395 syncable::Directory* dir = trans()->directory(); |
396 if (!dir->GetFirstChildId(trans(), Get(PARENT_ID), &successor_id)) { | 396 if (!dir->GetFirstChildId(trans(), Get(PARENT_ID), &successor_id)) { |
397 return false; | 397 return false; |
398 } | 398 } |
399 } | 399 } |
400 if (!successor_id.IsRoot()) { | 400 if (!successor_id.IsRoot()) { |
401 MutableEntry successor(write_transaction(), GET_BY_ID, successor_id); | 401 MutableEntry successor(write_transaction(), GET_BY_ID, successor_id); |
402 if (!successor.good()) { | 402 if (!successor.good()) { |
(...skipping 23 matching lines...) Expand all Loading... |
426 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); | 426 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); |
427 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; | 427 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; |
428 if (!(e->Put(IS_UNSYNCED, true))) | 428 if (!(e->Put(IS_UNSYNCED, true))) |
429 return false; | 429 return false; |
430 e->Put(SYNCING, false); | 430 e->Put(SYNCING, false); |
431 return true; | 431 return true; |
432 } | 432 } |
433 | 433 |
434 } // namespace syncable | 434 } // namespace syncable |
435 } // namespace syncer | 435 } // namespace syncer |
OLD | NEW |