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/directory_backing_store.h" | 5 #include "sync/syncable/directory_backing_store.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 return scoped_ptr<EntryKernel>(); | 116 return scoped_ptr<EntryKernel>(); |
117 } | 117 } |
118 | 118 |
119 kernel->mutable_ref(static_cast<UniquePositionField>(i)) = | 119 kernel->mutable_ref(static_cast<UniquePositionField>(i)) = |
120 UniquePosition::FromProto(proto); | 120 UniquePosition::FromProto(proto); |
121 } | 121 } |
122 for (; i < ATTACHMENT_METADATA_FIELDS_END; ++i) { | 122 for (; i < ATTACHMENT_METADATA_FIELDS_END; ++i) { |
123 kernel->mutable_ref(static_cast<AttachmentMetadataField>(i)).ParseFromArray( | 123 kernel->mutable_ref(static_cast<AttachmentMetadataField>(i)).ParseFromArray( |
124 statement->ColumnBlob(i), statement->ColumnByteLength(i)); | 124 statement->ColumnBlob(i), statement->ColumnByteLength(i)); |
125 } | 125 } |
| 126 |
| 127 // Sanity check on positions. We risk strange and rare crashes if our |
| 128 // assumptions about unique position values are broken. |
| 129 if (kernel->ShouldMaintainPosition() && |
| 130 !kernel->ref(UNIQUE_POSITION).IsValid()) { |
| 131 DVLOG(1) << "Unpacked invalid position on an entity that should have a " |
| 132 << "valid position. Assuming the DB is corrupt."; |
| 133 return scoped_ptr<EntryKernel>(); |
| 134 } |
| 135 |
126 return kernel.Pass(); | 136 return kernel.Pass(); |
127 } | 137 } |
128 | 138 |
129 namespace { | 139 namespace { |
130 | 140 |
131 string ComposeCreateTableColumnSpecs() { | 141 string ComposeCreateTableColumnSpecs() { |
132 const ColumnSpec* begin = g_metas_columns; | 142 const ColumnSpec* begin = g_metas_columns; |
133 const ColumnSpec* end = g_metas_columns + arraysize(g_metas_columns); | 143 const ColumnSpec* end = g_metas_columns + arraysize(g_metas_columns); |
134 string query; | 144 string query; |
135 query.reserve(kUpdateStatementBufferSize); | 145 query.reserve(kUpdateStatementBufferSize); |
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 } | 1568 } |
1559 query.append(" ) "); | 1569 query.append(" ) "); |
1560 values.append(" )"); | 1570 values.append(" )"); |
1561 query.append(values); | 1571 query.append(values); |
1562 save_statement->Assign(db_->GetUniqueStatement( | 1572 save_statement->Assign(db_->GetUniqueStatement( |
1563 base::StringPrintf(query.c_str(), "metas").c_str())); | 1573 base::StringPrintf(query.c_str(), "metas").c_str())); |
1564 } | 1574 } |
1565 | 1575 |
1566 } // namespace syncable | 1576 } // namespace syncable |
1567 } // namespace syncer | 1577 } // namespace syncer |
OLD | NEW |