Chromium Code Reviews| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 PassRefPtrWillBeRawPtr<DOMStringList> IDBObjectStore::indexNames() const | 81 PassRefPtrWillBeRawPtr<DOMStringList> IDBObjectStore::indexNames() const |
| 82 { | 82 { |
| 83 IDB_TRACE("IDBObjectStore::indexNames"); | 83 IDB_TRACE("IDBObjectStore::indexNames"); |
| 84 RefPtrWillBeRawPtr<DOMStringList> indexNames = DOMStringList::create(); | 84 RefPtrWillBeRawPtr<DOMStringList> indexNames = DOMStringList::create(); |
| 85 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) | 85 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) |
| 86 indexNames->append(it->value.name); | 86 indexNames->append(it->value.name); |
| 87 indexNames->sort(); | 87 indexNames->sort(); |
| 88 return indexNames.release(); | 88 return indexNames.release(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::get(ExecutionContext* context , const ScriptValue& key, ExceptionState& exceptionState) | 91 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::get(ScriptState* scriptState, const ScriptValue& key, ExceptionState& exceptionState) |
| 92 { | 92 { |
| 93 IDB_TRACE("IDBObjectStore::get"); | 93 IDB_TRACE("IDBObjectStore::get"); |
| 94 if (isDeleted()) { | 94 if (isDeleted()) { |
| 95 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); | 95 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); |
| 96 return nullptr; | 96 return nullptr; |
| 97 } | 97 } |
| 98 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 98 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 99 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); | 99 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); |
| 100 return nullptr; | 100 return nullptr; |
| 101 } | 101 } |
| 102 if (!m_transaction->isActive()) { | 102 if (!m_transaction->isActive()) { |
| 103 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); | 103 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); |
| 104 return nullptr; | 104 return nullptr; |
| 105 } | 105 } |
| 106 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(cont ext, key, exceptionState); | 106 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(scri ptState->executionContext(), key, exceptionState); |
| 107 if (exceptionState.hadException()) | 107 if (exceptionState.hadException()) |
| 108 return nullptr; | 108 return nullptr; |
| 109 if (!keyRange) { | 109 if (!keyRange) { |
| 110 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage); | 110 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage); |
| 111 return nullptr; | 111 return nullptr; |
| 112 } | 112 } |
| 113 if (!backendDB()) { | 113 if (!backendDB()) { |
| 114 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); | 114 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); |
| 115 return nullptr; | 115 return nullptr; |
| 116 } | 116 } |
| 117 | 117 |
| 118 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny: :create(this), m_transaction.get()); | 118 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB Any::create(this), m_transaction.get()); |
| 119 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key Range.release(), false, WebIDBCallbacksImpl::create(request).leakPtr()); | 119 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key Range.release(), false, WebIDBCallbacksImpl::create(request).leakPtr()); |
| 120 return request.release(); | 120 return request.release(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada ta& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* in dexKeys) | 123 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada ta& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* in dexKeys) |
| 124 { | 124 { |
| 125 ASSERT(indexKeys); | 125 ASSERT(indexKeys); |
| 126 RefPtrWillBeRawPtr<IDBKey> indexKey = createIDBKeyFromScriptValueAndKeyPath( isolate, objectValue, indexMetadata.keyPath); | 126 RefPtrWillBeRawPtr<IDBKey> indexKey = createIDBKeyFromScriptValueAndKeyPath( isolate, objectValue, indexMetadata.keyPath); |
| 127 | 127 |
| 128 if (!indexKey) | 128 if (!indexKey) |
| 129 return; | 129 return; |
| 130 | 130 |
| 131 if (!indexMetadata.multiEntry || indexKey->type() != IDBKey::ArrayType) { | 131 if (!indexMetadata.multiEntry || indexKey->type() != IDBKey::ArrayType) { |
| 132 if (!indexKey->isValid()) | 132 if (!indexKey->isValid()) |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 indexKeys->append(indexKey); | 135 indexKeys->append(indexKey); |
| 136 } else { | 136 } else { |
| 137 ASSERT(indexMetadata.multiEntry); | 137 ASSERT(indexMetadata.multiEntry); |
| 138 ASSERT(indexKey->type() == IDBKey::ArrayType); | 138 ASSERT(indexKey->type() == IDBKey::ArrayType); |
| 139 indexKey = IDBKey::createMultiEntryArray(indexKey->array()); | 139 indexKey = IDBKey::createMultiEntryArray(indexKey->array()); |
| 140 | 140 |
| 141 for (size_t i = 0; i < indexKey->array().size(); ++i) | 141 for (size_t i = 0; i < indexKey->array().size(); ++i) |
| 142 indexKeys->append(indexKey->array()[i]); | 142 indexKeys->append(indexKey->array()[i]); |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 | 145 |
| 146 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::add(ExecutionContext* executi onContext, ScriptValue& value, const ScriptValue& key, ExceptionState& exception State) | 146 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::add(ScriptState* scriptState, ScriptValue& value, const ScriptValue& key, ExceptionState& exceptionState) |
| 147 { | 147 { |
| 148 IDB_TRACE("IDBObjectStore::add"); | 148 IDB_TRACE("IDBObjectStore::add"); |
| 149 return put(executionContext, WebIDBDatabase::AddOnly, IDBAny::create(this), value, key, exceptionState); | 149 return put(scriptState, WebIDBDatabase::AddOnly, IDBAny::create(this), value , key, exceptionState); |
| 150 } | 150 } |
| 151 | 151 |
| 152 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::put(ExecutionContext* executi onContext, ScriptValue& value, const ScriptValue& key, ExceptionState& exception State) | 152 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::put(ScriptState* scriptState, ScriptValue& value, const ScriptValue& key, ExceptionState& exceptionState) |
| 153 { | 153 { |
| 154 IDB_TRACE("IDBObjectStore::put"); | 154 IDB_TRACE("IDBObjectStore::put"); |
| 155 return put(executionContext, WebIDBDatabase::AddOrUpdate, IDBAny::create(thi s), value, key, exceptionState); | 155 return put(scriptState, WebIDBDatabase::AddOrUpdate, IDBAny::create(this), v alue, key, exceptionState); |
| 156 } | 156 } |
| 157 | 157 |
| 158 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::put(ExecutionContext* executi onContext, WebIDBDatabase::PutMode putMode, PassRefPtrWillBeRawPtr<IDBAny> sourc e, ScriptValue& value, const ScriptValue& keyValue, ExceptionState& exceptionSta te) | 158 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::put(ScriptState* scriptState, WebIDBDatabase::PutMode putMode, PassRefPtrWillBeRawPtr<IDBAny> source, ScriptV alue& value, const ScriptValue& keyValue, ExceptionState& exceptionState) |
| 159 { | 159 { |
| 160 RefPtrWillBeRawPtr<IDBKey> key = keyValue.isUndefined() ? nullptr : scriptVa lueToIDBKey(toIsolate(executionContext), keyValue); | 160 RefPtrWillBeRawPtr<IDBKey> key = keyValue.isUndefined() ? nullptr : scriptVa lueToIDBKey(scriptState->isolate(), keyValue); |
| 161 return put(executionContext, putMode, source, value, key.release(), exceptio nState); | 161 return put(scriptState, putMode, source, value, key.release(), exceptionStat e); |
| 162 } | 162 } |
| 163 | 163 |
| 164 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::put(ExecutionContext* executi onContext, WebIDBDatabase::PutMode putMode, PassRefPtrWillBeRawPtr<IDBAny> sourc e, ScriptValue& value, PassRefPtrWillBeRawPtr<IDBKey> prpKey, ExceptionState& ex ceptionState) | 164 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::put(ScriptState* scriptState, WebIDBDatabase::PutMode putMode, PassRefPtrWillBeRawPtr<IDBAny> source, ScriptV alue& value, PassRefPtrWillBeRawPtr<IDBKey> prpKey, ExceptionState& exceptionSta te) |
| 165 { | 165 { |
| 166 RefPtrWillBeRawPtr<IDBKey> key = prpKey; | 166 RefPtrWillBeRawPtr<IDBKey> key = prpKey; |
| 167 if (isDeleted()) { | 167 if (isDeleted()) { |
| 168 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); | 168 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); |
| 169 return nullptr; | 169 return nullptr; |
| 170 } | 170 } |
| 171 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 171 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 172 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); | 172 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); |
| 173 return nullptr; | 173 return nullptr; |
| 174 } | 174 } |
| 175 if (!m_transaction->isActive()) { | 175 if (!m_transaction->isActive()) { |
| 176 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); | 176 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); |
| 177 return nullptr; | 177 return nullptr; |
| 178 } | 178 } |
| 179 if (m_transaction->isReadOnly()) { | 179 if (m_transaction->isReadOnly()) { |
| 180 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction ReadOnlyErrorMessage); | 180 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction ReadOnlyErrorMessage); |
| 181 return nullptr; | 181 return nullptr; |
| 182 } | 182 } |
| 183 | 183 |
| 184 Vector<WebBlobInfo> blobInfo; | 184 Vector<WebBlobInfo> blobInfo; |
| 185 | 185 |
| 186 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::creat e(value, &blobInfo, exceptionState, toIsolate(executionContext)); | 186 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::creat e(value, &blobInfo, exceptionState, scriptState->isolate()); |
| 187 if (exceptionState.hadException()) | 187 if (exceptionState.hadException()) |
| 188 return nullptr; | 188 return nullptr; |
| 189 | 189 |
| 190 if (serializedValue->containsBlobs()) { | 190 if (serializedValue->containsBlobs()) { |
| 191 // FIXME: Add Blob/File/FileList support | 191 // FIXME: Add Blob/File/FileList support |
| 192 exceptionState.throwDOMException(DataCloneError, "The object store curre ntly does not support blob values."); | 192 exceptionState.throwDOMException(DataCloneError, "The object store curre ntly does not support blob values."); |
| 193 return nullptr; | 193 return nullptr; |
| 194 } | 194 } |
| 195 ASSERT(blobInfo.isEmpty()); | 195 ASSERT(blobInfo.isEmpty()); |
| 196 | 196 |
| 197 const IDBKeyPath& keyPath = m_metadata.keyPath; | 197 const IDBKeyPath& keyPath = m_metadata.keyPath; |
| 198 const bool usesInLineKeys = !keyPath.isNull(); | 198 const bool usesInLineKeys = !keyPath.isNull(); |
| 199 const bool hasKeyGenerator = autoIncrement(); | 199 const bool hasKeyGenerator = autoIncrement(); |
| 200 | 200 |
| 201 if (putMode != WebIDBDatabase::CursorUpdate && usesInLineKeys && key) { | 201 if (putMode != WebIDBDatabase::CursorUpdate && usesInLineKeys && key) { |
| 202 exceptionState.throwDOMException(DataError, "The object store uses in-li ne keys and the key parameter was provided."); | 202 exceptionState.throwDOMException(DataError, "The object store uses in-li ne keys and the key parameter was provided."); |
| 203 return nullptr; | 203 return nullptr; |
| 204 } | 204 } |
| 205 if (!usesInLineKeys && !hasKeyGenerator && !key) { | 205 if (!usesInLineKeys && !hasKeyGenerator && !key) { |
| 206 exceptionState.throwDOMException(DataError, "The object store uses out-o f-line keys and has no key generator and the key parameter was not provided."); | 206 exceptionState.throwDOMException(DataError, "The object store uses out-o f-line keys and has no key generator and the key parameter was not provided."); |
| 207 return nullptr; | 207 return nullptr; |
| 208 } | 208 } |
| 209 if (usesInLineKeys) { | 209 if (usesInLineKeys) { |
| 210 RefPtrWillBeRawPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKe yPath(toIsolate(executionContext), value, keyPath); | 210 RefPtrWillBeRawPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKe yPath(scriptState->isolate(), value, keyPath); |
| 211 if (keyPathKey && !keyPathKey->isValid()) { | 211 if (keyPathKey && !keyPathKey->isValid()) { |
| 212 exceptionState.throwDOMException(DataError, "Evaluating the object s tore's key path yielded a value that is not a valid key."); | 212 exceptionState.throwDOMException(DataError, "Evaluating the object s tore's key path yielded a value that is not a valid key."); |
| 213 return nullptr; | 213 return nullptr; |
| 214 } | 214 } |
| 215 if (!hasKeyGenerator && !keyPathKey) { | 215 if (!hasKeyGenerator && !keyPathKey) { |
| 216 exceptionState.throwDOMException(DataError, "Evaluating the object s tore's key path did not yield a value."); | 216 exceptionState.throwDOMException(DataError, "Evaluating the object s tore's key path did not yield a value."); |
| 217 return nullptr; | 217 return nullptr; |
| 218 } | 218 } |
| 219 if (hasKeyGenerator && !keyPathKey) { | 219 if (hasKeyGenerator && !keyPathKey) { |
| 220 if (!canInjectIDBKeyIntoScriptValue(toIsolate(executionContext), val ue, keyPath)) { | 220 if (!canInjectIDBKeyIntoScriptValue(scriptState->isolate(), value, k eyPath)) { |
| 221 exceptionState.throwDOMException(DataError, "A generated key cou ld not be inserted into the value."); | 221 exceptionState.throwDOMException(DataError, "A generated key cou ld not be inserted into the value."); |
| 222 return nullptr; | 222 return nullptr; |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 if (keyPathKey) | 225 if (keyPathKey) |
| 226 key = keyPathKey; | 226 key = keyPathKey; |
| 227 } | 227 } |
| 228 if (key && !key->isValid()) { | 228 if (key && !key->isValid()) { |
| 229 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); | 229 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); |
| 230 return nullptr; | 230 return nullptr; |
| 231 } | 231 } |
| 232 | 232 |
| 233 if (!backendDB()) { | 233 if (!backendDB()) { |
| 234 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); | 234 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); |
| 235 return nullptr; | 235 return nullptr; |
| 236 } | 236 } |
| 237 | 237 |
| 238 Vector<int64_t> indexIds; | 238 Vector<int64_t> indexIds; |
| 239 WillBeHeapVector<IndexKeys> indexKeys; | 239 WillBeHeapVector<IndexKeys> indexKeys; |
| 240 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) { | 240 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) { |
| 241 IndexKeys keys; | 241 IndexKeys keys; |
| 242 generateIndexKeysForValue(toIsolate(executionContext), it->value, value, &keys); | 242 generateIndexKeysForValue(scriptState->isolate(), it->value, value, &key s); |
| 243 indexIds.append(it->key); | 243 indexIds.append(it->key); |
| 244 indexKeys.append(keys); | 244 indexKeys.append(keys); |
| 245 } | 245 } |
| 246 | 246 |
| 247 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext , source, m_transaction.get()); | 247 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, sou rce, m_transaction.get()); |
| 248 Vector<char> wireBytes; | 248 Vector<char> wireBytes; |
| 249 serializedValue->toWireBytes(wireBytes); | 249 serializedValue->toWireBytes(wireBytes); |
| 250 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); | 250 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); |
| 251 | 251 |
| 252 backendDB()->put(m_transaction->id(), id(), blink::WebData(valueBuffer), blo bInfo, key.release(), static_cast<WebIDBDatabase::PutMode>(putMode), WebIDBCallb acksImpl::create(request).leakPtr(), indexIds, indexKeys); | 252 backendDB()->put(m_transaction->id(), id(), blink::WebData(valueBuffer), blo bInfo, key.release(), static_cast<WebIDBDatabase::PutMode>(putMode), WebIDBCallb acksImpl::create(request).leakPtr(), indexIds, indexKeys); |
| 253 return request.release(); | 253 return request.release(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::deleteFunction(ExecutionConte xt* context, const ScriptValue& key, ExceptionState& exceptionState) | 256 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptState* s criptState, const ScriptValue& key, ExceptionState& exceptionState) |
| 257 { | 257 { |
| 258 IDB_TRACE("IDBObjectStore::delete"); | 258 IDB_TRACE("IDBObjectStore::delete"); |
| 259 if (isDeleted()) { | 259 if (isDeleted()) { |
| 260 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); | 260 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); |
| 261 return nullptr; | 261 return nullptr; |
| 262 } | 262 } |
| 263 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 263 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 264 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); | 264 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); |
| 265 return nullptr; | 265 return nullptr; |
| 266 } | 266 } |
| 267 if (!m_transaction->isActive()) { | 267 if (!m_transaction->isActive()) { |
| 268 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); | 268 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); |
| 269 return nullptr; | 269 return nullptr; |
| 270 } | 270 } |
| 271 if (m_transaction->isReadOnly()) { | 271 if (m_transaction->isReadOnly()) { |
| 272 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction ReadOnlyErrorMessage); | 272 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction ReadOnlyErrorMessage); |
| 273 return nullptr; | 273 return nullptr; |
| 274 } | 274 } |
| 275 | 275 |
| 276 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(cont ext, key, exceptionState); | 276 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(scri ptState->executionContext(), key, exceptionState); |
| 277 if (exceptionState.hadException()) | 277 if (exceptionState.hadException()) |
| 278 return nullptr; | 278 return nullptr; |
| 279 if (!keyRange) { | 279 if (!keyRange) { |
| 280 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage); | 280 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage); |
| 281 return nullptr; | 281 return nullptr; |
| 282 } | 282 } |
| 283 if (!backendDB()) { | 283 if (!backendDB()) { |
| 284 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); | 284 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); |
| 285 return nullptr; | 285 return nullptr; |
| 286 } | 286 } |
| 287 | 287 |
| 288 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny: :create(this), m_transaction.get()); | 288 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB Any::create(this), m_transaction.get()); |
| 289 backendDB()->deleteRange(m_transaction->id(), id(), keyRange.release(), WebI DBCallbacksImpl::create(request).leakPtr()); | 289 backendDB()->deleteRange(m_transaction->id(), id(), keyRange.release(), WebI DBCallbacksImpl::create(request).leakPtr()); |
| 290 return request.release(); | 290 return request.release(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::clear(ExecutionContext* conte xt, ExceptionState& exceptionState) | 293 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::clear(ScriptState* scriptStat e, ExceptionState& exceptionState) |
| 294 { | 294 { |
| 295 IDB_TRACE("IDBObjectStore::clear"); | 295 IDB_TRACE("IDBObjectStore::clear"); |
| 296 if (isDeleted()) { | 296 if (isDeleted()) { |
| 297 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); | 297 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); |
| 298 return nullptr; | 298 return nullptr; |
| 299 } | 299 } |
| 300 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 300 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 301 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); | 301 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); |
| 302 return nullptr; | 302 return nullptr; |
| 303 } | 303 } |
| 304 if (!m_transaction->isActive()) { | 304 if (!m_transaction->isActive()) { |
| 305 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); | 305 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); |
| 306 return nullptr; | 306 return nullptr; |
| 307 } | 307 } |
| 308 if (m_transaction->isReadOnly()) { | 308 if (m_transaction->isReadOnly()) { |
| 309 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction ReadOnlyErrorMessage); | 309 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction ReadOnlyErrorMessage); |
| 310 return nullptr; | 310 return nullptr; |
| 311 } | 311 } |
| 312 if (!backendDB()) { | 312 if (!backendDB()) { |
| 313 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); | 313 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); |
| 314 return nullptr; | 314 return nullptr; |
| 315 } | 315 } |
| 316 | 316 |
| 317 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny: :create(this), m_transaction.get()); | 317 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB Any::create(this), m_transaction.get()); |
| 318 backendDB()->clear(m_transaction->id(), id(), WebIDBCallbacksImpl::create(re quest).leakPtr()); | 318 backendDB()->clear(m_transaction->id(), id(), WebIDBCallbacksImpl::create(re quest).leakPtr()); |
| 319 return request.release(); | 319 return request.release(); |
| 320 } | 320 } |
| 321 | 321 |
| 322 namespace { | 322 namespace { |
| 323 // This class creates the index keys for a given index by extracting | 323 // This class creates the index keys for a given index by extracting |
| 324 // them from the SerializedScriptValue, for all the existing values in | 324 // them from the SerializedScriptValue, for all the existing values in |
| 325 // the objectStore. It only needs to be kept alive by virtue of being | 325 // the objectStore. It only needs to be kept alive by virtue of being |
| 326 // a listener on an IDBRequest object, in the same way that JavaScript | 326 // a listener on an IDBRequest object, in the same way that JavaScript |
| 327 // cursor success handlers are kept alive. | 327 // cursor success handlers are kept alive. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 341 IndexPopulator(ScriptState* scriptState, PassRefPtrWillBeRawPtr<IDBDatabase> database, int64_t transactionId, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata) | 341 IndexPopulator(ScriptState* scriptState, PassRefPtrWillBeRawPtr<IDBDatabase> database, int64_t transactionId, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata) |
| 342 : EventListener(CPPEventListenerType) | 342 : EventListener(CPPEventListenerType) |
| 343 , m_scriptState(scriptState) | 343 , m_scriptState(scriptState) |
| 344 , m_database(database) | 344 , m_database(database) |
| 345 , m_transactionId(transactionId) | 345 , m_transactionId(transactionId) |
| 346 , m_objectStoreId(objectStoreId) | 346 , m_objectStoreId(objectStoreId) |
| 347 , m_indexMetadata(indexMetadata) | 347 , m_indexMetadata(indexMetadata) |
| 348 { | 348 { |
| 349 } | 349 } |
| 350 | 350 |
| 351 virtual void handleEvent(ExecutionContext* context, Event* event) OVERRIDE | 351 virtual void handleEvent(ExecutionContext* executionContext, Event* event) O VERRIDE |
|
jsbell
2014/05/23 17:21:35
The executionContext parameter is now unused.
| |
| 352 { | 352 { |
| 353 ASSERT(event->type() == EventTypeNames::success); | 353 ASSERT(event->type() == EventTypeNames::success); |
| 354 EventTarget* target = event->target(); | 354 EventTarget* target = event->target(); |
| 355 IDBRequest* request = static_cast<IDBRequest*>(target); | 355 IDBRequest* request = static_cast<IDBRequest*>(target); |
| 356 | 356 |
| 357 if (!m_database->backend()) // If database is stopped? | 357 if (!m_database->backend()) // If database is stopped? |
| 358 return; | 358 return; |
| 359 | 359 |
| 360 RefPtrWillBeRawPtr<IDBAny> cursorAny = request->resultAsAny(); | 360 RefPtrWillBeRawPtr<IDBAny> cursorAny = request->resultAsAny(); |
| 361 RefPtrWillBeRawPtr<IDBCursorWithValue> cursor = nullptr; | 361 RefPtrWillBeRawPtr<IDBCursorWithValue> cursor = nullptr; |
| 362 if (cursorAny->type() == IDBAny::IDBCursorWithValueType) | 362 if (cursorAny->type() == IDBAny::IDBCursorWithValueType) |
| 363 cursor = cursorAny->idbCursorWithValue(); | 363 cursor = cursorAny->idbCursorWithValue(); |
| 364 | 364 |
| 365 Vector<int64_t> indexIds; | 365 Vector<int64_t> indexIds; |
| 366 indexIds.append(m_indexMetadata.id); | 366 indexIds.append(m_indexMetadata.id); |
| 367 if (cursor && !cursor->isDeleted()) { | 367 if (cursor && !cursor->isDeleted()) { |
| 368 cursor->continueFunction(static_cast<IDBKey*>(0), static_cast<IDBKey *>(0), ASSERT_NO_EXCEPTION); | 368 cursor->continueFunction(static_cast<IDBKey*>(0), static_cast<IDBKey *>(0), ASSERT_NO_EXCEPTION); |
| 369 | 369 |
| 370 RefPtrWillBeRawPtr<IDBKey> primaryKey = cursor->idbPrimaryKey(); | 370 RefPtrWillBeRawPtr<IDBKey> primaryKey = cursor->idbPrimaryKey(); |
| 371 ScriptValue value = cursor->value(m_scriptState.get()); | 371 ScriptValue value = cursor->value(m_scriptState.get()); |
| 372 | 372 |
| 373 IDBObjectStore::IndexKeys indexKeys; | 373 IDBObjectStore::IndexKeys indexKeys; |
| 374 generateIndexKeysForValue(toIsolate(context), m_indexMetadata, value , &indexKeys); | 374 generateIndexKeysForValue(m_scriptState->isolate(), m_indexMetadata, value, &indexKeys); |
|
jsbell
2014/05/23 17:21:35
And this is the only real change in the patch - mo
haraken
2014/05/26 07:04:03
I added the ASSERT.
However, this change won't ch
| |
| 375 | 375 |
| 376 WillBeHeapVector<IDBObjectStore::IndexKeys> indexKeysList; | 376 WillBeHeapVector<IDBObjectStore::IndexKeys> indexKeysList; |
| 377 indexKeysList.append(indexKeys); | 377 indexKeysList.append(indexKeys); |
| 378 | 378 |
| 379 m_database->backend()->setIndexKeys(m_transactionId, m_objectStoreId , primaryKey.release(), indexIds, indexKeysList); | 379 m_database->backend()->setIndexKeys(m_transactionId, m_objectStoreId , primaryKey.release(), indexIds, indexKeysList); |
| 380 } else { | 380 } else { |
| 381 // Now that we are done indexing, tell the backend to go | 381 // Now that we are done indexing, tell the backend to go |
| 382 // back to processing tasks of type NormalTask. | 382 // back to processing tasks of type NormalTask. |
| 383 m_database->backend()->setIndexesReady(m_transactionId, m_objectStor eId, indexIds); | 383 m_database->backend()->setIndexesReady(m_transactionId, m_objectStor eId, indexIds); |
| 384 m_database.clear(); | 384 m_database.clear(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 IDBIndexMetadata metadata(name, indexId, keyPath, unique, multiEntry); | 454 IDBIndexMetadata metadata(name, indexId, keyPath, unique, multiEntry); |
| 455 RefPtrWillBeRawPtr<IDBIndex> index = IDBIndex::create(metadata, this, m_tran saction.get()); | 455 RefPtrWillBeRawPtr<IDBIndex> index = IDBIndex::create(metadata, this, m_tran saction.get()); |
| 456 m_indexMap.set(name, index); | 456 m_indexMap.set(name, index); |
| 457 m_metadata.indexes.set(indexId, metadata); | 457 m_metadata.indexes.set(indexId, metadata); |
| 458 m_transaction->db()->indexCreated(id(), metadata); | 458 m_transaction->db()->indexCreated(id(), metadata); |
| 459 | 459 |
| 460 ASSERT(!exceptionState.hadException()); | 460 ASSERT(!exceptionState.hadException()); |
| 461 if (exceptionState.hadException()) | 461 if (exceptionState.hadException()) |
| 462 return nullptr; | 462 return nullptr; |
| 463 | 463 |
| 464 RefPtrWillBeRawPtr<IDBRequest> indexRequest = openCursor(scriptState->execut ionContext(), static_cast<IDBKeyRange*>(0), blink::WebIDBCursor::Next, WebIDBDat abase::PreemptiveTask); | 464 RefPtrWillBeRawPtr<IDBRequest> indexRequest = openCursor(scriptState, static _cast<IDBKeyRange*>(0), blink::WebIDBCursor::Next, WebIDBDatabase::PreemptiveTas k); |
| 465 indexRequest->preventPropagation(); | 465 indexRequest->preventPropagation(); |
| 466 | 466 |
| 467 // This is kept alive by being the success handler of the request, which is in turn kept alive by the owning transaction. | 467 // This is kept alive by being the success handler of the request, which is in turn kept alive by the owning transaction. |
| 468 RefPtr<IndexPopulator> indexPopulator = IndexPopulator::create(scriptState, transaction()->db(), m_transaction->id(), id(), metadata); | 468 RefPtr<IndexPopulator> indexPopulator = IndexPopulator::create(scriptState, transaction()->db(), m_transaction->id(), id(), metadata); |
| 469 indexRequest->setOnsuccess(indexPopulator); | 469 indexRequest->setOnsuccess(indexPopulator); |
| 470 return index.release(); | 470 return index.release(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 PassRefPtrWillBeRawPtr<IDBIndex> IDBObjectStore::index(const String& name, Excep tionState& exceptionState) | 473 PassRefPtrWillBeRawPtr<IDBIndex> IDBObjectStore::index(const String& name, Excep tionState& exceptionState) |
| 474 { | 474 { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 | 540 |
| 541 m_metadata.indexes.remove(indexId); | 541 m_metadata.indexes.remove(indexId); |
| 542 m_transaction->db()->indexDeleted(id(), indexId); | 542 m_transaction->db()->indexDeleted(id(), indexId); |
| 543 IDBIndexMap::iterator it = m_indexMap.find(name); | 543 IDBIndexMap::iterator it = m_indexMap.find(name); |
| 544 if (it != m_indexMap.end()) { | 544 if (it != m_indexMap.end()) { |
| 545 it->value->markDeleted(); | 545 it->value->markDeleted(); |
| 546 m_indexMap.remove(name); | 546 m_indexMap.remove(name); |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 | 549 |
| 550 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::openCursor(ExecutionContext* context, const ScriptValue& range, const String& directionString, ExceptionState & exceptionState) | 550 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::openCursor(ScriptState* scrip tState, const ScriptValue& range, const String& directionString, ExceptionState& exceptionState) |
| 551 { | 551 { |
| 552 IDB_TRACE("IDBObjectStore::openCursor"); | 552 IDB_TRACE("IDBObjectStore::openCursor"); |
| 553 if (isDeleted()) { | 553 if (isDeleted()) { |
| 554 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); | 554 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); |
| 555 return nullptr; | 555 return nullptr; |
| 556 } | 556 } |
| 557 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 557 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 558 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); | 558 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); |
| 559 return nullptr; | 559 return nullptr; |
| 560 } | 560 } |
| 561 if (!m_transaction->isActive()) { | 561 if (!m_transaction->isActive()) { |
| 562 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); | 562 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); |
| 563 return nullptr; | 563 return nullptr; |
| 564 } | 564 } |
| 565 | 565 |
| 566 WebIDBCursor::Direction direction = IDBCursor::stringToDirection(directionSt ring, exceptionState); | 566 WebIDBCursor::Direction direction = IDBCursor::stringToDirection(directionSt ring, exceptionState); |
| 567 if (exceptionState.hadException()) | 567 if (exceptionState.hadException()) |
| 568 return nullptr; | 568 return nullptr; |
| 569 | 569 |
| 570 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(cont ext, range, exceptionState); | 570 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(scri ptState->executionContext(), range, exceptionState); |
| 571 if (exceptionState.hadException()) | 571 if (exceptionState.hadException()) |
| 572 return nullptr; | 572 return nullptr; |
| 573 | 573 |
| 574 if (!backendDB()) { | 574 if (!backendDB()) { |
| 575 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); | 575 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); |
| 576 return nullptr; | 576 return nullptr; |
| 577 } | 577 } |
| 578 | 578 |
| 579 return openCursor(context, keyRange, direction, WebIDBDatabase::NormalTask); | 579 return openCursor(scriptState, keyRange, direction, WebIDBDatabase::NormalTa sk); |
| 580 } | 580 } |
| 581 | 581 |
| 582 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::openCursor(ExecutionContext* context, PassRefPtrWillBeRawPtr<IDBKeyRange> range, WebIDBCursor::Direction dire ction, WebIDBDatabase::TaskType taskType) | 582 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::openCursor(ScriptState* scrip tState, PassRefPtrWillBeRawPtr<IDBKeyRange> range, WebIDBCursor::Direction direc tion, WebIDBDatabase::TaskType taskType) |
| 583 { | 583 { |
| 584 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny: :create(this), m_transaction.get()); | 584 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB Any::create(this), m_transaction.get()); |
| 585 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); | 585 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); |
| 586 | 586 |
| 587 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid Id, range, direction, false, taskType, WebIDBCallbacksImpl::create(request).leak Ptr()); | 587 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid Id, range, direction, false, taskType, WebIDBCallbacksImpl::create(request).leak Ptr()); |
| 588 return request.release(); | 588 return request.release(); |
| 589 } | 589 } |
| 590 | 590 |
| 591 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::openKeyCursor(ExecutionContex t* context, const ScriptValue& range, const String& directionString, ExceptionSt ate& exceptionState) | 591 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::openKeyCursor(ScriptState* sc riptState, const ScriptValue& range, const String& directionString, ExceptionSta te& exceptionState) |
| 592 { | 592 { |
| 593 IDB_TRACE("IDBObjectStore::openKeyCursor"); | 593 IDB_TRACE("IDBObjectStore::openKeyCursor"); |
| 594 if (isDeleted()) { | 594 if (isDeleted()) { |
| 595 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); | 595 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); |
| 596 return nullptr; | 596 return nullptr; |
| 597 } | 597 } |
| 598 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 598 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 599 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); | 599 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); |
| 600 return nullptr; | 600 return nullptr; |
| 601 } | 601 } |
| 602 if (!m_transaction->isActive()) { | 602 if (!m_transaction->isActive()) { |
| 603 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); | 603 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); |
| 604 return nullptr; | 604 return nullptr; |
| 605 } | 605 } |
| 606 | 606 |
| 607 WebIDBCursor::Direction direction = IDBCursor::stringToDirection(directionSt ring, exceptionState); | 607 WebIDBCursor::Direction direction = IDBCursor::stringToDirection(directionSt ring, exceptionState); |
| 608 if (exceptionState.hadException()) | 608 if (exceptionState.hadException()) |
| 609 return nullptr; | 609 return nullptr; |
| 610 | 610 |
| 611 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(cont ext, range, exceptionState); | 611 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(scri ptState->executionContext(), range, exceptionState); |
| 612 if (exceptionState.hadException()) | 612 if (exceptionState.hadException()) |
| 613 return nullptr; | 613 return nullptr; |
| 614 | 614 |
| 615 if (!backendDB()) { | 615 if (!backendDB()) { |
| 616 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); | 616 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); |
| 617 return nullptr; | 617 return nullptr; |
| 618 } | 618 } |
| 619 | 619 |
| 620 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny: :create(this), m_transaction.get()); | 620 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB Any::create(this), m_transaction.get()); |
| 621 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); | 621 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); |
| 622 | 622 |
| 623 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid Id, keyRange.release(), direction, true, WebIDBDatabase::NormalTask, WebIDBCallb acksImpl::create(request).leakPtr()); | 623 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid Id, keyRange.release(), direction, true, WebIDBDatabase::NormalTask, WebIDBCallb acksImpl::create(request).leakPtr()); |
| 624 return request.release(); | 624 return request.release(); |
| 625 } | 625 } |
| 626 | 626 |
| 627 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::count(ExecutionContext* conte xt, const ScriptValue& range, ExceptionState& exceptionState) | 627 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::count(ScriptState* scriptStat e, const ScriptValue& range, ExceptionState& exceptionState) |
| 628 { | 628 { |
| 629 IDB_TRACE("IDBObjectStore::count"); | 629 IDB_TRACE("IDBObjectStore::count"); |
| 630 if (isDeleted()) { | 630 if (isDeleted()) { |
| 631 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); | 631 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); |
| 632 return nullptr; | 632 return nullptr; |
| 633 } | 633 } |
| 634 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 634 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 635 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); | 635 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); |
| 636 return nullptr; | 636 return nullptr; |
| 637 } | 637 } |
| 638 if (!m_transaction->isActive()) { | 638 if (!m_transaction->isActive()) { |
| 639 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); | 639 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); |
| 640 return nullptr; | 640 return nullptr; |
| 641 } | 641 } |
| 642 | 642 |
| 643 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(cont ext, range, exceptionState); | 643 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(scri ptState->executionContext(), range, exceptionState); |
| 644 if (exceptionState.hadException()) | 644 if (exceptionState.hadException()) |
| 645 return nullptr; | 645 return nullptr; |
| 646 | 646 |
| 647 if (!backendDB()) { | 647 if (!backendDB()) { |
| 648 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); | 648 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); |
| 649 return nullptr; | 649 return nullptr; |
| 650 } | 650 } |
| 651 | 651 |
| 652 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny: :create(this), m_transaction.get()); | 652 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB Any::create(this), m_transaction.get()); |
| 653 backendDB()->count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, k eyRange.release(), WebIDBCallbacksImpl::create(request).leakPtr()); | 653 backendDB()->count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, k eyRange.release(), WebIDBCallbacksImpl::create(request).leakPtr()); |
| 654 return request.release(); | 654 return request.release(); |
| 655 } | 655 } |
| 656 | 656 |
| 657 void IDBObjectStore::transactionFinished() | 657 void IDBObjectStore::transactionFinished() |
| 658 { | 658 { |
| 659 ASSERT(m_transaction->isFinished()); | 659 ASSERT(m_transaction->isFinished()); |
| 660 | 660 |
| 661 // Break reference cycles. | 661 // Break reference cycles. |
| 662 m_indexMap.clear(); | 662 m_indexMap.clear(); |
| 663 } | 663 } |
| 664 | 664 |
| 665 int64_t IDBObjectStore::findIndexId(const String& name) const | 665 int64_t IDBObjectStore::findIndexId(const String& name) const |
| 666 { | 666 { |
| 667 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) { | 667 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) { |
| 668 if (it->value.name == name) { | 668 if (it->value.name == name) { |
| 669 ASSERT(it->key != IDBIndexMetadata::InvalidId); | 669 ASSERT(it->key != IDBIndexMetadata::InvalidId); |
| 670 return it->key; | 670 return it->key; |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 return IDBIndexMetadata::InvalidId; | 673 return IDBIndexMetadata::InvalidId; |
| 674 } | 674 } |
| 675 | 675 |
| 676 WebIDBDatabase* IDBObjectStore::backendDB() const | 676 WebIDBDatabase* IDBObjectStore::backendDB() const |
| 677 { | 677 { |
| 678 return m_transaction->backendDB(); | 678 return m_transaction->backendDB(); |
| 679 } | 679 } |
| 680 | 680 |
| 681 } // namespace WebCore | 681 } // namespace WebCore |
| OLD | NEW |