| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 | 649 |
| 650 bool DirectoryBackingStore::LoadEntries(Directory::MetahandlesMap* handles_map, | 650 bool DirectoryBackingStore::LoadEntries(Directory::MetahandlesMap* handles_map, |
| 651 MetahandleSet* metahandles_to_purge) { | 651 MetahandleSet* metahandles_to_purge) { |
| 652 string select; | 652 string select; |
| 653 select.reserve(kUpdateStatementBufferSize); | 653 select.reserve(kUpdateStatementBufferSize); |
| 654 select.append("SELECT "); | 654 select.append("SELECT "); |
| 655 AppendColumnList(&select); | 655 AppendColumnList(&select); |
| 656 select.append(" FROM metas"); | 656 select.append(" FROM metas"); |
| 657 int total_specifics_copies = 0; | 657 int total_specifics_copies = 0; |
| 658 int model_type_entry_count[MODEL_TYPE_COUNT]; | 658 int model_type_entry_count[MODEL_TYPE_COUNT]; |
| 659 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | 659 for (int i = 0; i < MODEL_TYPE_COUNT; ++i) { |
| 660 model_type_entry_count[i] = 0; | 660 model_type_entry_count[i] = 0; |
| 661 } | 661 } |
| 662 | 662 |
| 663 sql::Statement s(db_->GetUniqueStatement(select.c_str())); | 663 sql::Statement s(db_->GetUniqueStatement(select.c_str())); |
| 664 | 664 |
| 665 while (s.Step()) { | 665 while (s.Step()) { |
| 666 scoped_ptr<EntryKernel> kernel = UnpackEntry(&s, &total_specifics_copies); | 666 scoped_ptr<EntryKernel> kernel = UnpackEntry(&s, &total_specifics_copies); |
| 667 // A null kernel is evidence of external data corruption. | 667 // A null kernel is evidence of external data corruption. |
| 668 if (!kernel) | 668 if (!kernel) |
| 669 return false; | 669 return false; |
| 670 | 670 |
| 671 int64_t handle = kernel->ref(META_HANDLE); | 671 int64_t handle = kernel->ref(META_HANDLE); |
| 672 if (SafeToPurgeOnLoading(*kernel)) { | 672 if (SafeToPurgeOnLoading(*kernel)) { |
| 673 metahandles_to_purge->insert(handle); | 673 metahandles_to_purge->insert(handle); |
| 674 } else { | 674 } else { |
| 675 ++model_type_entry_count[kernel->GetModelType()]; | 675 ModelType model_type = kernel->GetModelType(); |
| 676 if (!IsRealDataType(model_type)) { |
| 677 model_type = kernel->GetServerModelType(); |
| 678 } |
| 679 ++model_type_entry_count[model_type]; |
| 676 (*handles_map)[handle] = kernel.release(); | 680 (*handles_map)[handle] = kernel.release(); |
| 677 } | 681 } |
| 678 } | 682 } |
| 679 | 683 |
| 680 UploadModelTypeEntryCount(total_specifics_copies, model_type_entry_count); | 684 UploadModelTypeEntryCount(total_specifics_copies, model_type_entry_count); |
| 681 | 685 |
| 682 return s.Succeeded(); | 686 return s.Succeeded(); |
| 683 } | 687 } |
| 684 | 688 |
| 685 bool DirectoryBackingStore::SafeToPurgeOnLoading( | 689 bool DirectoryBackingStore::SafeToPurgeOnLoading( |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 DCHECK(CalledOnValidThread()); | 1750 DCHECK(CalledOnValidThread()); |
| 1747 DCHECK(!catastrophic_error_handler.is_null()); | 1751 DCHECK(!catastrophic_error_handler.is_null()); |
| 1748 catastrophic_error_handler_ = catastrophic_error_handler; | 1752 catastrophic_error_handler_ = catastrophic_error_handler; |
| 1749 sql::Connection::ErrorCallback error_callback = | 1753 sql::Connection::ErrorCallback error_callback = |
| 1750 base::Bind(&OnSqliteError, catastrophic_error_handler_); | 1754 base::Bind(&OnSqliteError, catastrophic_error_handler_); |
| 1751 db_->set_error_callback(error_callback); | 1755 db_->set_error_callback(error_callback); |
| 1752 } | 1756 } |
| 1753 | 1757 |
| 1754 } // namespace syncable | 1758 } // namespace syncable |
| 1755 } // namespace syncer | 1759 } // namespace syncer |
| OLD | NEW |