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())) { | |
akalin
2011/10/15 01:19:44
TODO to propagate error up, refer bug
| |
1488 NOTREACHED(); | |
1489 } | |
1487 | 1490 |
1488 return true; | 1491 return true; |
1489 } | 1492 } |
1490 | 1493 |
1491 bool MutableEntry::Put(Int64Field field, const int64& value) { | 1494 bool MutableEntry::Put(Int64Field field, const int64& value) { |
1492 DCHECK(kernel_); | 1495 DCHECK(kernel_); |
1493 if (kernel_->ref(field) != value) { | 1496 if (kernel_->ref(field) != value) { |
1494 ScopedKernelLock lock(dir()); | 1497 ScopedKernelLock lock(dir()); |
1495 if (SERVER_POSITION_IN_PARENT == field) { | 1498 if (SERVER_POSITION_IN_PARENT == field) { |
1496 ScopedIndexUpdater<ParentIdAndHandleIndexer> updater(lock, kernel_, | 1499 ScopedIndexUpdater<ParentIdAndHandleIndexer> updater(lock, kernel_, |
(...skipping 17 matching lines...) Expand all Loading... | |
1514 } | 1517 } |
1515 | 1518 |
1516 bool MutableEntry::Put(IdField field, const Id& value) { | 1519 bool MutableEntry::Put(IdField field, const Id& value) { |
1517 DCHECK(kernel_); | 1520 DCHECK(kernel_); |
1518 if (kernel_->ref(field) != value) { | 1521 if (kernel_->ref(field) != value) { |
1519 if (ID == field) { | 1522 if (ID == field) { |
1520 if (!dir()->ReindexId(kernel_, value)) | 1523 if (!dir()->ReindexId(kernel_, value)) |
1521 return false; | 1524 return false; |
1522 } else if (PARENT_ID == field) { | 1525 } else if (PARENT_ID == field) { |
1523 PutParentIdPropertyOnly(value); // Makes sibling order inconsistent. | 1526 PutParentIdPropertyOnly(value); // Makes sibling order inconsistent. |
1524 CHECK(PutPredecessor(Id())); // Fixes up the sibling order inconsistency. | 1527 // Fixes up the sibling order inconsistency. |
1528 if (!PutPredecessor(Id())) { | |
akalin
2011/10/15 01:19:44
here too
| |
1529 NOTREACHED(); | |
1530 } | |
1525 } else { | 1531 } else { |
1526 kernel_->put(field, value); | 1532 kernel_->put(field, value); |
1527 } | 1533 } |
1528 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles); | 1534 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles); |
1529 } | 1535 } |
1530 return true; | 1536 return true; |
1531 } | 1537 } |
1532 | 1538 |
1533 void MutableEntry::PutParentIdPropertyOnly(const Id& parent_id) { | 1539 void MutableEntry::PutParentIdPropertyOnly(const Id& parent_id) { |
1534 dir()->ReindexParentId(kernel_, parent_id); | 1540 dir()->ReindexParentId(kernel_, parent_id); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1970 CHECK(result); | 1976 CHECK(result); |
1971 for (iterator i = GetParentChildIndexLowerBound(lock, parent_id), | 1977 for (iterator i = GetParentChildIndexLowerBound(lock, parent_id), |
1972 end = GetParentChildIndexUpperBound(lock, parent_id); | 1978 end = GetParentChildIndexUpperBound(lock, parent_id); |
1973 i != end; ++i) { | 1979 i != end; ++i) { |
1974 DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID)); | 1980 DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID)); |
1975 result->push_back((*i)->ref(META_HANDLE)); | 1981 result->push_back((*i)->ref(META_HANDLE)); |
1976 } | 1982 } |
1977 } | 1983 } |
1978 | 1984 |
1979 } // namespace syncable | 1985 } // namespace syncable |
OLD | NEW |