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

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

Issue 2314933005: Align IndexedDB metadata rollback on transaction abort to spec. (Closed)
Patch Set: Rebased. 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.h
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.h b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.h
index 0bc4ab1ca37fb3cead3e7efe1a0b934ef014b85e..cd5e55e7db0c8575058c10b717e6e2b4d1177cb4 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.h
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.h
@@ -39,7 +39,6 @@
#include "public/platform/modules/indexeddb/WebIDBCursor.h"
#include "public/platform/modules/indexeddb/WebIDBDatabase.h"
#include "public/platform/modules/indexeddb/WebIDBTypes.h"
-#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
@@ -52,14 +51,14 @@ class ExceptionState;
class IDBObjectStore final : public GarbageCollectedFinalized<IDBObjectStore>, public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
- static IDBObjectStore* create(const IDBObjectStoreMetadata& metadata, IDBTransaction* transaction)
+ static IDBObjectStore* create(RefPtr<IDBObjectStoreMetadata> metadata, IDBTransaction* transaction)
{
- return new IDBObjectStore(metadata, transaction);
+ return new IDBObjectStore(std::move(metadata), transaction);
}
~IDBObjectStore() { }
DECLARE_TRACE();
- const IDBObjectStoreMetadata& metadata() const { return m_metadata; }
+ const IDBObjectStoreMetadata& metadata() const { return *m_metadata; }
const IDBKeyPath& idbKeyPath() const { return metadata().keyPath; }
// Implement the IDBObjectStore IDL
@@ -101,33 +100,57 @@ public:
void markDeleted();
bool isDeleted() const { return m_deleted; }
- void abort();
- void transactionFinished();
- void setMetadata(const IDBObjectStoreMetadata& metadata) { m_metadata = metadata; }
+ // Clears the cache used to implement the index() method.
+ //
+ // This should be called when the store's transaction clears its reference
+ // to this IDBObjectStore instance, so the store can clear its references to
+ // IDBIndex instances. This way, Oilpan can garbage-collect the instances
+ // that are not referenced in JavaScript.
+ //
+ // For most stores, the condition above is met when the transaction
+ /// finishes. The exception is stores that are created and deleted in the
jsbell 2016/09/26 22:23:40 Nit: extra /
pwnall 2016/09/27 00:12:19 Done.
+ // same transaction. Those stores will remain marked for deletion even if
+ // the transaction aborts, so the transaction can forget about them (and
+ // clear their index caches) right when they are deleted.
+ void clearIndexCache();
+
+ // Sets the object store's metadata to a previous version.
+ //
+ // The reverting process includes reverting the metadata for the IDBIndex
+ // instances that are still tracked by the store. It does not revert the
+ // IDBIndex metadata for indexes that were deleted in this transaction.
+ //
+ // Used when a versionchange transaction is aborted.
+ void revertMetadata(RefPtr<IDBObjectStoreMetadata> previousMetadata);
+ // This relies on the changes made by revertMetadata().
+ void revertDeletedIndexMetadata(IDBIndex& deletedIndex);
// Used by IDBIndex::setName:
bool containsIndex(const String& name) const
{
return findIndexId(name) != IDBIndexMetadata::InvalidId;
}
- void indexRenamed(int64_t indexId, const String& newName);
+ void renameIndex(int64_t indexId, const String& newName);
WebIDBDatabase* backendDB() const;
private:
- IDBObjectStore(const IDBObjectStoreMetadata&, IDBTransaction*);
+ IDBObjectStore(RefPtr<IDBObjectStoreMetadata>, IDBTransaction*);
IDBIndex* createIndex(ScriptState*, const String& name, const IDBKeyPath&, const IDBIndexParameters&, ExceptionState&);
IDBRequest* put(ScriptState*, WebIDBPutMode, IDBAny* source, const ScriptValue&, const ScriptValue& key, ExceptionState&);
int64_t findIndexId(const String& name) const;
- IDBObjectStoreMetadata m_metadata;
+ // The IDBObjectStoreMetadata is shared with the object store map in the
+ // database's metadata.
+ RefPtr<IDBObjectStoreMetadata> m_metadata;
Member<IDBTransaction> m_transaction;
bool m_deleted = false;
// Caches the IDBIndex instances returned by the index() method.
+ //
// The spec requires that an object store's index() returns the same
// IDBIndex instance for a specific index, so this cache is necessary
// for correctness.
@@ -137,9 +160,9 @@ private:
using IDBIndexMap = HeapHashMap<String, Member<IDBIndex>>;
IDBIndexMap m_indexMap;
- // Used to mark indexes created in an aborted upgrade transaction as
- // deleted.
- HeapHashSet<Member<IDBIndex>> m_createdIndexes;
+#if DCHECK_IS_ON()
+ bool m_clearIndexCacheCalled = false;
+#endif // DCHECK_IS_ON()
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698