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

Side by Side 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 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 30 matching lines...) Expand all
41 namespace blink { 41 namespace blink {
42 42
43 class ExceptionState; 43 class ExceptionState;
44 class IDBObjectStore; 44 class IDBObjectStore;
45 45
46 class IDBIndex final : public GarbageCollectedFinalized<IDBIndex>, 46 class IDBIndex final : public GarbageCollectedFinalized<IDBIndex>,
47 public ScriptWrappable { 47 public ScriptWrappable {
48 DEFINE_WRAPPERTYPEINFO(); 48 DEFINE_WRAPPERTYPEINFO();
49 49
50 public: 50 public:
51 static IDBIndex* create(const IDBIndexMetadata& metadata, 51 static IDBIndex* create(RefPtr<IDBIndexMetadata> metadata,
52 IDBObjectStore* objectStore, 52 IDBObjectStore* objectStore,
53 IDBTransaction* transaction) { 53 IDBTransaction* transaction) {
54 return new IDBIndex(metadata, objectStore, transaction); 54 return new IDBIndex(std::move(metadata), objectStore, transaction);
55 } 55 }
56 ~IDBIndex(); 56 ~IDBIndex();
57 DECLARE_TRACE(); 57 DECLARE_TRACE();
58 58
59 // Implement the IDL 59 // Implement the IDL
60 const String& name() const { return metadata().name; } 60 const String& name() const { return metadata().name; }
61 void setName(const String& name, ExceptionState&); 61 void setName(const String& name, ExceptionState&);
62 IDBObjectStore* objectStore() const { return m_objectStore.get(); } 62 IDBObjectStore* objectStore() const { return m_objectStore.get(); }
63 ScriptValue keyPath(ScriptState*) const; 63 ScriptValue keyPath(ScriptState*) const;
64 bool unique() const { return metadata().unique; } 64 bool unique() const { return metadata().unique; }
(...skipping 16 matching lines...) Expand all
81 ExceptionState&); 81 ExceptionState&);
82 IDBRequest* getKey(ScriptState*, const ScriptValue& key, ExceptionState&); 82 IDBRequest* getKey(ScriptState*, const ScriptValue& key, ExceptionState&);
83 IDBRequest* getAllKeys(ScriptState*, 83 IDBRequest* getAllKeys(ScriptState*,
84 const ScriptValue& range, 84 const ScriptValue& range,
85 ExceptionState&); 85 ExceptionState&);
86 IDBRequest* getAllKeys(ScriptState*, 86 IDBRequest* getAllKeys(ScriptState*,
87 const ScriptValue& range, 87 const ScriptValue& range,
88 uint32_t maxCount, 88 uint32_t maxCount,
89 ExceptionState&); 89 ExceptionState&);
90 90
91 void markDeleted() { m_deleted = true; } 91 void markDeleted() {
92 bool isDeleted() const; 92 DCHECK(m_transaction->isVersionChange())
93 << "Index deleted outside versionchange transaction.";
94 m_deleted = true;
95 }
96 bool isDeleted() const { return m_deleted; }
93 int64_t id() const { return metadata().id; } 97 int64_t id() const { return metadata().id; }
94 98
99 // True if this index was created in its associated transaction.
100 // Only valid if the index's associated transaction is a versionchange.
101 bool isNewlyCreated(
102 const IDBObjectStoreMetadata& oldObjectStoreMetadata) const {
103 DCHECK(m_transaction->isVersionChange());
104
105 // Index IDs are allocated sequentially, so we can tell if an index was
106 // created in this transaction by comparing its ID against the object
107 // store's maximum index ID at the time when the transaction was started.
108 return id() > oldObjectStoreMetadata.maxIndexId;
109 }
110
111 void revertMetadata(RefPtr<IDBIndexMetadata> oldMetadata);
112
95 // Used internally and by InspectorIndexedDBAgent: 113 // Used internally and by InspectorIndexedDBAgent:
96 IDBRequest* openCursor(ScriptState*, IDBKeyRange*, WebIDBCursorDirection); 114 IDBRequest* openCursor(ScriptState*, IDBKeyRange*, WebIDBCursorDirection);
97 115
98 WebIDBDatabase* backendDB() const; 116 WebIDBDatabase* backendDB() const;
99 117
100 private: 118 private:
101 IDBIndex(const IDBIndexMetadata&, IDBObjectStore*, IDBTransaction*); 119 IDBIndex(RefPtr<IDBIndexMetadata>, IDBObjectStore*, IDBTransaction*);
102 120
103 const IDBIndexMetadata& metadata() const { return m_metadata; } 121 const IDBIndexMetadata& metadata() const { return *m_metadata; }
104 122
105 IDBRequest* getInternal(ScriptState*, 123 IDBRequest* getInternal(ScriptState*,
106 const ScriptValue& key, 124 const ScriptValue& key,
107 ExceptionState&, 125 ExceptionState&,
108 bool keyOnly); 126 bool keyOnly);
109 IDBRequest* getAllInternal(ScriptState*, 127 IDBRequest* getAllInternal(ScriptState*,
110 const ScriptValue& range, 128 const ScriptValue& range,
111 unsigned long maxCount, 129 unsigned long maxCount,
112 ExceptionState&, 130 ExceptionState&,
113 bool keyOnly); 131 bool keyOnly);
114 132
115 IDBIndexMetadata m_metadata; 133 RefPtr<IDBIndexMetadata> m_metadata;
116 Member<IDBObjectStore> m_objectStore; 134 Member<IDBObjectStore> m_objectStore;
117 Member<IDBTransaction> m_transaction; 135 Member<IDBTransaction> m_transaction;
118 bool m_deleted = false; 136 bool m_deleted = false;
119 }; 137 };
120 138
121 } // namespace blink 139 } // namespace blink
122 140
123 #endif // IDBIndex_h 141 #endif // IDBIndex_h
OLDNEW
« 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