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

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: Rebased. 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 28 matching lines...) Expand all
39 #include "wtf/text/WTFString.h" 39 #include "wtf/text/WTFString.h"
40 40
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>, public Script Wrappable { 46 class IDBIndex final : public GarbageCollectedFinalized<IDBIndex>, public Script Wrappable {
47 DEFINE_WRAPPERTYPEINFO(); 47 DEFINE_WRAPPERTYPEINFO();
48 public: 48 public:
49 static IDBIndex* create(const IDBIndexMetadata& metadata, IDBObjectStore* ob jectStore, IDBTransaction* transaction) 49 static IDBIndex* create(RefPtr<IDBIndexMetadata> metadata, IDBObjectStore* o bjectStore, IDBTransaction* transaction)
50 { 50 {
51 return new IDBIndex(metadata, objectStore, transaction); 51 return new IDBIndex(std::move(metadata), objectStore, transaction);
52 } 52 }
53 ~IDBIndex(); 53 ~IDBIndex();
54 DECLARE_TRACE(); 54 DECLARE_TRACE();
55 55
56 // Implement the IDL 56 // Implement the IDL
57 const String& name() const { return metadata().name; } 57 const String& name() const { return metadata().name; }
58 void setName(const String& name, ExceptionState&); 58 void setName(const String& name, ExceptionState&);
59 IDBObjectStore* objectStore() const { return m_objectStore.get(); } 59 IDBObjectStore* objectStore() const { return m_objectStore.get(); }
60 ScriptValue keyPath(ScriptState*) const; 60 ScriptValue keyPath(ScriptState*) const;
61 bool unique() const { return metadata().unique; } 61 bool unique() const { return metadata().unique; }
62 bool multiEntry() const { return metadata().multiEntry; } 62 bool multiEntry() const { return metadata().multiEntry; }
63 63
64 IDBRequest* openCursor(ScriptState*, const ScriptValue& key, const String& d irection, ExceptionState&); 64 IDBRequest* openCursor(ScriptState*, const ScriptValue& key, const String& d irection, ExceptionState&);
65 IDBRequest* openKeyCursor(ScriptState*, const ScriptValue& range, const Stri ng& direction, ExceptionState&); 65 IDBRequest* openKeyCursor(ScriptState*, const ScriptValue& range, const Stri ng& direction, ExceptionState&);
66 IDBRequest* count(ScriptState*, const ScriptValue& range, ExceptionState&); 66 IDBRequest* count(ScriptState*, const ScriptValue& range, ExceptionState&);
67 IDBRequest* get(ScriptState*, const ScriptValue& key, ExceptionState&); 67 IDBRequest* get(ScriptState*, const ScriptValue& key, ExceptionState&);
68 IDBRequest* getAll(ScriptState*, const ScriptValue& range, ExceptionState&); 68 IDBRequest* getAll(ScriptState*, const ScriptValue& range, ExceptionState&);
69 IDBRequest* getAll(ScriptState*, const ScriptValue& range, unsigned long max Count, ExceptionState&); 69 IDBRequest* getAll(ScriptState*, const ScriptValue& range, unsigned long max Count, ExceptionState&);
70 IDBRequest* getKey(ScriptState*, const ScriptValue& key, ExceptionState&); 70 IDBRequest* getKey(ScriptState*, const ScriptValue& key, ExceptionState&);
71 IDBRequest* getAllKeys(ScriptState*, const ScriptValue& range, ExceptionStat e&); 71 IDBRequest* getAllKeys(ScriptState*, const ScriptValue& range, ExceptionStat e&);
72 IDBRequest* getAllKeys(ScriptState*, const ScriptValue& range, uint32_t maxC ount, ExceptionState&); 72 IDBRequest* getAllKeys(ScriptState*, const ScriptValue& range, uint32_t maxC ount, ExceptionState&);
73 73
74 void markDeleted() { m_deleted = true; } 74 void markDeleted()
75 bool isDeleted() const; 75 {
76 DCHECK(m_transaction->isVersionChange()) << "Index deleted outside versi onchange transaction.";
77 m_deleted = true;
78 }
79 bool isDeleted() const { return m_deleted; }
76 int64_t id() const { return metadata().id; } 80 int64_t id() const { return metadata().id; }
81 void revertMetadata(RefPtr<IDBIndexMetadata> oldMetadata);
77 82
78 // Used internally and by InspectorIndexedDBAgent: 83 // Used internally and by InspectorIndexedDBAgent:
79 IDBRequest* openCursor(ScriptState*, IDBKeyRange*, WebIDBCursorDirection); 84 IDBRequest* openCursor(ScriptState*, IDBKeyRange*, WebIDBCursorDirection);
80 85
81 WebIDBDatabase* backendDB() const; 86 WebIDBDatabase* backendDB() const;
82 87
83 private: 88 private:
84 IDBIndex(const IDBIndexMetadata&, IDBObjectStore*, IDBTransaction*); 89 IDBIndex(RefPtr<IDBIndexMetadata>, IDBObjectStore*, IDBTransaction*);
85 90
86 const IDBIndexMetadata& metadata() const { return m_metadata; } 91 const IDBIndexMetadata& metadata() const { return *m_metadata; }
87 92
88 IDBRequest* getInternal(ScriptState*, const ScriptValue& key, ExceptionState &, bool keyOnly); 93 IDBRequest* getInternal(ScriptState*, const ScriptValue& key, ExceptionState &, bool keyOnly);
89 IDBRequest* getAllInternal(ScriptState*, const ScriptValue& range, unsigned long maxCount, ExceptionState&, bool keyOnly); 94 IDBRequest* getAllInternal(ScriptState*, const ScriptValue& range, unsigned long maxCount, ExceptionState&, bool keyOnly);
90 95
91 IDBIndexMetadata m_metadata; 96 RefPtr<IDBIndexMetadata> m_metadata;
92 Member<IDBObjectStore> m_objectStore; 97 Member<IDBObjectStore> m_objectStore;
93 Member<IDBTransaction> m_transaction; 98 Member<IDBTransaction> m_transaction;
94 bool m_deleted = false; 99 bool m_deleted = false;
95 }; 100 };
96 101
97 } // namespace blink 102 } // namespace blink
98 103
99 #endif // IDBIndex_h 104 #endif // IDBIndex_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698