| 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 "components/sync/syncable/directory_backing_store.h" | 5 #include "components/sync/syncable/directory_backing_store.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <unordered_set> | 10 #include <unordered_set> |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 kernel->load(static_cast<TField>(*index), blob, length); | 117 kernel->load(static_cast<TField>(*index), blob, length); |
| 118 prev_blob = blob; | 118 prev_blob = blob; |
| 119 prev_length = length; | 119 prev_length = length; |
| 120 prev_index = *index; | 120 prev_index = *index; |
| 121 ++(*total_entry_copies); | 121 ++(*total_entry_copies); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 // The caller owns the returned EntryKernel*. Assumes the statement currently | 126 // The caller owns the returned EntryKernel*. Assumes the statement currently |
| 127 // points to a valid row in the metas table. Returns NULL to indicate that | 127 // points to a valid row in the metas table. Returns null to indicate that |
| 128 // it detected a corruption in the data on unpacking. | 128 // it detected a corruption in the data on unpacking. |
| 129 std::unique_ptr<EntryKernel> UnpackEntry(sql::Statement* statement, | 129 std::unique_ptr<EntryKernel> UnpackEntry(sql::Statement* statement, |
| 130 int* total_specifics_copies) { | 130 int* total_specifics_copies) { |
| 131 std::unique_ptr<EntryKernel> kernel(new EntryKernel()); | 131 std::unique_ptr<EntryKernel> kernel(new EntryKernel()); |
| 132 DCHECK_EQ(statement->ColumnCount(), static_cast<int>(FIELD_COUNT)); | 132 DCHECK_EQ(statement->ColumnCount(), static_cast<int>(FIELD_COUNT)); |
| 133 int i = 0; | 133 int i = 0; |
| 134 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { | 134 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { |
| 135 kernel->put(static_cast<Int64Field>(i), statement->ColumnInt64(i)); | 135 kernel->put(static_cast<Int64Field>(i), statement->ColumnInt64(i)); |
| 136 } | 136 } |
| 137 for ( ; i < TIME_FIELDS_END; ++i) { | 137 for ( ; i < TIME_FIELDS_END; ++i) { |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 return true; | 1206 return true; |
| 1207 } | 1207 } |
| 1208 | 1208 |
| 1209 bool DirectoryBackingStore::MigrateVersion79To80() { | 1209 bool DirectoryBackingStore::MigrateVersion79To80() { |
| 1210 if (!db_->Execute( | 1210 if (!db_->Execute( |
| 1211 "ALTER TABLE share_info ADD COLUMN bag_of_chips BLOB")) | 1211 "ALTER TABLE share_info ADD COLUMN bag_of_chips BLOB")) |
| 1212 return false; | 1212 return false; |
| 1213 sql::Statement update(db_->GetUniqueStatement( | 1213 sql::Statement update(db_->GetUniqueStatement( |
| 1214 "UPDATE share_info SET bag_of_chips = ?")); | 1214 "UPDATE share_info SET bag_of_chips = ?")); |
| 1215 // An empty message is serialized to an empty string. | 1215 // An empty message is serialized to an empty string. |
| 1216 update.BindBlob(0, NULL, 0); | 1216 update.BindBlob(0, nullptr, 0); |
| 1217 if (!update.Run()) | 1217 if (!update.Run()) |
| 1218 return false; | 1218 return false; |
| 1219 SetVersion(80); | 1219 SetVersion(80); |
| 1220 return true; | 1220 return true; |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 bool DirectoryBackingStore::MigrateVersion80To81() { | 1223 bool DirectoryBackingStore::MigrateVersion80To81() { |
| 1224 if (!db_->Execute( | 1224 if (!db_->Execute( |
| 1225 "ALTER TABLE metas ADD COLUMN server_ordinal_in_parent BLOB")) | 1225 "ALTER TABLE metas ADD COLUMN server_ordinal_in_parent BLOB")) |
| 1226 return false; | 1226 return false; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 "INSERT INTO share_info VALUES" | 1503 "INSERT INTO share_info VALUES" |
| 1504 "(?, " // id | 1504 "(?, " // id |
| 1505 "?, " // name | 1505 "?, " // name |
| 1506 "?, " // store_birthday | 1506 "?, " // store_birthday |
| 1507 "?, " // cache_guid | 1507 "?, " // cache_guid |
| 1508 "?);")); // bag_of_chips | 1508 "?);")); // bag_of_chips |
| 1509 s.BindString(0, dir_name_); // id | 1509 s.BindString(0, dir_name_); // id |
| 1510 s.BindString(1, dir_name_); // name | 1510 s.BindString(1, dir_name_); // name |
| 1511 s.BindString(2, std::string()); // store_birthday | 1511 s.BindString(2, std::string()); // store_birthday |
| 1512 s.BindString(3, GenerateCacheGUID()); // cache_guid | 1512 s.BindString(3, GenerateCacheGUID()); // cache_guid |
| 1513 s.BindBlob(4, NULL, 0); // bag_of_chips | 1513 s.BindBlob(4, nullptr, 0); // bag_of_chips |
| 1514 if (!s.Run()) | 1514 if (!s.Run()) |
| 1515 return false; | 1515 return false; |
| 1516 } | 1516 } |
| 1517 | 1517 |
| 1518 if (!CreateModelsTable()) | 1518 if (!CreateModelsTable()) |
| 1519 return false; | 1519 return false; |
| 1520 | 1520 |
| 1521 // Create the big metas table. | 1521 // Create the big metas table. |
| 1522 if (!CreateMetasTable(false)) | 1522 if (!CreateMetasTable(false)) |
| 1523 return false; | 1523 return false; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 DCHECK(CalledOnValidThread()); | 1763 DCHECK(CalledOnValidThread()); |
| 1764 DCHECK(!catastrophic_error_handler.is_null()); | 1764 DCHECK(!catastrophic_error_handler.is_null()); |
| 1765 catastrophic_error_handler_ = catastrophic_error_handler; | 1765 catastrophic_error_handler_ = catastrophic_error_handler; |
| 1766 sql::Connection::ErrorCallback error_callback = | 1766 sql::Connection::ErrorCallback error_callback = |
| 1767 base::Bind(&OnSqliteError, catastrophic_error_handler_); | 1767 base::Bind(&OnSqliteError, catastrophic_error_handler_); |
| 1768 db_->set_error_callback(error_callback); | 1768 db_->set_error_callback(error_callback); |
| 1769 } | 1769 } |
| 1770 | 1770 |
| 1771 } // namespace syncable | 1771 } // namespace syncable |
| 1772 } // namespace syncer | 1772 } // namespace syncer |
| OLD | NEW |