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 | |
136 return kernel.Pass(); | 126 return kernel.Pass(); |
137 } | 127 } |
138 | 128 |
139 namespace { | 129 namespace { |
140 | 130 |
141 string ComposeCreateTableColumnSpecs() { | 131 string ComposeCreateTableColumnSpecs() { |
142 const ColumnSpec* begin = g_metas_columns; | 132 const ColumnSpec* begin = g_metas_columns; |
143 const ColumnSpec* end = g_metas_columns + arraysize(g_metas_columns); | 133 const ColumnSpec* end = g_metas_columns + arraysize(g_metas_columns); |
144 string query; | 134 string query; |
145 query.reserve(kUpdateStatementBufferSize); | 135 query.reserve(kUpdateStatementBufferSize); |
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 } | 1558 } |
1569 query.append(" ) "); | 1559 query.append(" ) "); |
1570 values.append(" )"); | 1560 values.append(" )"); |
1571 query.append(values); | 1561 query.append(values); |
1572 save_statement->Assign(db_->GetUniqueStatement( | 1562 save_statement->Assign(db_->GetUniqueStatement( |
1573 base::StringPrintf(query.c_str(), "metas").c_str())); | 1563 base::StringPrintf(query.c_str(), "metas").c_str())); |
1574 } | 1564 } |
1575 | 1565 |
1576 } // namespace syncable | 1566 } // namespace syncable |
1577 } // namespace syncer | 1567 } // namespace syncer |
OLD | NEW |