Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: components/sync/syncable/directory_backing_store.cc

Issue 2287783002: Remove stl_util's STLValueDeleter. (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 674
675 int64_t handle = kernel->ref(META_HANDLE); 675 int64_t handle = kernel->ref(META_HANDLE);
676 if (SafeToPurgeOnLoading(*kernel)) { 676 if (SafeToPurgeOnLoading(*kernel)) {
677 metahandles_to_purge->insert(handle); 677 metahandles_to_purge->insert(handle);
678 } else { 678 } else {
679 ModelType model_type = kernel->GetModelType(); 679 ModelType model_type = kernel->GetModelType();
680 if (!IsRealDataType(model_type)) { 680 if (!IsRealDataType(model_type)) {
681 model_type = kernel->GetServerModelType(); 681 model_type = kernel->GetServerModelType();
682 } 682 }
683 ++model_type_entry_count[model_type]; 683 ++model_type_entry_count[model_type];
684 (*handles_map)[handle] = kernel.release(); 684 (*handles_map)[handle] = std::move(kernel);
685 } 685 }
686 } 686 }
687 687
688 UploadModelTypeEntryCount(total_specifics_copies, model_type_entry_count); 688 UploadModelTypeEntryCount(total_specifics_copies, model_type_entry_count);
689 689
690 return s.Succeeded(); 690 return s.Succeeded();
691 } 691 }
692 692
693 bool DirectoryBackingStore::SafeToPurgeOnLoading( 693 bool DirectoryBackingStore::SafeToPurgeOnLoading(
694 const EntryKernel& entry) const { 694 const EntryKernel& entry) const {
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 // whose PARENT_ID values refer to ID values that do not actually exist. 1644 // whose PARENT_ID values refer to ID values that do not actually exist.
1645 // Returns true on success. 1645 // Returns true on success.
1646 bool DirectoryBackingStore::VerifyReferenceIntegrity( 1646 bool DirectoryBackingStore::VerifyReferenceIntegrity(
1647 const Directory::MetahandlesMap* handles_map) { 1647 const Directory::MetahandlesMap* handles_map) {
1648 TRACE_EVENT0("sync", "SyncDatabaseIntegrityCheck"); 1648 TRACE_EVENT0("sync", "SyncDatabaseIntegrityCheck");
1649 typedef std::unordered_set<std::string> IdsSet; 1649 typedef std::unordered_set<std::string> IdsSet;
1650 1650
1651 IdsSet ids_set; 1651 IdsSet ids_set;
1652 bool is_ok = true; 1652 bool is_ok = true;
1653 1653
1654 for (Directory::MetahandlesMap::const_iterator it = handles_map->begin(); 1654 for (auto it = handles_map->begin(); it != handles_map->end(); ++it) {
1655 it != handles_map->end(); ++it) { 1655 EntryKernel* entry = it->second.get();
1656 EntryKernel* entry = it->second;
1657 bool is_duplicate_id = !(ids_set.insert(entry->ref(ID).value()).second); 1656 bool is_duplicate_id = !(ids_set.insert(entry->ref(ID).value()).second);
1658 is_ok = is_ok && !is_duplicate_id; 1657 is_ok = is_ok && !is_duplicate_id;
1659 } 1658 }
1660 1659
1661 IdsSet::iterator end = ids_set.end(); 1660 IdsSet::iterator end = ids_set.end();
1662 for (Directory::MetahandlesMap::const_iterator it = handles_map->begin(); 1661 for (auto it = handles_map->begin(); it != handles_map->end(); ++it) {
1663 it != handles_map->end(); ++it) { 1662 EntryKernel* entry = it->second.get();
1664 EntryKernel* entry = it->second;
1665 if (!entry->ref(PARENT_ID).IsNull()) { 1663 if (!entry->ref(PARENT_ID).IsNull()) {
1666 bool parent_exists = (ids_set.find(entry->ref(PARENT_ID).value()) != end); 1664 bool parent_exists = (ids_set.find(entry->ref(PARENT_ID).value()) != end);
1667 if (!parent_exists) { 1665 if (!parent_exists) {
1668 return false; 1666 return false;
1669 } 1667 }
1670 } 1668 }
1671 } 1669 }
1672 return is_ok; 1670 return is_ok;
1673 } 1671 }
1674 1672
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 DCHECK(CalledOnValidThread()); 1759 DCHECK(CalledOnValidThread());
1762 DCHECK(!catastrophic_error_handler.is_null()); 1760 DCHECK(!catastrophic_error_handler.is_null());
1763 catastrophic_error_handler_ = catastrophic_error_handler; 1761 catastrophic_error_handler_ = catastrophic_error_handler;
1764 sql::Connection::ErrorCallback error_callback = 1762 sql::Connection::ErrorCallback error_callback =
1765 base::Bind(&OnSqliteError, catastrophic_error_handler_); 1763 base::Bind(&OnSqliteError, catastrophic_error_handler_);
1766 db_->set_error_callback(error_callback); 1764 db_->set_error_callback(error_callback);
1767 } 1765 }
1768 1766
1769 } // namespace syncable 1767 } // namespace syncable
1770 } // namespace syncer 1768 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/syncable/directory.cc ('k') | components/sync/syncable/directory_backing_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698