| 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 21 matching lines...) Expand all Loading... |
| 32 #include "bindings/modules/v8/ToV8ForModules.h" | 32 #include "bindings/modules/v8/ToV8ForModules.h" |
| 33 #include "bindings/modules/v8/V8BindingForModules.h" | 33 #include "bindings/modules/v8/V8BindingForModules.h" |
| 34 #include "core/dom/DOMStringList.h" | 34 #include "core/dom/DOMStringList.h" |
| 35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
| 36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
| 37 #include "modules/indexeddb/IDBAny.h" | 37 #include "modules/indexeddb/IDBAny.h" |
| 38 #include "modules/indexeddb/IDBCursorWithValue.h" | 38 #include "modules/indexeddb/IDBCursorWithValue.h" |
| 39 #include "modules/indexeddb/IDBDatabase.h" | 39 #include "modules/indexeddb/IDBDatabase.h" |
| 40 #include "modules/indexeddb/IDBKeyPath.h" | 40 #include "modules/indexeddb/IDBKeyPath.h" |
| 41 #include "modules/indexeddb/IDBTracing.h" | 41 #include "modules/indexeddb/IDBTracing.h" |
| 42 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | |
| 43 #include "platform/SharedBuffer.h" | 42 #include "platform/SharedBuffer.h" |
| 44 #include "public/platform/WebBlobInfo.h" | 43 #include "public/platform/WebBlobInfo.h" |
| 45 #include "public/platform/WebData.h" | 44 #include "public/platform/WebData.h" |
| 46 #include "public/platform/WebVector.h" | 45 #include "public/platform/WebVector.h" |
| 47 #include "public/platform/modules/indexeddb/WebIDBKey.h" | 46 #include "public/platform/modules/indexeddb/WebIDBKey.h" |
| 48 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" | 47 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" |
| 49 #include <memory> | 48 #include <memory> |
| 50 #include <v8.h> | 49 #include <v8.h> |
| 51 | 50 |
| 52 using blink::WebBlobInfo; | 51 using blink::WebBlobInfo; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (!keyRange) { | 155 if (!keyRange) { |
| 157 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); | 156 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); |
| 158 return nullptr; | 157 return nullptr; |
| 159 } | 158 } |
| 160 if (!backendDB()) { | 159 if (!backendDB()) { |
| 161 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 160 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 162 return nullptr; | 161 return nullptr; |
| 163 } | 162 } |
| 164 | 163 |
| 165 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 164 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 166 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key
Range, false /* keyOnly */, WebIDBCallbacksImpl::create(request).release()); | 165 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key
Range, false /* keyOnly */, request->createWebCallbacks().release()); |
| 167 return request; | 166 return request; |
| 168 } | 167 } |
| 169 | 168 |
| 170 IDBRequest* IDBObjectStore::getKey(ScriptState* scriptState, const ScriptValue&
key, ExceptionState& exceptionState) | 169 IDBRequest* IDBObjectStore::getKey(ScriptState* scriptState, const ScriptValue&
key, ExceptionState& exceptionState) |
| 171 { | 170 { |
| 172 IDB_TRACE("IDBObjectStore::getKey"); | 171 IDB_TRACE("IDBObjectStore::getKey"); |
| 173 if (isDeleted()) { | 172 if (isDeleted()) { |
| 174 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 173 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 175 return nullptr; | 174 return nullptr; |
| 176 } | 175 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 188 if (!keyRange) { | 187 if (!keyRange) { |
| 189 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); | 188 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); |
| 190 return nullptr; | 189 return nullptr; |
| 191 } | 190 } |
| 192 if (!backendDB()) { | 191 if (!backendDB()) { |
| 193 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 192 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 194 return nullptr; | 193 return nullptr; |
| 195 } | 194 } |
| 196 | 195 |
| 197 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 196 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 198 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key
Range, true /* keyOnly */, WebIDBCallbacksImpl::create(request).release()); | 197 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key
Range, true /* keyOnly */, request->createWebCallbacks().release()); |
| 199 return request; | 198 return request; |
| 200 } | 199 } |
| 201 | 200 |
| 202 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, ExceptionState& exceptionState) | 201 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, ExceptionState& exceptionState) |
| 203 { | 202 { |
| 204 return getAll(scriptState, keyRange, std::numeric_limits<uint32_t>::max(), e
xceptionState); | 203 return getAll(scriptState, keyRange, std::numeric_limits<uint32_t>::max(), e
xceptionState); |
| 205 } | 204 } |
| 206 | 205 |
| 207 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, unsigned long maxCount, ExceptionState& exceptionState) | 206 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, unsigned long maxCount, ExceptionState& exceptionState) |
| 208 { | 207 { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 224 } | 223 } |
| 225 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->getExecutionC
ontext(), keyRange, exceptionState); | 224 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->getExecutionC
ontext(), keyRange, exceptionState); |
| 226 if (exceptionState.hadException()) | 225 if (exceptionState.hadException()) |
| 227 return nullptr; | 226 return nullptr; |
| 228 if (!backendDB()) { | 227 if (!backendDB()) { |
| 229 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 228 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 230 return nullptr; | 229 return nullptr; |
| 231 } | 230 } |
| 232 | 231 |
| 233 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 232 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 234 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId,
range, maxCount, false, WebIDBCallbacksImpl::create(request).release()); | 233 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId,
range, maxCount, false, request->createWebCallbacks().release()); |
| 235 return request; | 234 return request; |
| 236 } | 235 } |
| 237 | 236 |
| 238 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal
ue& keyRange, ExceptionState& exceptionState) | 237 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal
ue& keyRange, ExceptionState& exceptionState) |
| 239 { | 238 { |
| 240 return getAllKeys(scriptState, keyRange, std::numeric_limits<uint32_t>::max(
), exceptionState); | 239 return getAllKeys(scriptState, keyRange, std::numeric_limits<uint32_t>::max(
), exceptionState); |
| 241 } | 240 } |
| 242 | 241 |
| 243 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal
ue& keyRange, unsigned long maxCount, ExceptionState& exceptionState) | 242 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal
ue& keyRange, unsigned long maxCount, ExceptionState& exceptionState) |
| 244 { | 243 { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 260 } | 259 } |
| 261 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->getExecutionC
ontext(), keyRange, exceptionState); | 260 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->getExecutionC
ontext(), keyRange, exceptionState); |
| 262 if (exceptionState.hadException()) | 261 if (exceptionState.hadException()) |
| 263 return nullptr; | 262 return nullptr; |
| 264 if (!backendDB()) { | 263 if (!backendDB()) { |
| 265 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 264 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 266 return nullptr; | 265 return nullptr; |
| 267 } | 266 } |
| 268 | 267 |
| 269 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 268 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 270 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId,
range, maxCount, true, WebIDBCallbacksImpl::create(request).release()); | 269 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId,
range, maxCount, true, request->createWebCallbacks().release()); |
| 271 return request; | 270 return request; |
| 272 } | 271 } |
| 273 | 272 |
| 274 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada
ta& indexMetadata, const ScriptValue& objectValue, IndexKeys* indexKeys) | 273 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada
ta& indexMetadata, const ScriptValue& objectValue, IndexKeys* indexKeys) |
| 275 { | 274 { |
| 276 DCHECK(indexKeys); | 275 DCHECK(indexKeys); |
| 277 NonThrowableExceptionState exceptionState; | 276 NonThrowableExceptionState exceptionState; |
| 278 IDBKey* indexKey = ScriptValue::to<IDBKey*>(isolate, objectValue, exceptionS
tate, indexMetadata.keyPath); | 277 IDBKey* indexKey = ScriptValue::to<IDBKey*>(isolate, objectValue, exceptionS
tate, indexMetadata.keyPath); |
| 279 | 278 |
| 280 if (!indexKey) | 279 if (!indexKey) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 generateIndexKeysForValue(scriptState->isolate(), it.value, clone, &keys
); | 414 generateIndexKeysForValue(scriptState->isolate(), it.value, clone, &keys
); |
| 416 indexIds.append(it.key); | 415 indexIds.append(it.key); |
| 417 indexKeys.append(keys); | 416 indexKeys.append(keys); |
| 418 } | 417 } |
| 419 | 418 |
| 420 IDBRequest* request = IDBRequest::create(scriptState, source, m_transaction.
get()); | 419 IDBRequest* request = IDBRequest::create(scriptState, source, m_transaction.
get()); |
| 421 Vector<char> wireBytes; | 420 Vector<char> wireBytes; |
| 422 serializedValue->toWireBytes(wireBytes); | 421 serializedValue->toWireBytes(wireBytes); |
| 423 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); | 422 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); |
| 424 | 423 |
| 425 backendDB()->put(m_transaction->id(), id(), WebData(valueBuffer), blobInfo,
key, static_cast<WebIDBPutMode>(putMode), WebIDBCallbacksImpl::create(request).r
elease(), indexIds, indexKeys); | 424 backendDB()->put(m_transaction->id(), id(), WebData(valueBuffer), blobInfo,
key, static_cast<WebIDBPutMode>(putMode), request->createWebCallbacks().release(
), indexIds, indexKeys); |
| 426 return request; | 425 return request; |
| 427 } | 426 } |
| 428 | 427 |
| 429 IDBRequest* IDBObjectStore::deleteFunction(ScriptState* scriptState, const Scrip
tValue& key, ExceptionState& exceptionState) | 428 IDBRequest* IDBObjectStore::deleteFunction(ScriptState* scriptState, const Scrip
tValue& key, ExceptionState& exceptionState) |
| 430 { | 429 { |
| 431 IDB_TRACE("IDBObjectStore::delete"); | 430 IDB_TRACE("IDBObjectStore::delete"); |
| 432 if (isDeleted()) { | 431 if (isDeleted()) { |
| 433 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 432 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 434 return nullptr; | 433 return nullptr; |
| 435 } | 434 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 452 if (!keyRange) { | 451 if (!keyRange) { |
| 453 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); | 452 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); |
| 454 return nullptr; | 453 return nullptr; |
| 455 } | 454 } |
| 456 if (!backendDB()) { | 455 if (!backendDB()) { |
| 457 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 456 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 458 return nullptr; | 457 return nullptr; |
| 459 } | 458 } |
| 460 | 459 |
| 461 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 460 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 462 backendDB()->deleteRange(m_transaction->id(), id(), keyRange, WebIDBCallback
sImpl::create(request).release()); | 461 backendDB()->deleteRange(m_transaction->id(), id(), keyRange, request->creat
eWebCallbacks().release()); |
| 463 return request; | 462 return request; |
| 464 } | 463 } |
| 465 | 464 |
| 466 IDBRequest* IDBObjectStore::clear(ScriptState* scriptState, ExceptionState& exce
ptionState) | 465 IDBRequest* IDBObjectStore::clear(ScriptState* scriptState, ExceptionState& exce
ptionState) |
| 467 { | 466 { |
| 468 IDB_TRACE("IDBObjectStore::clear"); | 467 IDB_TRACE("IDBObjectStore::clear"); |
| 469 if (isDeleted()) { | 468 if (isDeleted()) { |
| 470 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 469 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 471 return nullptr; | 470 return nullptr; |
| 472 } | 471 } |
| 473 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 472 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 474 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 473 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 475 return nullptr; | 474 return nullptr; |
| 476 } | 475 } |
| 477 if (!m_transaction->isActive()) { | 476 if (!m_transaction->isActive()) { |
| 478 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 477 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 479 return nullptr; | 478 return nullptr; |
| 480 } | 479 } |
| 481 if (m_transaction->isReadOnly()) { | 480 if (m_transaction->isReadOnly()) { |
| 482 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction
ReadOnlyErrorMessage); | 481 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction
ReadOnlyErrorMessage); |
| 483 return nullptr; | 482 return nullptr; |
| 484 } | 483 } |
| 485 if (!backendDB()) { | 484 if (!backendDB()) { |
| 486 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 485 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 487 return nullptr; | 486 return nullptr; |
| 488 } | 487 } |
| 489 | 488 |
| 490 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 489 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 491 backendDB()->clear(m_transaction->id(), id(), WebIDBCallbacksImpl::create(re
quest).release()); | 490 backendDB()->clear(m_transaction->id(), id(), request->createWebCallbacks().
release()); |
| 492 return request; | 491 return request; |
| 493 } | 492 } |
| 494 | 493 |
| 495 namespace { | 494 namespace { |
| 496 // This class creates the index keys for a given index by extracting | 495 // This class creates the index keys for a given index by extracting |
| 497 // them from the SerializedScriptValue, for all the existing values in | 496 // them from the SerializedScriptValue, for all the existing values in |
| 498 // the objectStore. It only needs to be kept alive by virtue of being | 497 // the objectStore. It only needs to be kept alive by virtue of being |
| 499 // a listener on an IDBRequest object, in the same way that JavaScript | 498 // a listener on an IDBRequest object, in the same way that JavaScript |
| 500 // cursor success handlers are kept alive. | 499 // cursor success handlers are kept alive. |
| 501 class IndexPopulator final : public EventListener { | 500 class IndexPopulator final : public EventListener { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 } | 733 } |
| 735 | 734 |
| 736 return openCursor(scriptState, keyRange, direction, WebIDBTaskTypeNormal); | 735 return openCursor(scriptState, keyRange, direction, WebIDBTaskTypeNormal); |
| 737 } | 736 } |
| 738 | 737 |
| 739 IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, IDBKeyRange* ra
nge, WebIDBCursorDirection direction, WebIDBTaskType taskType) | 738 IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, IDBKeyRange* ra
nge, WebIDBCursorDirection direction, WebIDBTaskType taskType) |
| 740 { | 739 { |
| 741 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 740 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 742 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); | 741 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); |
| 743 | 742 |
| 744 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, range, direction, false, taskType, WebIDBCallbacksImpl::create(request).rele
ase()); | 743 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, range, direction, false, taskType, request->createWebCallbacks().release()); |
| 745 return request; | 744 return request; |
| 746 } | 745 } |
| 747 | 746 |
| 748 IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* scriptState, const Script
Value& range, const String& directionString, ExceptionState& exceptionState) | 747 IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* scriptState, const Script
Value& range, const String& directionString, ExceptionState& exceptionState) |
| 749 { | 748 { |
| 750 IDB_TRACE("IDBObjectStore::openKeyCursor"); | 749 IDB_TRACE("IDBObjectStore::openKeyCursor"); |
| 751 if (isDeleted()) { | 750 if (isDeleted()) { |
| 752 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 751 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 753 return nullptr; | 752 return nullptr; |
| 754 } | 753 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 767 return nullptr; | 766 return nullptr; |
| 768 | 767 |
| 769 if (!backendDB()) { | 768 if (!backendDB()) { |
| 770 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 769 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 771 return nullptr; | 770 return nullptr; |
| 772 } | 771 } |
| 773 | 772 |
| 774 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 773 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 775 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); | 774 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); |
| 776 | 775 |
| 777 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, keyRange, direction, true, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create
(request).release()); | 776 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, keyRange, direction, true, WebIDBTaskTypeNormal, request->createWebCallbacks
().release()); |
| 778 return request; | 777 return request; |
| 779 } | 778 } |
| 780 | 779 |
| 781 IDBRequest* IDBObjectStore::count(ScriptState* scriptState, const ScriptValue& r
ange, ExceptionState& exceptionState) | 780 IDBRequest* IDBObjectStore::count(ScriptState* scriptState, const ScriptValue& r
ange, ExceptionState& exceptionState) |
| 782 { | 781 { |
| 783 IDB_TRACE("IDBObjectStore::count"); | 782 IDB_TRACE("IDBObjectStore::count"); |
| 784 if (isDeleted()) { | 783 if (isDeleted()) { |
| 785 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 784 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 786 return nullptr; | 785 return nullptr; |
| 787 } | 786 } |
| 788 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 787 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 789 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 788 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 790 return nullptr; | 789 return nullptr; |
| 791 } | 790 } |
| 792 if (!m_transaction->isActive()) { | 791 if (!m_transaction->isActive()) { |
| 793 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 792 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 794 return nullptr; | 793 return nullptr; |
| 795 } | 794 } |
| 796 | 795 |
| 797 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti
onContext(), range, exceptionState); | 796 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti
onContext(), range, exceptionState); |
| 798 if (exceptionState.hadException()) | 797 if (exceptionState.hadException()) |
| 799 return nullptr; | 798 return nullptr; |
| 800 | 799 |
| 801 if (!backendDB()) { | 800 if (!backendDB()) { |
| 802 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 801 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 803 return nullptr; | 802 return nullptr; |
| 804 } | 803 } |
| 805 | 804 |
| 806 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 805 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 807 backendDB()->count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, k
eyRange, WebIDBCallbacksImpl::create(request).release()); | 806 backendDB()->count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, k
eyRange, request->createWebCallbacks().release()); |
| 808 return request; | 807 return request; |
| 809 } | 808 } |
| 810 | 809 |
| 811 void IDBObjectStore::markDeleted() | 810 void IDBObjectStore::markDeleted() |
| 812 { | 811 { |
| 813 DCHECK(m_transaction->isVersionChange()) << "An object store got deleted out
side a versionchange transaction."; | 812 DCHECK(m_transaction->isVersionChange()) << "An object store got deleted out
side a versionchange transaction."; |
| 814 m_deleted = true; | 813 m_deleted = true; |
| 815 } | 814 } |
| 816 | 815 |
| 817 void IDBObjectStore::abort() | 816 void IDBObjectStore::abort() |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 } | 855 } |
| 857 return IDBIndexMetadata::InvalidId; | 856 return IDBIndexMetadata::InvalidId; |
| 858 } | 857 } |
| 859 | 858 |
| 860 WebIDBDatabase* IDBObjectStore::backendDB() const | 859 WebIDBDatabase* IDBObjectStore::backendDB() const |
| 861 { | 860 { |
| 862 return m_transaction->backendDB(); | 861 return m_transaction->backendDB(); |
| 863 } | 862 } |
| 864 | 863 |
| 865 } // namespace blink | 864 } // namespace blink |
| OLD | NEW |