| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 indexNames->append(it->value.name); | 84 indexNames->append(it->value.name); |
| 85 indexNames->sort(); | 85 indexNames->sort(); |
| 86 return indexNames.release(); | 86 return indexNames.release(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 IDBRequest* IDBObjectStore::get(ScriptState* scriptState, const ScriptValue& key
, ExceptionState& exceptionState) | 89 IDBRequest* IDBObjectStore::get(ScriptState* scriptState, const ScriptValue& key
, ExceptionState& exceptionState) |
| 90 { | 90 { |
| 91 IDB_TRACE("IDBObjectStore::get"); | 91 IDB_TRACE("IDBObjectStore::get"); |
| 92 if (isDeleted()) { | 92 if (isDeleted()) { |
| 93 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 93 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 94 return 0; | 94 return nullptr; |
| 95 } | 95 } |
| 96 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 96 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 97 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 97 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 98 return 0; | 98 return nullptr; |
| 99 } | 99 } |
| 100 if (!m_transaction->isActive()) { | 100 if (!m_transaction->isActive()) { |
| 101 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 101 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 102 return 0; | 102 return nullptr; |
| 103 } | 103 } |
| 104 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC
ontext(), key, exceptionState); | 104 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC
ontext(), key, exceptionState); |
| 105 if (exceptionState.hadException()) | 105 if (exceptionState.hadException()) |
| 106 return 0; | 106 return nullptr; |
| 107 if (!keyRange) { | 107 if (!keyRange) { |
| 108 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); | 108 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); |
| 109 return 0; | 109 return nullptr; |
| 110 } | 110 } |
| 111 if (!backendDB()) { | 111 if (!backendDB()) { |
| 112 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 112 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 113 return 0; | 113 return nullptr; |
| 114 } | 114 } |
| 115 | 115 |
| 116 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 116 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 117 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key
Range, false, WebIDBCallbacksImpl::create(request).leakPtr()); | 117 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key
Range, false, WebIDBCallbacksImpl::create(request).leakPtr()); |
| 118 return request; | 118 return request; |
| 119 } | 119 } |
| 120 | 120 |
| 121 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, ExceptionState& exceptionState) | 121 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, ExceptionState& exceptionState) |
| 122 { | 122 { |
| 123 return getAll(scriptState, keyRange, std::numeric_limits<uint32_t>::max(), e
xceptionState); | 123 return getAll(scriptState, keyRange, std::numeric_limits<uint32_t>::max(), e
xceptionState); |
| 124 } | 124 } |
| 125 | 125 |
| 126 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, unsigned long maxCount, ExceptionState& exceptionState) | 126 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, unsigned long maxCount, ExceptionState& exceptionState) |
| 127 { | 127 { |
| 128 IDB_TRACE("IDBObjectStore::getAll"); | 128 IDB_TRACE("IDBObjectStore::getAll"); |
| 129 if (!maxCount) { | 129 if (!maxCount) { |
| 130 exceptionState.throwTypeError(IDBDatabase::notValidMaxCountErrorMessage)
; | 130 exceptionState.throwTypeError(IDBDatabase::notValidMaxCountErrorMessage)
; |
| 131 return 0; | 131 return nullptr; |
| 132 } | 132 } |
| 133 if (isDeleted()) { | 133 if (isDeleted()) { |
| 134 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 134 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 135 return 0; | 135 return nullptr; |
| 136 } | 136 } |
| 137 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 137 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 138 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 138 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 139 return 0; | 139 return nullptr; |
| 140 } | 140 } |
| 141 if (!m_transaction->isActive()) { | 141 if (!m_transaction->isActive()) { |
| 142 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 142 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 143 return 0; | 143 return nullptr; |
| 144 } | 144 } |
| 145 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->executionCont
ext(), keyRange, exceptionState); | 145 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->executionCont
ext(), keyRange, exceptionState); |
| 146 if (exceptionState.hadException()) | 146 if (exceptionState.hadException()) |
| 147 return 0; | 147 return nullptr; |
| 148 if (!backendDB()) { | 148 if (!backendDB()) { |
| 149 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 149 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 150 return 0; | 150 return nullptr; |
| 151 } | 151 } |
| 152 | 152 |
| 153 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 153 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 154 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId,
range, maxCount, false, WebIDBCallbacksImpl::create(request).leakPtr()); | 154 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId,
range, maxCount, false, WebIDBCallbacksImpl::create(request).leakPtr()); |
| 155 return request; | 155 return request; |
| 156 } | 156 } |
| 157 | 157 |
| 158 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada
ta& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* in
dexKeys) | 158 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada
ta& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* in
dexKeys) |
| 159 { | 159 { |
| 160 ASSERT(indexKeys); | 160 ASSERT(indexKeys); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 IDBKey* key = keyValue.isUndefined() ? nullptr : ScriptValue::to<IDBKey*>(sc
riptState->isolate(), keyValue, exceptionState); | 196 IDBKey* key = keyValue.isUndefined() ? nullptr : ScriptValue::to<IDBKey*>(sc
riptState->isolate(), keyValue, exceptionState); |
| 197 if (exceptionState.hadException()) | 197 if (exceptionState.hadException()) |
| 198 return nullptr; | 198 return nullptr; |
| 199 return put(scriptState, putMode, source, value, key, exceptionState); | 199 return put(scriptState, putMode, source, value, key, exceptionState); |
| 200 } | 200 } |
| 201 | 201 |
| 202 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode,
IDBAny* source, const ScriptValue& value, IDBKey* key, ExceptionState& exceptio
nState) | 202 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode,
IDBAny* source, const ScriptValue& value, IDBKey* key, ExceptionState& exceptio
nState) |
| 203 { | 203 { |
| 204 if (isDeleted()) { | 204 if (isDeleted()) { |
| 205 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 205 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 206 return 0; | 206 return nullptr; |
| 207 } | 207 } |
| 208 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 208 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 209 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 209 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 210 return 0; | 210 return nullptr; |
| 211 } | 211 } |
| 212 if (!m_transaction->isActive()) { | 212 if (!m_transaction->isActive()) { |
| 213 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 213 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 214 return 0; | 214 return nullptr; |
| 215 } | 215 } |
| 216 if (m_transaction->isReadOnly()) { | 216 if (m_transaction->isReadOnly()) { |
| 217 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction
ReadOnlyErrorMessage); | 217 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction
ReadOnlyErrorMessage); |
| 218 return 0; | 218 return nullptr; |
| 219 } | 219 } |
| 220 | 220 |
| 221 Vector<WebBlobInfo> blobInfo; | 221 Vector<WebBlobInfo> blobInfo; |
| 222 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValueFactory
::instance().create(scriptState->isolate(), value, &blobInfo, exceptionState); | 222 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValueFactory
::instance().create(scriptState->isolate(), value, &blobInfo, exceptionState); |
| 223 if (exceptionState.hadException()) | 223 if (exceptionState.hadException()) |
| 224 return 0; | 224 return nullptr; |
| 225 | 225 |
| 226 // Keys that need to be extracted must be taken from a clone so that | 226 // Keys that need to be extracted must be taken from a clone so that |
| 227 // side effects (i.e. getters) are not triggered. Construct the | 227 // side effects (i.e. getters) are not triggered. Construct the |
| 228 // clone lazily since the operation may be expensive. | 228 // clone lazily since the operation may be expensive. |
| 229 ScriptValue clone; | 229 ScriptValue clone; |
| 230 | 230 |
| 231 const IDBKeyPath& keyPath = m_metadata.keyPath; | 231 const IDBKeyPath& keyPath = m_metadata.keyPath; |
| 232 const bool usesInLineKeys = !keyPath.isNull(); | 232 const bool usesInLineKeys = !keyPath.isNull(); |
| 233 const bool hasKeyGenerator = autoIncrement(); | 233 const bool hasKeyGenerator = autoIncrement(); |
| 234 | 234 |
| 235 if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) { | 235 if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) { |
| 236 exceptionState.throwDOMException(DataError, "The object store uses in-li
ne keys and the key parameter was provided."); | 236 exceptionState.throwDOMException(DataError, "The object store uses in-li
ne keys and the key parameter was provided."); |
| 237 return 0; | 237 return nullptr; |
| 238 } | 238 } |
| 239 | 239 |
| 240 // This test logically belongs in IDBCursor, but must operate on the cloned
value. | 240 // This test logically belongs in IDBCursor, but must operate on the cloned
value. |
| 241 if (putMode == WebIDBPutModeCursorUpdate && usesInLineKeys) { | 241 if (putMode == WebIDBPutModeCursorUpdate && usesInLineKeys) { |
| 242 ASSERT(key); | 242 ASSERT(key); |
| 243 if (clone.isEmpty()) | 243 if (clone.isEmpty()) |
| 244 clone = deserializeScriptValue(scriptState, serializedValue.get(), &
blobInfo); | 244 clone = deserializeScriptValue(scriptState, serializedValue.get(), &
blobInfo); |
| 245 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), cl
one, exceptionState, keyPath); | 245 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), cl
one, exceptionState, keyPath); |
| 246 if (exceptionState.hadException()) | 246 if (exceptionState.hadException()) |
| 247 return nullptr; | 247 return nullptr; |
| 248 if (!keyPathKey || !keyPathKey->isEqual(key)) { | 248 if (!keyPathKey || !keyPathKey->isEqual(key)) { |
| 249 exceptionState.throwDOMException(DataError, "The effective object st
ore of this cursor uses in-line keys and evaluating the key path of the value pa
rameter results in a different value than the cursor's effective key."); | 249 exceptionState.throwDOMException(DataError, "The effective object st
ore of this cursor uses in-line keys and evaluating the key path of the value pa
rameter results in a different value than the cursor's effective key."); |
| 250 return nullptr; | 250 return nullptr; |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 if (!usesInLineKeys && !hasKeyGenerator && !key) { | 254 if (!usesInLineKeys && !hasKeyGenerator && !key) { |
| 255 exceptionState.throwDOMException(DataError, "The object store uses out-o
f-line keys and has no key generator and the key parameter was not provided."); | 255 exceptionState.throwDOMException(DataError, "The object store uses out-o
f-line keys and has no key generator and the key parameter was not provided."); |
| 256 return 0; | 256 return nullptr; |
| 257 } | 257 } |
| 258 if (usesInLineKeys) { | 258 if (usesInLineKeys) { |
| 259 if (clone.isEmpty()) | 259 if (clone.isEmpty()) |
| 260 clone = deserializeScriptValue(scriptState, serializedValue.get(), &
blobInfo); | 260 clone = deserializeScriptValue(scriptState, serializedValue.get(), &
blobInfo); |
| 261 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), cl
one, exceptionState, keyPath); | 261 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), cl
one, exceptionState, keyPath); |
| 262 if (exceptionState.hadException()) | 262 if (exceptionState.hadException()) |
| 263 return nullptr; | 263 return nullptr; |
| 264 if (keyPathKey && !keyPathKey->isValid()) { | 264 if (keyPathKey && !keyPathKey->isValid()) { |
| 265 exceptionState.throwDOMException(DataError, "Evaluating the object s
tore's key path yielded a value that is not a valid key."); | 265 exceptionState.throwDOMException(DataError, "Evaluating the object s
tore's key path yielded a value that is not a valid key."); |
| 266 return 0; | 266 return nullptr; |
| 267 } | 267 } |
| 268 if (!hasKeyGenerator && !keyPathKey) { | 268 if (!hasKeyGenerator && !keyPathKey) { |
| 269 exceptionState.throwDOMException(DataError, "Evaluating the object s
tore's key path did not yield a value."); | 269 exceptionState.throwDOMException(DataError, "Evaluating the object s
tore's key path did not yield a value."); |
| 270 return 0; | 270 return nullptr; |
| 271 } | 271 } |
| 272 if (hasKeyGenerator && !keyPathKey) { | 272 if (hasKeyGenerator && !keyPathKey) { |
| 273 if (!canInjectIDBKeyIntoScriptValue(scriptState->isolate(), clone, k
eyPath)) { | 273 if (!canInjectIDBKeyIntoScriptValue(scriptState->isolate(), clone, k
eyPath)) { |
| 274 exceptionState.throwDOMException(DataError, "A generated key cou
ld not be inserted into the value."); | 274 exceptionState.throwDOMException(DataError, "A generated key cou
ld not be inserted into the value."); |
| 275 return 0; | 275 return nullptr; |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 if (keyPathKey) | 278 if (keyPathKey) |
| 279 key = keyPathKey; | 279 key = keyPathKey; |
| 280 } | 280 } |
| 281 if (key && !key->isValid()) { | 281 if (key && !key->isValid()) { |
| 282 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 282 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 283 return 0; | 283 return nullptr; |
| 284 } | 284 } |
| 285 | 285 |
| 286 if (!backendDB()) { | 286 if (!backendDB()) { |
| 287 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 287 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 288 return 0; | 288 return nullptr; |
| 289 } | 289 } |
| 290 | 290 |
| 291 Vector<int64_t> indexIds; | 291 Vector<int64_t> indexIds; |
| 292 HeapVector<IndexKeys> indexKeys; | 292 HeapVector<IndexKeys> indexKeys; |
| 293 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe
s.begin(); it != m_metadata.indexes.end(); ++it) { | 293 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe
s.begin(); it != m_metadata.indexes.end(); ++it) { |
| 294 if (clone.isEmpty()) | 294 if (clone.isEmpty()) |
| 295 clone = deserializeScriptValue(scriptState, serializedValue.get(), &
blobInfo); | 295 clone = deserializeScriptValue(scriptState, serializedValue.get(), &
blobInfo); |
| 296 IndexKeys keys; | 296 IndexKeys keys; |
| 297 generateIndexKeysForValue(scriptState->isolate(), it->value, clone, &key
s); | 297 generateIndexKeysForValue(scriptState->isolate(), it->value, clone, &key
s); |
| 298 indexIds.append(it->key); | 298 indexIds.append(it->key); |
| 299 indexKeys.append(keys); | 299 indexKeys.append(keys); |
| 300 } | 300 } |
| 301 | 301 |
| 302 IDBRequest* request = IDBRequest::create(scriptState, source, m_transaction.
get()); | 302 IDBRequest* request = IDBRequest::create(scriptState, source, m_transaction.
get()); |
| 303 Vector<char> wireBytes; | 303 Vector<char> wireBytes; |
| 304 serializedValue->toWireBytes(wireBytes); | 304 serializedValue->toWireBytes(wireBytes); |
| 305 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); | 305 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); |
| 306 | 306 |
| 307 backendDB()->put(m_transaction->id(), id(), WebData(valueBuffer), blobInfo,
key, static_cast<WebIDBPutMode>(putMode), WebIDBCallbacksImpl::create(request).l
eakPtr(), indexIds, indexKeys); | 307 backendDB()->put(m_transaction->id(), id(), WebData(valueBuffer), blobInfo,
key, static_cast<WebIDBPutMode>(putMode), WebIDBCallbacksImpl::create(request).l
eakPtr(), indexIds, indexKeys); |
| 308 return request; | 308 return request; |
| 309 } | 309 } |
| 310 | 310 |
| 311 IDBRequest* IDBObjectStore::deleteFunction(ScriptState* scriptState, const Scrip
tValue& key, ExceptionState& exceptionState) | 311 IDBRequest* IDBObjectStore::deleteFunction(ScriptState* scriptState, const Scrip
tValue& key, ExceptionState& exceptionState) |
| 312 { | 312 { |
| 313 IDB_TRACE("IDBObjectStore::delete"); | 313 IDB_TRACE("IDBObjectStore::delete"); |
| 314 if (isDeleted()) { | 314 if (isDeleted()) { |
| 315 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 315 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 316 return 0; | 316 return nullptr; |
| 317 } | 317 } |
| 318 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 318 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 319 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 319 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 320 return 0; | 320 return nullptr; |
| 321 } | 321 } |
| 322 if (!m_transaction->isActive()) { | 322 if (!m_transaction->isActive()) { |
| 323 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 323 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 324 return 0; | 324 return nullptr; |
| 325 } | 325 } |
| 326 if (m_transaction->isReadOnly()) { | 326 if (m_transaction->isReadOnly()) { |
| 327 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction
ReadOnlyErrorMessage); | 327 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction
ReadOnlyErrorMessage); |
| 328 return 0; | 328 return nullptr; |
| 329 } | 329 } |
| 330 | 330 |
| 331 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC
ontext(), key, exceptionState); | 331 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC
ontext(), key, exceptionState); |
| 332 if (exceptionState.hadException()) | 332 if (exceptionState.hadException()) |
| 333 return 0; | 333 return nullptr; |
| 334 if (!keyRange) { | 334 if (!keyRange) { |
| 335 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); | 335 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); |
| 336 return 0; | 336 return nullptr; |
| 337 } | 337 } |
| 338 if (!backendDB()) { | 338 if (!backendDB()) { |
| 339 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 339 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 340 return 0; | 340 return nullptr; |
| 341 } | 341 } |
| 342 | 342 |
| 343 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 343 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 344 backendDB()->deleteRange(m_transaction->id(), id(), keyRange, WebIDBCallback
sImpl::create(request).leakPtr()); | 344 backendDB()->deleteRange(m_transaction->id(), id(), keyRange, WebIDBCallback
sImpl::create(request).leakPtr()); |
| 345 return request; | 345 return request; |
| 346 } | 346 } |
| 347 | 347 |
| 348 IDBRequest* IDBObjectStore::clear(ScriptState* scriptState, ExceptionState& exce
ptionState) | 348 IDBRequest* IDBObjectStore::clear(ScriptState* scriptState, ExceptionState& exce
ptionState) |
| 349 { | 349 { |
| 350 IDB_TRACE("IDBObjectStore::clear"); | 350 IDB_TRACE("IDBObjectStore::clear"); |
| 351 if (isDeleted()) { | 351 if (isDeleted()) { |
| 352 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 352 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 353 return 0; | 353 return nullptr; |
| 354 } | 354 } |
| 355 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 355 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 356 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 356 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 357 return 0; | 357 return nullptr; |
| 358 } | 358 } |
| 359 if (!m_transaction->isActive()) { | 359 if (!m_transaction->isActive()) { |
| 360 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 360 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 361 return 0; | 361 return nullptr; |
| 362 } | 362 } |
| 363 if (m_transaction->isReadOnly()) { | 363 if (m_transaction->isReadOnly()) { |
| 364 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction
ReadOnlyErrorMessage); | 364 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction
ReadOnlyErrorMessage); |
| 365 return 0; | 365 return nullptr; |
| 366 } | 366 } |
| 367 if (!backendDB()) { | 367 if (!backendDB()) { |
| 368 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 368 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 369 return 0; | 369 return nullptr; |
| 370 } | 370 } |
| 371 | 371 |
| 372 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 372 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 373 backendDB()->clear(m_transaction->id(), id(), WebIDBCallbacksImpl::create(re
quest).leakPtr()); | 373 backendDB()->clear(m_transaction->id(), id(), WebIDBCallbacksImpl::create(re
quest).leakPtr()); |
| 374 return request; | 374 return request; |
| 375 } | 375 } |
| 376 | 376 |
| 377 namespace { | 377 namespace { |
| 378 // This class creates the index keys for a given index by extracting | 378 // This class creates the index keys for a given index by extracting |
| 379 // them from the SerializedScriptValue, for all the existing values in | 379 // them from the SerializedScriptValue, for all the existing values in |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 const int64_t m_objectStoreId; | 448 const int64_t m_objectStoreId; |
| 449 const IDBIndexMetadata m_indexMetadata; | 449 const IDBIndexMetadata m_indexMetadata; |
| 450 }; | 450 }; |
| 451 } | 451 } |
| 452 | 452 |
| 453 IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
me, const IDBKeyPath& keyPath, const IDBIndexParameters& options, ExceptionState
& exceptionState) | 453 IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
me, const IDBKeyPath& keyPath, const IDBIndexParameters& options, ExceptionState
& exceptionState) |
| 454 { | 454 { |
| 455 IDB_TRACE("IDBObjectStore::createIndex"); | 455 IDB_TRACE("IDBObjectStore::createIndex"); |
| 456 if (!m_transaction->isVersionChange()) { | 456 if (!m_transaction->isVersionChange()) { |
| 457 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); | 457 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); |
| 458 return 0; | 458 return nullptr; |
| 459 } | 459 } |
| 460 if (isDeleted()) { | 460 if (isDeleted()) { |
| 461 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 461 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 462 return 0; | 462 return nullptr; |
| 463 } | 463 } |
| 464 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 464 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 465 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 465 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 466 return 0; | 466 return nullptr; |
| 467 } | 467 } |
| 468 if (!m_transaction->isActive()) { | 468 if (!m_transaction->isActive()) { |
| 469 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 469 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 470 return 0; | 470 return nullptr; |
| 471 } | 471 } |
| 472 if (!keyPath.isValid()) { | 472 if (!keyPath.isValid()) { |
| 473 exceptionState.throwDOMException(SyntaxError, "The keyPath argument cont
ains an invalid key path."); | 473 exceptionState.throwDOMException(SyntaxError, "The keyPath argument cont
ains an invalid key path."); |
| 474 return 0; | 474 return nullptr; |
| 475 } | 475 } |
| 476 if (containsIndex(name)) { | 476 if (containsIndex(name)) { |
| 477 exceptionState.throwDOMException(ConstraintError, "An index with the spe
cified name already exists."); | 477 exceptionState.throwDOMException(ConstraintError, "An index with the spe
cified name already exists."); |
| 478 return 0; | 478 return nullptr; |
| 479 } | 479 } |
| 480 | 480 |
| 481 if (keyPath.type() == IDBKeyPath::ArrayType && options.multiEntry()) { | 481 if (keyPath.type() == IDBKeyPath::ArrayType && options.multiEntry()) { |
| 482 exceptionState.throwDOMException(InvalidAccessError, "The keyPath argume
nt was an array and the multiEntry option is true."); | 482 exceptionState.throwDOMException(InvalidAccessError, "The keyPath argume
nt was an array and the multiEntry option is true."); |
| 483 return 0; | 483 return nullptr; |
| 484 } | 484 } |
| 485 if (!backendDB()) { | 485 if (!backendDB()) { |
| 486 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 486 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 487 return 0; | 487 return nullptr; |
| 488 } | 488 } |
| 489 | 489 |
| 490 int64_t indexId = m_metadata.maxIndexId + 1; | 490 int64_t indexId = m_metadata.maxIndexId + 1; |
| 491 backendDB()->createIndex(m_transaction->id(), id(), indexId, name, keyPath,
options.unique(), options.multiEntry()); | 491 backendDB()->createIndex(m_transaction->id(), id(), indexId, name, keyPath,
options.unique(), options.multiEntry()); |
| 492 | 492 |
| 493 ++m_metadata.maxIndexId; | 493 ++m_metadata.maxIndexId; |
| 494 | 494 |
| 495 IDBIndexMetadata metadata(name, indexId, keyPath, options.unique(), options.
multiEntry()); | 495 IDBIndexMetadata metadata(name, indexId, keyPath, options.unique(), options.
multiEntry()); |
| 496 IDBIndex* index = IDBIndex::create(metadata, this, m_transaction.get()); | 496 IDBIndex* index = IDBIndex::create(metadata, this, m_transaction.get()); |
| 497 m_indexMap.set(name, index); | 497 m_indexMap.set(name, index); |
| 498 m_metadata.indexes.set(indexId, metadata); | 498 m_metadata.indexes.set(indexId, metadata); |
| 499 m_transaction->db()->indexCreated(id(), metadata); | 499 m_transaction->db()->indexCreated(id(), metadata); |
| 500 | 500 |
| 501 ASSERT(!exceptionState.hadException()); | 501 ASSERT(!exceptionState.hadException()); |
| 502 if (exceptionState.hadException()) | 502 if (exceptionState.hadException()) |
| 503 return 0; | 503 return nullptr; |
| 504 | 504 |
| 505 IDBRequest* indexRequest = openCursor(scriptState, nullptr, WebIDBCursorDire
ctionNext, WebIDBTaskTypePreemptive); | 505 IDBRequest* indexRequest = openCursor(scriptState, nullptr, WebIDBCursorDire
ctionNext, WebIDBTaskTypePreemptive); |
| 506 indexRequest->preventPropagation(); | 506 indexRequest->preventPropagation(); |
| 507 | 507 |
| 508 // This is kept alive by being the success handler of the request, which is
in turn kept alive by the owning transaction. | 508 // This is kept alive by being the success handler of the request, which is
in turn kept alive by the owning transaction. |
| 509 RefPtr<IndexPopulator> indexPopulator = IndexPopulator::create(scriptState,
transaction()->db(), m_transaction->id(), id(), metadata); | 509 RefPtr<IndexPopulator> indexPopulator = IndexPopulator::create(scriptState,
transaction()->db(), m_transaction->id(), id(), metadata); |
| 510 indexRequest->setOnsuccess(indexPopulator); | 510 indexRequest->setOnsuccess(indexPopulator); |
| 511 return index; | 511 return index; |
| 512 } | 512 } |
| 513 | 513 |
| 514 IDBIndex* IDBObjectStore::index(const String& name, ExceptionState& exceptionSta
te) | 514 IDBIndex* IDBObjectStore::index(const String& name, ExceptionState& exceptionSta
te) |
| 515 { | 515 { |
| 516 IDB_TRACE("IDBObjectStore::index"); | 516 IDB_TRACE("IDBObjectStore::index"); |
| 517 if (isDeleted()) { | 517 if (isDeleted()) { |
| 518 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 518 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 519 return 0; | 519 return nullptr; |
| 520 } | 520 } |
| 521 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 521 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 522 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::transac
tionFinishedErrorMessage); | 522 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::transac
tionFinishedErrorMessage); |
| 523 return 0; | 523 return nullptr; |
| 524 } | 524 } |
| 525 | 525 |
| 526 IDBIndexMap::iterator it = m_indexMap.find(name); | 526 IDBIndexMap::iterator it = m_indexMap.find(name); |
| 527 if (it != m_indexMap.end()) | 527 if (it != m_indexMap.end()) |
| 528 return it->value; | 528 return it->value; |
| 529 | 529 |
| 530 int64_t indexId = findIndexId(name); | 530 int64_t indexId = findIndexId(name); |
| 531 if (indexId == IDBIndexMetadata::InvalidId) { | 531 if (indexId == IDBIndexMetadata::InvalidId) { |
| 532 exceptionState.throwDOMException(NotFoundError, IDBDatabase::noSuchIndex
ErrorMessage); | 532 exceptionState.throwDOMException(NotFoundError, IDBDatabase::noSuchIndex
ErrorMessage); |
| 533 return 0; | 533 return nullptr; |
| 534 } | 534 } |
| 535 | 535 |
| 536 const IDBIndexMetadata* indexMetadata(nullptr); | 536 const IDBIndexMetadata* indexMetadata(nullptr); |
| 537 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe
s.begin(); it != m_metadata.indexes.end(); ++it) { | 537 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe
s.begin(); it != m_metadata.indexes.end(); ++it) { |
| 538 if (it->value.name == name) { | 538 if (it->value.name == name) { |
| 539 indexMetadata = &it->value; | 539 indexMetadata = &it->value; |
| 540 break; | 540 break; |
| 541 } | 541 } |
| 542 } | 542 } |
| 543 ASSERT(indexMetadata); | 543 ASSERT(indexMetadata); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 it->value->markDeleted(); | 586 it->value->markDeleted(); |
| 587 m_indexMap.remove(name); | 587 m_indexMap.remove(name); |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 | 590 |
| 591 IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, const ScriptVal
ue& range, const String& directionString, ExceptionState& exceptionState) | 591 IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, const ScriptVal
ue& range, const String& directionString, ExceptionState& exceptionState) |
| 592 { | 592 { |
| 593 IDB_TRACE("IDBObjectStore::openCursor"); | 593 IDB_TRACE("IDBObjectStore::openCursor"); |
| 594 if (isDeleted()) { | 594 if (isDeleted()) { |
| 595 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 595 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 596 return 0; | 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 0; | 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 0; | 604 return nullptr; |
| 605 } | 605 } |
| 606 | 606 |
| 607 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri
ng, exceptionState); | 607 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri
ng, exceptionState); |
| 608 if (exceptionState.hadException()) | 608 if (exceptionState.hadException()) |
| 609 return 0; | 609 return nullptr; |
| 610 | 610 |
| 611 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC
ontext(), range, exceptionState); | 611 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC
ontext(), range, exceptionState); |
| 612 if (exceptionState.hadException()) | 612 if (exceptionState.hadException()) |
| 613 return 0; | 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 0; | 617 return nullptr; |
| 618 } | 618 } |
| 619 | 619 |
| 620 return openCursor(scriptState, keyRange, direction, WebIDBTaskTypeNormal); | 620 return openCursor(scriptState, keyRange, direction, WebIDBTaskTypeNormal); |
| 621 } | 621 } |
| 622 | 622 |
| 623 IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, IDBKeyRange* ra
nge, WebIDBCursorDirection direction, WebIDBTaskType taskType) | 623 IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, IDBKeyRange* ra
nge, WebIDBCursorDirection direction, WebIDBTaskType taskType) |
| 624 { | 624 { |
| 625 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 625 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 626 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); | 626 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); |
| 627 | 627 |
| 628 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, range, direction, false, taskType, WebIDBCallbacksImpl::create(request).leak
Ptr()); | 628 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, range, direction, false, taskType, WebIDBCallbacksImpl::create(request).leak
Ptr()); |
| 629 return request; | 629 return request; |
| 630 } | 630 } |
| 631 | 631 |
| 632 IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* scriptState, const Script
Value& range, const String& directionString, ExceptionState& exceptionState) | 632 IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* scriptState, const Script
Value& range, const String& directionString, ExceptionState& exceptionState) |
| 633 { | 633 { |
| 634 IDB_TRACE("IDBObjectStore::openKeyCursor"); | 634 IDB_TRACE("IDBObjectStore::openKeyCursor"); |
| 635 if (isDeleted()) { | 635 if (isDeleted()) { |
| 636 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 636 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 637 return 0; | 637 return nullptr; |
| 638 } | 638 } |
| 639 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 639 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 640 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 640 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 641 return 0; | 641 return nullptr; |
| 642 } | 642 } |
| 643 if (!m_transaction->isActive()) { | 643 if (!m_transaction->isActive()) { |
| 644 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 644 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 645 return 0; | 645 return nullptr; |
| 646 } | 646 } |
| 647 | 647 |
| 648 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri
ng, exceptionState); | 648 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri
ng, exceptionState); |
| 649 if (exceptionState.hadException()) | 649 if (exceptionState.hadException()) |
| 650 return 0; | 650 return nullptr; |
| 651 | 651 |
| 652 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC
ontext(), range, exceptionState); | 652 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC
ontext(), range, exceptionState); |
| 653 if (exceptionState.hadException()) | 653 if (exceptionState.hadException()) |
| 654 return 0; | 654 return nullptr; |
| 655 | 655 |
| 656 if (!backendDB()) { | 656 if (!backendDB()) { |
| 657 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 657 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 658 return 0; | 658 return nullptr; |
| 659 } | 659 } |
| 660 | 660 |
| 661 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 661 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 662 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); | 662 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); |
| 663 | 663 |
| 664 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, keyRange, direction, true, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create
(request).leakPtr()); | 664 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, keyRange, direction, true, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create
(request).leakPtr()); |
| 665 return request; | 665 return request; |
| 666 } | 666 } |
| 667 | 667 |
| 668 IDBRequest* IDBObjectStore::count(ScriptState* scriptState, const ScriptValue& r
ange, ExceptionState& exceptionState) | 668 IDBRequest* IDBObjectStore::count(ScriptState* scriptState, const ScriptValue& r
ange, ExceptionState& exceptionState) |
| 669 { | 669 { |
| 670 IDB_TRACE("IDBObjectStore::count"); | 670 IDB_TRACE("IDBObjectStore::count"); |
| 671 if (isDeleted()) { | 671 if (isDeleted()) { |
| 672 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 672 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 673 return 0; | 673 return nullptr; |
| 674 } | 674 } |
| 675 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 675 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 676 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 676 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 677 return 0; | 677 return nullptr; |
| 678 } | 678 } |
| 679 if (!m_transaction->isActive()) { | 679 if (!m_transaction->isActive()) { |
| 680 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 680 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 681 return 0; | 681 return nullptr; |
| 682 } | 682 } |
| 683 | 683 |
| 684 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC
ontext(), range, exceptionState); | 684 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC
ontext(), range, exceptionState); |
| 685 if (exceptionState.hadException()) | 685 if (exceptionState.hadException()) |
| 686 return 0; | 686 return nullptr; |
| 687 | 687 |
| 688 if (!backendDB()) { | 688 if (!backendDB()) { |
| 689 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 689 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 690 return 0; | 690 return nullptr; |
| 691 } | 691 } |
| 692 | 692 |
| 693 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 693 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 694 backendDB()->count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, k
eyRange, WebIDBCallbacksImpl::create(request).leakPtr()); | 694 backendDB()->count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, k
eyRange, WebIDBCallbacksImpl::create(request).leakPtr()); |
| 695 return request; | 695 return request; |
| 696 } | 696 } |
| 697 | 697 |
| 698 void IDBObjectStore::transactionFinished() | 698 void IDBObjectStore::transactionFinished() |
| 699 { | 699 { |
| 700 ASSERT(m_transaction->isFinished()); | 700 ASSERT(m_transaction->isFinished()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 713 } | 713 } |
| 714 return IDBIndexMetadata::InvalidId; | 714 return IDBIndexMetadata::InvalidId; |
| 715 } | 715 } |
| 716 | 716 |
| 717 WebIDBDatabase* IDBObjectStore::backendDB() const | 717 WebIDBDatabase* IDBObjectStore::backendDB() const |
| 718 { | 718 { |
| 719 return m_transaction->backendDB(); | 719 return m_transaction->backendDB(); |
| 720 } | 720 } |
| 721 | 721 |
| 722 } // namespace blink | 722 } // namespace blink |
| OLD | NEW |