OLD | NEW |
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 Loading... |
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 const IDBIndexMetadata& metadata() const { return *m_metadata; } |
| 57 |
56 // Implement the IDL | 58 // Implement the IDL |
57 const String& name() const { return m_metadata.name; } | 59 const String& name() const { return metadata().name; } |
58 void setName(const String& name, ExceptionState&); | 60 void setName(const String& name, ExceptionState&); |
59 IDBObjectStore* objectStore() const { return m_objectStore.get(); } | 61 IDBObjectStore* objectStore() const { return m_objectStore.get(); } |
60 ScriptValue keyPath(ScriptState*) const; | 62 ScriptValue keyPath(ScriptState*) const; |
61 bool unique() const { return m_metadata.unique; } | 63 bool unique() const { return metadata().unique; } |
62 bool multiEntry() const { return m_metadata.multiEntry; } | 64 bool multiEntry() const { return metadata().multiEntry; } |
63 | 65 |
64 IDBRequest* openCursor(ScriptState*, const ScriptValue& key, const String& d
irection, ExceptionState&); | 66 IDBRequest* openCursor(ScriptState*, const ScriptValue& key, const String& d
irection, ExceptionState&); |
65 IDBRequest* openKeyCursor(ScriptState*, const ScriptValue& range, const Stri
ng& direction, ExceptionState&); | 67 IDBRequest* openKeyCursor(ScriptState*, const ScriptValue& range, const Stri
ng& direction, ExceptionState&); |
66 IDBRequest* count(ScriptState*, const ScriptValue& range, ExceptionState&); | 68 IDBRequest* count(ScriptState*, const ScriptValue& range, ExceptionState&); |
67 IDBRequest* get(ScriptState*, const ScriptValue& key, ExceptionState&); | 69 IDBRequest* get(ScriptState*, const ScriptValue& key, ExceptionState&); |
68 IDBRequest* getAll(ScriptState*, const ScriptValue& range, ExceptionState&); | 70 IDBRequest* getAll(ScriptState*, const ScriptValue& range, ExceptionState&); |
69 IDBRequest* getAll(ScriptState*, const ScriptValue& range, unsigned long max
Count, ExceptionState&); | 71 IDBRequest* getAll(ScriptState*, const ScriptValue& range, unsigned long max
Count, ExceptionState&); |
70 IDBRequest* getKey(ScriptState*, const ScriptValue& key, ExceptionState&); | 72 IDBRequest* getKey(ScriptState*, const ScriptValue& key, ExceptionState&); |
71 IDBRequest* getAllKeys(ScriptState*, const ScriptValue& range, ExceptionStat
e&); | 73 IDBRequest* getAllKeys(ScriptState*, const ScriptValue& range, ExceptionStat
e&); |
72 IDBRequest* getAllKeys(ScriptState*, const ScriptValue& range, uint32_t maxC
ount, ExceptionState&); | 74 IDBRequest* getAllKeys(ScriptState*, const ScriptValue& range, uint32_t maxC
ount, ExceptionState&); |
73 | 75 |
74 void markDeleted() { m_deleted = true; } | 76 void markDeleted() { m_deleted = true; } |
75 bool isDeleted() const; | 77 bool isDeleted() const { return m_deleted; } |
76 int64_t id() const { return m_metadata.id; } | 78 int64_t id() const { return metadata().id; } |
| 79 void revertMetadata(RefPtr<IDBIndexMetadata> oldMetadata); |
77 | 80 |
78 // Used internally and by InspectorIndexedDBAgent: | 81 // Used internally and by InspectorIndexedDBAgent: |
79 IDBRequest* openCursor(ScriptState*, IDBKeyRange*, WebIDBCursorDirection); | 82 IDBRequest* openCursor(ScriptState*, IDBKeyRange*, WebIDBCursorDirection); |
80 | 83 |
81 WebIDBDatabase* backendDB() const; | 84 WebIDBDatabase* backendDB() const; |
82 | 85 |
83 private: | 86 private: |
84 IDBIndex(const IDBIndexMetadata&, IDBObjectStore*, IDBTransaction*); | 87 IDBIndex(RefPtr<IDBIndexMetadata>, IDBObjectStore*, IDBTransaction*); |
85 | 88 |
86 IDBRequest* getInternal(ScriptState*, const ScriptValue& key, ExceptionState
&, bool keyOnly); | 89 IDBRequest* getInternal(ScriptState*, const ScriptValue& key, ExceptionState
&, bool keyOnly); |
87 IDBRequest* getAllInternal(ScriptState*, const ScriptValue& range, unsigned
long maxCount, ExceptionState&, bool keyOnly); | 90 IDBRequest* getAllInternal(ScriptState*, const ScriptValue& range, unsigned
long maxCount, ExceptionState&, bool keyOnly); |
88 | 91 |
89 IDBIndexMetadata m_metadata; | 92 RefPtr<IDBIndexMetadata> m_metadata; |
90 Member<IDBObjectStore> m_objectStore; | 93 Member<IDBObjectStore> m_objectStore; |
91 Member<IDBTransaction> m_transaction; | 94 Member<IDBTransaction> m_transaction; |
92 bool m_deleted = false; | 95 bool m_deleted = false; |
93 }; | 96 }; |
94 | 97 |
95 } // namespace blink | 98 } // namespace blink |
96 | 99 |
97 #endif // IDBIndex_h | 100 #endif // IDBIndex_h |
OLD | NEW |