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