| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 static IDBObjectStore* create(const IDBObjectStoreMetadata& metadata, IDBTra
nsaction* transaction) | 55 static IDBObjectStore* create(const IDBObjectStoreMetadata& metadata, IDBTra
nsaction* transaction) |
| 56 { | 56 { |
| 57 return new IDBObjectStore(metadata, transaction); | 57 return new IDBObjectStore(metadata, transaction); |
| 58 } | 58 } |
| 59 ~IDBObjectStore() { } | 59 ~IDBObjectStore() { } |
| 60 DECLARE_TRACE(); | 60 DECLARE_TRACE(); |
| 61 | 61 |
| 62 // Implement the IDBObjectStore IDL | 62 // Implement the IDBObjectStore IDL |
| 63 int64_t id() const { return m_metadata.id; } | 63 int64_t id() const { return m_metadata.id; } |
| 64 const String& name() const { return m_metadata.name; } | 64 const String& name() const { return m_metadata.name; } |
| 65 void setName(const String& name, ExceptionState&); |
| 65 ScriptValue keyPath(ScriptState*) const; | 66 ScriptValue keyPath(ScriptState*) const; |
| 66 DOMStringList* indexNames() const; | 67 DOMStringList* indexNames() const; |
| 67 IDBTransaction* transaction() const { return m_transaction.get(); } | 68 IDBTransaction* transaction() const { return m_transaction.get(); } |
| 68 bool autoIncrement() const { return m_metadata.autoIncrement; } | 69 bool autoIncrement() const { return m_metadata.autoIncrement; } |
| 69 | 70 |
| 70 IDBRequest* openCursor(ScriptState*, const ScriptValue& range, const String&
direction, ExceptionState&); | 71 IDBRequest* openCursor(ScriptState*, const ScriptValue& range, const String&
direction, ExceptionState&); |
| 71 IDBRequest* openKeyCursor(ScriptState*, const ScriptValue& range, const Stri
ng& direction, ExceptionState&); | 72 IDBRequest* openKeyCursor(ScriptState*, const ScriptValue& range, const Stri
ng& direction, ExceptionState&); |
| 72 IDBRequest* get(ScriptState*, const ScriptValue& key, ExceptionState&); | 73 IDBRequest* get(ScriptState*, const ScriptValue& key, ExceptionState&); |
| 73 IDBRequest* getKey(ScriptState*, const ScriptValue& key, ExceptionState&); | 74 IDBRequest* getKey(ScriptState*, const ScriptValue& key, ExceptionState&); |
| 74 IDBRequest* getAll(ScriptState*, const ScriptValue& range, unsigned long max
Count, ExceptionState&); | 75 IDBRequest* getAll(ScriptState*, const ScriptValue& range, unsigned long max
Count, ExceptionState&); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 98 void markDeleted() { m_deleted = true; } | 99 void markDeleted() { m_deleted = true; } |
| 99 bool isDeleted() const { return m_deleted; } | 100 bool isDeleted() const { return m_deleted; } |
| 100 void abort(); | 101 void abort(); |
| 101 void transactionFinished(); | 102 void transactionFinished(); |
| 102 | 103 |
| 103 const IDBObjectStoreMetadata& metadata() const { return m_metadata; } | 104 const IDBObjectStoreMetadata& metadata() const { return m_metadata; } |
| 104 void setMetadata(const IDBObjectStoreMetadata& metadata) { m_metadata = meta
data; } | 105 void setMetadata(const IDBObjectStoreMetadata& metadata) { m_metadata = meta
data; } |
| 105 | 106 |
| 106 typedef HeapVector<Member<IDBKey>> IndexKeys; | 107 typedef HeapVector<Member<IDBKey>> IndexKeys; |
| 107 | 108 |
| 109 // Used by IDBIndex::setName: |
| 110 bool containsIndex(const String& name) const |
| 111 { |
| 112 return findIndexId(name) != IDBIndexMetadata::InvalidId; |
| 113 } |
| 114 void indexRenamed(int64_t indexId, const String& newName); |
| 115 |
| 108 WebIDBDatabase* backendDB() const; | 116 WebIDBDatabase* backendDB() const; |
| 109 | 117 |
| 110 private: | 118 private: |
| 111 IDBObjectStore(const IDBObjectStoreMetadata&, IDBTransaction*); | 119 IDBObjectStore(const IDBObjectStoreMetadata&, IDBTransaction*); |
| 112 | 120 |
| 113 IDBIndex* createIndex(ScriptState*, const String& name, const IDBKeyPath&, c
onst IDBIndexParameters&, ExceptionState&); | 121 IDBIndex* createIndex(ScriptState*, const String& name, const IDBKeyPath&, c
onst IDBIndexParameters&, ExceptionState&); |
| 114 IDBRequest* put(ScriptState*, WebIDBPutMode, IDBAny* source, const ScriptVal
ue&, const ScriptValue& key, ExceptionState&); | 122 IDBRequest* put(ScriptState*, WebIDBPutMode, IDBAny* source, const ScriptVal
ue&, const ScriptValue& key, ExceptionState&); |
| 115 | 123 |
| 116 int64_t findIndexId(const String& name) const; | 124 int64_t findIndexId(const String& name) const; |
| 117 bool containsIndex(const String& name) const | |
| 118 { | |
| 119 return findIndexId(name) != IDBIndexMetadata::InvalidId; | |
| 120 } | |
| 121 | 125 |
| 122 IDBObjectStoreMetadata m_metadata; | 126 IDBObjectStoreMetadata m_metadata; |
| 123 Member<IDBTransaction> m_transaction; | 127 Member<IDBTransaction> m_transaction; |
| 124 bool m_deleted = false; | 128 bool m_deleted = false; |
| 125 | 129 |
| 126 typedef HeapHashMap<String, Member<IDBIndex>> IDBIndexMap; | 130 typedef HeapHashMap<String, Member<IDBIndex>> IDBIndexMap; |
| 127 IDBIndexMap m_indexMap; | 131 IDBIndexMap m_indexMap; |
| 128 | 132 |
| 129 // Used to mark indexes created in an aborted upgrade transaction as | 133 // Used to mark indexes created in an aborted upgrade transaction as |
| 130 // deleted. | 134 // deleted. |
| 131 HeapHashSet<Member<IDBIndex>> m_createdIndexes; | 135 HeapHashSet<Member<IDBIndex>> m_createdIndexes; |
| 132 }; | 136 }; |
| 133 | 137 |
| 134 } // namespace blink | 138 } // namespace blink |
| 135 | 139 |
| 136 #endif // IDBObjectStore_h | 140 #endif // IDBObjectStore_h |
| OLD | NEW |