OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/syncable/directory_backing_store.h" | 5 #include "chrome/browser/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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | 387 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { |
388 sqlite_utils::SQLStatement op; | 388 sqlite_utils::SQLStatement op; |
389 op.prepare(dbhandle, "INSERT OR REPLACE INTO models (model_id, " | 389 op.prepare(dbhandle, "INSERT OR REPLACE INTO models (model_id, " |
390 "progress_marker, initial_sync_ended) VALUES ( ?, ?, ?)"); | 390 "progress_marker, initial_sync_ended) VALUES ( ?, ?, ?)"); |
391 // We persist not ModelType but rather a protobuf-derived ID. | 391 // We persist not ModelType but rather a protobuf-derived ID. |
392 string model_id = ModelTypeEnumToModelId(ModelTypeFromInt(i)); | 392 string model_id = ModelTypeEnumToModelId(ModelTypeFromInt(i)); |
393 string progress_marker; | 393 string progress_marker; |
394 info.download_progress[i].SerializeToString(&progress_marker); | 394 info.download_progress[i].SerializeToString(&progress_marker); |
395 op.bind_blob(0, model_id.data(), model_id.length()); | 395 op.bind_blob(0, model_id.data(), model_id.length()); |
396 op.bind_blob(1, progress_marker.data(), progress_marker.length()); | 396 op.bind_blob(1, progress_marker.data(), progress_marker.length()); |
397 op.bind_bool(2, info.initial_sync_ended[i]); | 397 op.bind_bool(2, info.initial_sync_ended.Has(ModelTypeFromInt(i))); |
398 | 398 |
399 if (!(SQLITE_DONE == op.step() && | 399 if (!(SQLITE_DONE == op.step() && |
400 SQLITE_OK == op.reset() && | 400 SQLITE_OK == op.reset() && |
401 1 == op.changes())) { | 401 1 == op.changes())) { |
402 return false; | 402 return false; |
403 } | 403 } |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 return (SQLITE_OK == transaction.Commit()); | 407 return (SQLITE_OK == transaction.Commit()); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 sqlite_utils::SQLStatement query; | 607 sqlite_utils::SQLStatement query; |
608 query.prepare(load_dbhandle_, | 608 query.prepare(load_dbhandle_, |
609 "SELECT model_id, progress_marker, initial_sync_ended " | 609 "SELECT model_id, progress_marker, initial_sync_ended " |
610 "FROM models"); | 610 "FROM models"); |
611 while (SQLITE_ROW == query.step()) { | 611 while (SQLITE_ROW == query.step()) { |
612 ModelType type = ModelIdToModelTypeEnum(query.column_blob(0), | 612 ModelType type = ModelIdToModelTypeEnum(query.column_blob(0), |
613 query.column_bytes(0)); | 613 query.column_bytes(0)); |
614 if (type != UNSPECIFIED && type != TOP_LEVEL_FOLDER) { | 614 if (type != UNSPECIFIED && type != TOP_LEVEL_FOLDER) { |
615 info->kernel_info.download_progress[type].ParseFromArray( | 615 info->kernel_info.download_progress[type].ParseFromArray( |
616 query.column_blob(1), query.column_bytes(1)); | 616 query.column_blob(1), query.column_bytes(1)); |
617 info->kernel_info.initial_sync_ended[type] = query.column_bool(2); | 617 if (query.column_bool(2)) { |
| 618 info->kernel_info.initial_sync_ended.Put(type); |
| 619 } |
618 } | 620 } |
619 } | 621 } |
620 } | 622 } |
621 { | 623 { |
622 sqlite_utils::SQLStatement query; | 624 sqlite_utils::SQLStatement query; |
623 query.prepare(load_dbhandle_, | 625 query.prepare(load_dbhandle_, |
624 "SELECT MAX(metahandle) FROM metas"); | 626 "SELECT MAX(metahandle) FROM metas"); |
625 if (SQLITE_ROW != query.step()) | 627 if (SQLITE_ROW != query.step()) |
626 return false; | 628 return false; |
627 info->max_metahandle = query.column_int64(0); | 629 info->max_metahandle = query.column_int64(0); |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 "id TEXT primary key, " | 1257 "id TEXT primary key, " |
1256 "name TEXT, " | 1258 "name TEXT, " |
1257 "store_birthday TEXT, " | 1259 "store_birthday TEXT, " |
1258 "db_create_version TEXT, " | 1260 "db_create_version TEXT, " |
1259 "db_create_time INT, " | 1261 "db_create_time INT, " |
1260 "next_id INT default -2, " | 1262 "next_id INT default -2, " |
1261 "cache_guid TEXT )"); | 1263 "cache_guid TEXT )"); |
1262 return ExecQuery(load_dbhandle_, query.c_str()); | 1264 return ExecQuery(load_dbhandle_, query.c_str()); |
1263 } | 1265 } |
1264 } // namespace syncable | 1266 } // namespace syncable |
OLD | NEW |