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

Unified Diff: third_party/WebKit/Source/modules/indexeddb/IDBIndex.h

Issue 2314933005: Align IndexedDB metadata rollback on transaction abort to spec. (Closed)
Patch Set: Addressed feedback. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/indexeddb/IDBIndex.h
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBIndex.h b/third_party/WebKit/Source/modules/indexeddb/IDBIndex.h
index 7177a8b86ba262595d51bc22f53223ac92858574..7154b4298fbe5d56f0374a0c38fcabc418d2ddfd 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBIndex.h
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBIndex.h
@@ -48,10 +48,10 @@ class IDBIndex final : public GarbageCollectedFinalized<IDBIndex>,
DEFINE_WRAPPERTYPEINFO();
public:
- static IDBIndex* create(const IDBIndexMetadata& metadata,
+ static IDBIndex* create(RefPtr<IDBIndexMetadata> metadata,
IDBObjectStore* objectStore,
IDBTransaction* transaction) {
- return new IDBIndex(metadata, objectStore, transaction);
+ return new IDBIndex(std::move(metadata), objectStore, transaction);
}
~IDBIndex();
DECLARE_TRACE();
@@ -88,19 +88,37 @@ class IDBIndex final : public GarbageCollectedFinalized<IDBIndex>,
uint32_t maxCount,
ExceptionState&);
- void markDeleted() { m_deleted = true; }
- bool isDeleted() const;
+ void markDeleted() {
+ DCHECK(m_transaction->isVersionChange())
+ << "Index deleted outside versionchange transaction.";
+ m_deleted = true;
+ }
+ bool isDeleted() const { return m_deleted; }
int64_t id() const { return metadata().id; }
+ // True if this index was created in its associated transaction.
+ // Only valid if the index's associated transaction is a versionchange.
+ bool isNewlyCreated(
+ const IDBObjectStoreMetadata& oldObjectStoreMetadata) const {
+ DCHECK(m_transaction->isVersionChange());
+
+ // Index IDs are allocated sequentially, so we can tell if an index was
+ // created in this transaction by comparing its ID against the object
+ // store's maximum index ID at the time when the transaction was started.
+ return id() > oldObjectStoreMetadata.maxIndexId;
+ }
+
+ void revertMetadata(RefPtr<IDBIndexMetadata> oldMetadata);
+
// Used internally and by InspectorIndexedDBAgent:
IDBRequest* openCursor(ScriptState*, IDBKeyRange*, WebIDBCursorDirection);
WebIDBDatabase* backendDB() const;
private:
- IDBIndex(const IDBIndexMetadata&, IDBObjectStore*, IDBTransaction*);
+ IDBIndex(RefPtr<IDBIndexMetadata>, IDBObjectStore*, IDBTransaction*);
- const IDBIndexMetadata& metadata() const { return m_metadata; }
+ const IDBIndexMetadata& metadata() const { return *m_metadata; }
IDBRequest* getInternal(ScriptState*,
const ScriptValue& key,
@@ -112,7 +130,7 @@ class IDBIndex final : public GarbageCollectedFinalized<IDBIndex>,
ExceptionState&,
bool keyOnly);
- IDBIndexMetadata m_metadata;
+ RefPtr<IDBIndexMetadata> m_metadata;
Member<IDBObjectStore> m_objectStore;
Member<IDBTransaction> m_transaction;
bool m_deleted = false;
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/IDBDatabase.cpp ('k') | third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698