Chromium Code Reviews| Index: third_party/WebKit/Source/modules/indexeddb/IDBTransaction.h |
| diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBTransaction.h b/third_party/WebKit/Source/modules/indexeddb/IDBTransaction.h |
| index 154120dbc681958c92aad62d807b81d6f05aad53..abd12f4061e05cacf0793ad9c59124bfd455ae76 100644 |
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBTransaction.h |
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBTransaction.h |
| @@ -48,7 +48,6 @@ class ExceptionState; |
| class IDBDatabase; |
| class IDBObjectStore; |
| class IDBOpenDBRequest; |
| -struct IDBObjectStoreMetadata; |
| class MODULES_EXPORT IDBTransaction final |
| : public EventTargetWithInlineData |
| @@ -57,8 +56,8 @@ class MODULES_EXPORT IDBTransaction final |
| USING_GARBAGE_COLLECTED_MIXIN(IDBTransaction); |
| DEFINE_WRAPPERTYPEINFO(); |
| public: |
| - static IDBTransaction* create(ScriptState*, int64_t, const HashSet<String>& objectStoreNames, WebIDBTransactionMode, IDBDatabase*); |
| - static IDBTransaction* create(ScriptState*, int64_t, IDBDatabase*, IDBOpenDBRequest*, const IDBDatabaseMetadata& previousMetadata); |
| + static IDBTransaction* createNonVersionChange(ScriptState*, int64_t, const HashSet<String>& objectStoreNames, WebIDBTransactionMode, IDBDatabase*); |
| + static IDBTransaction* createVersionChange(ScriptState*, int64_t, IDBDatabase*, IDBOpenDBRequest*, const IDBDatabaseMetadata& oldMetadata); |
| ~IDBTransaction() override; |
| DECLARE_VIRTUAL_TRACE(); |
| @@ -116,6 +115,13 @@ private: |
| void enqueueEvent(Event*); |
| + // Called when a transaction is aborted. |
| + void abortOutstandingRequests(); |
| + void revertDatabaseMetadata(); |
| + |
| + // Called when a transaction is completed (committed or aborted). |
| + void finish(); |
|
cmumford
2016/09/19 23:26:48
If the transaction has already finished then this
pwnall
2016/09/20 09:11:15
Done.
|
| + |
| enum State { |
| Inactive, // Created or started, but not in an event callback |
| Active, // Created or started, in creation scope or an event callback |
| @@ -125,7 +131,7 @@ private: |
| const int64_t m_id; |
| Member<IDBDatabase> m_database; |
| - const HashSet<String> m_objectStoreNames; |
| + const HashSet<String> m_scope; |
|
cmumford
2016/09/19 23:26:48
You may want to add a comment above m_scope.
pwnall
2016/09/20 09:11:15
Done.
Thank you! That's a very good point!
|
| Member<IDBOpenDBRequest> m_openDBRequest; |
| const WebIDBTransactionMode m_mode; |
| State m_state = Active; |
| @@ -135,7 +141,19 @@ private: |
| HeapListHashSet<Member<IDBRequest>> m_requestList; |
| - typedef HeapHashMap<String, Member<IDBObjectStore>> IDBObjectStoreMap; |
| +#if DCHECK_IS_ON() |
| + bool m_finishCalled = false; |
| +#endif // DCHECK_IS_ON() |
| + |
| + // Caches the IDBObjectStore instances returned by the objectStore() method. |
| + // |
| + // The spec requires that a transaction's objectStore() returns the same |
| + // IDBObjectStore instance for a specific store, so this cache is necessary |
| + // for correctness. |
| + // |
| + // objectStore() throws for completed/aborted transactions, so this is not |
| + // used after a transaction is finished, and can be cleared. |
| + using IDBObjectStoreMap = HeapHashMap<String, Member<IDBObjectStore>>; |
| IDBObjectStoreMap m_objectStoreMap; |
| // Used to mark stores created in an aborted upgrade transaction as |
| @@ -149,7 +167,8 @@ private: |
| // Holds stores created, deleted, or used during upgrade transactions to |
| // reset metadata in case of abort. |
| HeapHashMap<Member<IDBObjectStore>, IDBObjectStoreMetadata> m_objectStoreCleanupMap; |
| - IDBDatabaseMetadata m_previousMetadata; |
| + |
| + IDBDatabaseMetadata m_oldDatabaseMetadata; |
| }; |
| } // namespace blink |