OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/syncable/syncable.h" | 5 #include "chrome/browser/sync/syncable/syncable.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <functional> | 9 #include <functional> |
10 #include <iomanip> | 10 #include <iomanip> |
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 // Some indices don't include deleted items and must be updated | 1476 // Some indices don't include deleted items and must be updated |
1477 // upon a value change. | 1477 // upon a value change. |
1478 ScopedIndexUpdater<ParentIdAndHandleIndexer> updater(lock, kernel_, | 1478 ScopedIndexUpdater<ParentIdAndHandleIndexer> updater(lock, kernel_, |
1479 dir()->kernel_->parent_id_child_index); | 1479 dir()->kernel_->parent_id_child_index); |
1480 | 1480 |
1481 kernel_->put(IS_DEL, is_del); | 1481 kernel_->put(IS_DEL, is_del); |
1482 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles); | 1482 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles); |
1483 } | 1483 } |
1484 | 1484 |
1485 if (!is_del) | 1485 if (!is_del) |
1486 CHECK(PutPredecessor(Id())); // Restores position to the 0th index. | 1486 // Restores position to the 0th index. |
| 1487 if (!PutPredecessor(Id())) { |
| 1488 // TODO(lipalani) : Propagate the error to caller. crbug.com/100444. |
| 1489 NOTREACHED(); |
| 1490 } |
1487 | 1491 |
1488 return true; | 1492 return true; |
1489 } | 1493 } |
1490 | 1494 |
1491 bool MutableEntry::Put(Int64Field field, const int64& value) { | 1495 bool MutableEntry::Put(Int64Field field, const int64& value) { |
1492 DCHECK(kernel_); | 1496 DCHECK(kernel_); |
1493 if (kernel_->ref(field) != value) { | 1497 if (kernel_->ref(field) != value) { |
1494 ScopedKernelLock lock(dir()); | 1498 ScopedKernelLock lock(dir()); |
1495 if (SERVER_POSITION_IN_PARENT == field) { | 1499 if (SERVER_POSITION_IN_PARENT == field) { |
1496 ScopedIndexUpdater<ParentIdAndHandleIndexer> updater(lock, kernel_, | 1500 ScopedIndexUpdater<ParentIdAndHandleIndexer> updater(lock, kernel_, |
(...skipping 17 matching lines...) Expand all Loading... |
1514 } | 1518 } |
1515 | 1519 |
1516 bool MutableEntry::Put(IdField field, const Id& value) { | 1520 bool MutableEntry::Put(IdField field, const Id& value) { |
1517 DCHECK(kernel_); | 1521 DCHECK(kernel_); |
1518 if (kernel_->ref(field) != value) { | 1522 if (kernel_->ref(field) != value) { |
1519 if (ID == field) { | 1523 if (ID == field) { |
1520 if (!dir()->ReindexId(kernel_, value)) | 1524 if (!dir()->ReindexId(kernel_, value)) |
1521 return false; | 1525 return false; |
1522 } else if (PARENT_ID == field) { | 1526 } else if (PARENT_ID == field) { |
1523 PutParentIdPropertyOnly(value); // Makes sibling order inconsistent. | 1527 PutParentIdPropertyOnly(value); // Makes sibling order inconsistent. |
1524 CHECK(PutPredecessor(Id())); // Fixes up the sibling order inconsistency. | 1528 // Fixes up the sibling order inconsistency. |
| 1529 if (!PutPredecessor(Id())) { |
| 1530 // TODO(lipalani) : Propagate the error to caller. crbug.com/100444. |
| 1531 NOTREACHED(); |
| 1532 } |
1525 } else { | 1533 } else { |
1526 kernel_->put(field, value); | 1534 kernel_->put(field, value); |
1527 } | 1535 } |
1528 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles); | 1536 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles); |
1529 } | 1537 } |
1530 return true; | 1538 return true; |
1531 } | 1539 } |
1532 | 1540 |
1533 void MutableEntry::PutParentIdPropertyOnly(const Id& parent_id) { | 1541 void MutableEntry::PutParentIdPropertyOnly(const Id& parent_id) { |
1534 dir()->ReindexParentId(kernel_, parent_id); | 1542 dir()->ReindexParentId(kernel_, parent_id); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1970 CHECK(result); | 1978 CHECK(result); |
1971 for (iterator i = GetParentChildIndexLowerBound(lock, parent_id), | 1979 for (iterator i = GetParentChildIndexLowerBound(lock, parent_id), |
1972 end = GetParentChildIndexUpperBound(lock, parent_id); | 1980 end = GetParentChildIndexUpperBound(lock, parent_id); |
1973 i != end; ++i) { | 1981 i != end; ++i) { |
1974 DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID)); | 1982 DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID)); |
1975 result->push_back((*i)->ref(META_HANDLE)); | 1983 result->push_back((*i)->ref(META_HANDLE)); |
1976 } | 1984 } |
1977 } | 1985 } |
1978 | 1986 |
1979 } // namespace syncable | 1987 } // namespace syncable |
OLD | NEW |