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

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())
jsbell 2016/10/06 20:01:31 This should probably move into .cpp file. (Otherwi
pwnall 2016/10/06 22:15:22 Isn't that an acceptable tradeoff in return for sm
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; }
98 void revertMetadata(RefPtr<IDBIndexMetadata> oldMetadata);
94 99
95 // Used internally and by InspectorIndexedDBAgent: 100 // Used internally and by InspectorIndexedDBAgent:
96 IDBRequest* openCursor(ScriptState*, IDBKeyRange*, WebIDBCursorDirection); 101 IDBRequest* openCursor(ScriptState*, IDBKeyRange*, WebIDBCursorDirection);
97 102
98 WebIDBDatabase* backendDB() const; 103 WebIDBDatabase* backendDB() const;
99 104
100 private: 105 private:
101 IDBIndex(const IDBIndexMetadata&, IDBObjectStore*, IDBTransaction*); 106 IDBIndex(RefPtr<IDBIndexMetadata>, IDBObjectStore*, IDBTransaction*);
102 107
103 const IDBIndexMetadata& metadata() const { return m_metadata; } 108 const IDBIndexMetadata& metadata() const { return *m_metadata; }
104 109
105 IDBRequest* getInternal(ScriptState*, 110 IDBRequest* getInternal(ScriptState*,
106 const ScriptValue& key, 111 const ScriptValue& key,
107 ExceptionState&, 112 ExceptionState&,
108 bool keyOnly); 113 bool keyOnly);
109 IDBRequest* getAllInternal(ScriptState*, 114 IDBRequest* getAllInternal(ScriptState*,
110 const ScriptValue& range, 115 const ScriptValue& range,
111 unsigned long maxCount, 116 unsigned long maxCount,
112 ExceptionState&, 117 ExceptionState&,
113 bool keyOnly); 118 bool keyOnly);
114 119
115 IDBIndexMetadata m_metadata; 120 RefPtr<IDBIndexMetadata> m_metadata;
116 Member<IDBObjectStore> m_objectStore; 121 Member<IDBObjectStore> m_objectStore;
117 Member<IDBTransaction> m_transaction; 122 Member<IDBTransaction> m_transaction;
118 bool m_deleted = false; 123 bool m_deleted = false;
119 }; 124 };
120 125
121 } // namespace blink 126 } // namespace blink
122 127
123 #endif // IDBIndex_h 128 #endif // IDBIndex_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698