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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp

Issue 2709033003: Migrate WTF::HashMap::get() to ::at() (Closed)
Patch Set: rebase Created 3 years, 10 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 return it->value; 816 return it->value;
817 817
818 int64_t indexId = findIndexId(name); 818 int64_t indexId = findIndexId(name);
819 if (indexId == IDBIndexMetadata::InvalidId) { 819 if (indexId == IDBIndexMetadata::InvalidId) {
820 exceptionState.throwDOMException(NotFoundError, 820 exceptionState.throwDOMException(NotFoundError,
821 IDBDatabase::noSuchIndexErrorMessage); 821 IDBDatabase::noSuchIndexErrorMessage);
822 return nullptr; 822 return nullptr;
823 } 823 }
824 824
825 DCHECK(metadata().indexes.contains(indexId)); 825 DCHECK(metadata().indexes.contains(indexId));
826 RefPtr<IDBIndexMetadata> indexMetadata = metadata().indexes.get(indexId); 826 RefPtr<IDBIndexMetadata> indexMetadata = metadata().indexes.at(indexId);
827 DCHECK(indexMetadata.get()); 827 DCHECK(indexMetadata.get());
828 IDBIndex* index = 828 IDBIndex* index =
829 IDBIndex::create(std::move(indexMetadata), this, m_transaction.get()); 829 IDBIndex::create(std::move(indexMetadata), this, m_transaction.get());
830 m_indexMap.set(name, index); 830 m_indexMap.set(name, index);
831 return index; 831 return index;
832 } 832 }
833 833
834 void IDBObjectStore::deleteIndex(const String& name, 834 void IDBObjectStore::deleteIndex(const String& name,
835 ExceptionState& exceptionState) { 835 ExceptionState& exceptionState) {
836 IDB_TRACE("IDBObjectStore::deleteIndex"); 836 IDB_TRACE("IDBObjectStore::deleteIndex");
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 DCHECK(!oldMetadata->indexes.contains(indexId)); 1055 DCHECK(!oldMetadata->indexes.contains(indexId));
1056 index->markDeleted(); 1056 index->markDeleted();
1057 continue; 1057 continue;
1058 } 1058 }
1059 1059
1060 // The index was created in a previous transaction. We need to revert 1060 // The index was created in a previous transaction. We need to revert
1061 // its metadata. The index might have been deleted, so we 1061 // its metadata. The index might have been deleted, so we
1062 // unconditionally reset the deletion marker. 1062 // unconditionally reset the deletion marker.
1063 DCHECK(oldMetadata->indexes.contains(indexId)); 1063 DCHECK(oldMetadata->indexes.contains(indexId));
1064 RefPtr<IDBIndexMetadata> oldIndexMetadata = 1064 RefPtr<IDBIndexMetadata> oldIndexMetadata =
1065 oldMetadata->indexes.get(indexId); 1065 oldMetadata->indexes.at(indexId);
1066 index->revertMetadata(std::move(oldIndexMetadata)); 1066 index->revertMetadata(std::move(oldIndexMetadata));
1067 } 1067 }
1068 m_metadata = std::move(oldMetadata); 1068 m_metadata = std::move(oldMetadata);
1069 1069
1070 // An object store's metadata will only get reverted if the index was in the 1070 // An object store's metadata will only get reverted if the index was in the
1071 // database when the versionchange transaction started. 1071 // database when the versionchange transaction started.
1072 m_deleted = false; 1072 m_deleted = false;
1073 } 1073 }
1074 1074
1075 void IDBObjectStore::revertDeletedIndexMetadata(IDBIndex& deletedIndex) { 1075 void IDBObjectStore::revertDeletedIndexMetadata(IDBIndex& deletedIndex) {
1076 DCHECK(m_transaction->isVersionChange()); 1076 DCHECK(m_transaction->isVersionChange());
1077 DCHECK(!m_transaction->isActive()); 1077 DCHECK(!m_transaction->isActive());
1078 DCHECK(deletedIndex.objectStore() == this); 1078 DCHECK(deletedIndex.objectStore() == this);
1079 DCHECK(deletedIndex.isDeleted()); 1079 DCHECK(deletedIndex.isDeleted());
1080 1080
1081 const int64_t indexId = deletedIndex.id(); 1081 const int64_t indexId = deletedIndex.id();
1082 DCHECK(m_metadata->indexes.contains(indexId)) 1082 DCHECK(m_metadata->indexes.contains(indexId))
1083 << "The object store's metadata was not correctly reverted"; 1083 << "The object store's metadata was not correctly reverted";
1084 RefPtr<IDBIndexMetadata> oldIndexMetadata = m_metadata->indexes.get(indexId); 1084 RefPtr<IDBIndexMetadata> oldIndexMetadata = m_metadata->indexes.at(indexId);
1085 deletedIndex.revertMetadata(std::move(oldIndexMetadata)); 1085 deletedIndex.revertMetadata(std::move(oldIndexMetadata));
1086 } 1086 }
1087 1087
1088 void IDBObjectStore::renameIndex(int64_t indexId, const String& newName) { 1088 void IDBObjectStore::renameIndex(int64_t indexId, const String& newName) {
1089 DCHECK(m_transaction->isVersionChange()); 1089 DCHECK(m_transaction->isVersionChange());
1090 DCHECK(m_transaction->isActive()); 1090 DCHECK(m_transaction->isActive());
1091 1091
1092 backendDB()->renameIndex(m_transaction->id(), id(), indexId, newName); 1092 backendDB()->renameIndex(m_transaction->id(), id(), indexId, newName);
1093 1093
1094 auto metadataIterator = m_metadata->indexes.find(indexId); 1094 auto metadataIterator = m_metadata->indexes.find(indexId);
(...skipping 16 matching lines...) Expand all
1111 } 1111 }
1112 } 1112 }
1113 return IDBIndexMetadata::InvalidId; 1113 return IDBIndexMetadata::InvalidId;
1114 } 1114 }
1115 1115
1116 WebIDBDatabase* IDBObjectStore::backendDB() const { 1116 WebIDBDatabase* IDBObjectStore::backendDB() const {
1117 return m_transaction->backendDB(); 1117 return m_transaction->backendDB();
1118 } 1118 }
1119 1119
1120 } // namespace blink 1120 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698