| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 for ( ; i < PROTO_FIELDS_END; ++i) { | 63 for ( ; i < PROTO_FIELDS_END; ++i) { |
| 64 std::string temp; | 64 std::string temp; |
| 65 entry.ref(static_cast<ProtoField>(i)).SerializeToString(&temp); | 65 entry.ref(static_cast<ProtoField>(i)).SerializeToString(&temp); |
| 66 statement->BindBlob(index++, temp.data(), temp.length()); | 66 statement->BindBlob(index++, temp.data(), temp.length()); |
| 67 } | 67 } |
| 68 for ( ; i < UNIQUE_POSITION_FIELDS_END; ++i) { | 68 for ( ; i < UNIQUE_POSITION_FIELDS_END; ++i) { |
| 69 std::string temp; | 69 std::string temp; |
| 70 entry.ref(static_cast<UniquePositionField>(i)).SerializeToString(&temp); | 70 entry.ref(static_cast<UniquePositionField>(i)).SerializeToString(&temp); |
| 71 statement->BindBlob(index++, temp.data(), temp.length()); | 71 statement->BindBlob(index++, temp.data(), temp.length()); |
| 72 } | 72 } |
| 73 for (; i < ATTACHMENT_METADATA_FIELDS_END; ++i) { | |
| 74 std::string temp; | |
| 75 entry.ref(static_cast<AttachmentMetadataField>(i)).SerializeToString(&temp); | |
| 76 statement->BindBlob(index++, temp.data(), temp.length()); | |
| 77 } | |
| 78 } | 73 } |
| 79 | 74 |
| 80 // The caller owns the returned EntryKernel*. Assumes the statement currently | 75 // The caller owns the returned EntryKernel*. Assumes the statement currently |
| 81 // points to a valid row in the metas table. Returns NULL to indicate that | 76 // points to a valid row in the metas table. Returns NULL to indicate that |
| 82 // it detected a corruption in the data on unpacking. | 77 // it detected a corruption in the data on unpacking. |
| 83 scoped_ptr<EntryKernel> UnpackEntry(sql::Statement* statement) { | 78 scoped_ptr<EntryKernel> UnpackEntry(sql::Statement* statement) { |
| 84 scoped_ptr<EntryKernel> kernel(new EntryKernel()); | 79 scoped_ptr<EntryKernel> kernel(new EntryKernel()); |
| 85 DCHECK_EQ(statement->ColumnCount(), static_cast<int>(FIELD_COUNT)); | 80 DCHECK_EQ(statement->ColumnCount(), static_cast<int>(FIELD_COUNT)); |
| 86 int i = 0; | 81 int i = 0; |
| 87 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { | 82 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 112 | 107 |
| 113 sync_pb::UniquePosition proto; | 108 sync_pb::UniquePosition proto; |
| 114 if (!proto.ParseFromString(temp)) { | 109 if (!proto.ParseFromString(temp)) { |
| 115 DVLOG(1) << "Unpacked invalid position. Assuming the DB is corrupt"; | 110 DVLOG(1) << "Unpacked invalid position. Assuming the DB is corrupt"; |
| 116 return scoped_ptr<EntryKernel>(); | 111 return scoped_ptr<EntryKernel>(); |
| 117 } | 112 } |
| 118 | 113 |
| 119 kernel->mutable_ref(static_cast<UniquePositionField>(i)) = | 114 kernel->mutable_ref(static_cast<UniquePositionField>(i)) = |
| 120 UniquePosition::FromProto(proto); | 115 UniquePosition::FromProto(proto); |
| 121 } | 116 } |
| 122 for (; i < ATTACHMENT_METADATA_FIELDS_END; ++i) { | |
| 123 kernel->mutable_ref(static_cast<AttachmentMetadataField>(i)).ParseFromArray( | |
| 124 statement->ColumnBlob(i), statement->ColumnByteLength(i)); | |
| 125 } | |
| 126 return kernel.Pass(); | 117 return kernel.Pass(); |
| 127 } | 118 } |
| 128 | 119 |
| 129 namespace { | 120 namespace { |
| 130 | 121 |
| 131 string ComposeCreateTableColumnSpecs() { | 122 string ComposeCreateTableColumnSpecs() { |
| 132 const ColumnSpec* begin = g_metas_columns; | 123 const ColumnSpec* begin = g_metas_columns; |
| 133 const ColumnSpec* end = g_metas_columns + arraysize(g_metas_columns); | 124 const ColumnSpec* end = g_metas_columns + arraysize(g_metas_columns); |
| 134 string query; | 125 string query; |
| 135 query.reserve(kUpdateStatementBufferSize); | 126 query.reserve(kUpdateStatementBufferSize); |
| (...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 } | 1549 } |
| 1559 query.append(" ) "); | 1550 query.append(" ) "); |
| 1560 values.append(" )"); | 1551 values.append(" )"); |
| 1561 query.append(values); | 1552 query.append(values); |
| 1562 save_statement->Assign(db_->GetUniqueStatement( | 1553 save_statement->Assign(db_->GetUniqueStatement( |
| 1563 base::StringPrintf(query.c_str(), "metas").c_str())); | 1554 base::StringPrintf(query.c_str(), "metas").c_str())); |
| 1564 } | 1555 } |
| 1565 | 1556 |
| 1566 } // namespace syncable | 1557 } // namespace syncable |
| 1567 } // namespace syncer | 1558 } // namespace syncer |
| OLD | NEW |