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 |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
13 * | 13 * |
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "modules/indexeddb/IDBObjectStore.h" | 26 #include "modules/indexeddb/IDBObjectStore.h" |
27 | 27 |
| 28 #include "Source/modules/indexeddb/indexed_db.mojom-blink.h" |
28 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
30 #include "bindings/core/v8/ScriptState.h" | 31 #include "bindings/core/v8/ScriptState.h" |
31 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 32 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
32 #include "bindings/modules/v8/ToV8ForModules.h" | 33 #include "bindings/modules/v8/ToV8ForModules.h" |
33 #include "bindings/modules/v8/V8BindingForModules.h" | 34 #include "bindings/modules/v8/V8BindingForModules.h" |
34 #include "core/dom/DOMStringList.h" | 35 #include "core/dom/DOMStringList.h" |
35 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
36 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
37 #include "modules/indexeddb/IDBAny.h" | 38 #include "modules/indexeddb/IDBAny.h" |
38 #include "modules/indexeddb/IDBCursorWithValue.h" | 39 #include "modules/indexeddb/IDBCursorWithValue.h" |
39 #include "modules/indexeddb/IDBDatabase.h" | 40 #include "modules/indexeddb/IDBDatabase.h" |
| 41 #include "modules/indexeddb/IDBDatabaseProxy.h" |
40 #include "modules/indexeddb/IDBKeyPath.h" | 42 #include "modules/indexeddb/IDBKeyPath.h" |
41 #include "modules/indexeddb/IDBTracing.h" | 43 #include "modules/indexeddb/IDBTracing.h" |
42 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | |
43 #include "platform/SharedBuffer.h" | 44 #include "platform/SharedBuffer.h" |
44 #include "public/platform/WebBlobInfo.h" | 45 #include "public/platform/WebBlobInfo.h" |
45 #include "public/platform/WebData.h" | 46 #include "public/platform/WebData.h" |
46 #include "public/platform/WebVector.h" | 47 #include "public/platform/WebVector.h" |
47 #include "public/platform/modules/indexeddb/WebIDBKey.h" | 48 #include "public/platform/modules/indexeddb/WebIDBKey.h" |
48 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" | 49 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" |
49 #include <memory> | 50 #include <memory> |
50 #include <v8.h> | 51 #include <v8.h> |
51 | 52 |
52 using blink::WebBlobInfo; | 53 using indexed_db::mojom::blink::CursorDirection; |
53 using blink::WebIDBCallbacks; | 54 using indexed_db::mojom::blink::KeyPtr; |
54 using blink::WebIDBCursor; | 55 using indexed_db::mojom::blink::KeyRangePtr; |
55 using blink::WebIDBDatabase; | 56 using indexed_db::mojom::blink::PutMode; |
56 using blink::WebVector; | |
57 | 57 |
58 namespace blink { | 58 namespace blink { |
59 | 59 |
60 IDBObjectStore::IDBObjectStore(const IDBObjectStoreMetadata& metadata, IDBTransa
ction* transaction) | 60 IDBObjectStore::IDBObjectStore(const IDBObjectStoreMetadata& metadata, IDBTransa
ction* transaction) |
61 : m_metadata(metadata) | 61 : m_metadata(metadata) |
62 , m_transaction(transaction) | 62 , m_transaction(transaction) |
63 { | 63 { |
64 ASSERT(m_transaction); | 64 ASSERT(m_transaction); |
65 } | 65 } |
66 | 66 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 if (!keyRange) { | 107 if (!keyRange) { |
108 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); | 108 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); |
109 return nullptr; | 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 nullptr; | 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).release()); | 117 indexed_db::mojom::blink::Database::GetCallback getCallback = convertToBaseC
allback(WTF::bind(&IDBRequest::onGetResult, wrapWeakPersistent(request))); |
| 118 backendDB()->Get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key
Range, false, getCallback); |
118 return request; | 119 return request; |
119 } | 120 } |
120 | 121 |
121 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, ExceptionState& exceptionState) | 122 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, ExceptionState& exceptionState) |
122 { | 123 { |
123 return getAll(scriptState, keyRange, std::numeric_limits<uint32_t>::max(), e
xceptionState); | 124 return getAll(scriptState, keyRange, std::numeric_limits<uint32_t>::max(), e
xceptionState); |
124 } | 125 } |
125 | 126 |
126 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, unsigned long maxCount, ExceptionState& exceptionState) | 127 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
keyRange, unsigned long maxCount, ExceptionState& exceptionState) |
127 { | 128 { |
(...skipping 15 matching lines...) Expand all Loading... |
143 } | 144 } |
144 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->getExecutionC
ontext(), keyRange, exceptionState); | 145 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->getExecutionC
ontext(), keyRange, exceptionState); |
145 if (exceptionState.hadException()) | 146 if (exceptionState.hadException()) |
146 return nullptr; | 147 return nullptr; |
147 if (!backendDB()) { | 148 if (!backendDB()) { |
148 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 149 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
149 return nullptr; | 150 return nullptr; |
150 } | 151 } |
151 | 152 |
152 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 153 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
153 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId,
range, maxCount, false, WebIDBCallbacksImpl::create(request).release()); | 154 backendDB()->GetAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId,
range, maxCount, false); |
154 return request; | 155 return request; |
155 } | 156 } |
156 | 157 |
157 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal
ue& keyRange, ExceptionState& exceptionState) | 158 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal
ue& keyRange, ExceptionState& exceptionState) |
158 { | 159 { |
159 return getAllKeys(scriptState, keyRange, std::numeric_limits<uint32_t>::max(
), exceptionState); | 160 return getAllKeys(scriptState, keyRange, std::numeric_limits<uint32_t>::max(
), exceptionState); |
160 } | 161 } |
161 | 162 |
162 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal
ue& keyRange, unsigned long maxCount, ExceptionState& exceptionState) | 163 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal
ue& keyRange, unsigned long maxCount, ExceptionState& exceptionState) |
163 { | 164 { |
(...skipping 15 matching lines...) Expand all Loading... |
179 } | 180 } |
180 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->getExecutionC
ontext(), keyRange, exceptionState); | 181 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->getExecutionC
ontext(), keyRange, exceptionState); |
181 if (exceptionState.hadException()) | 182 if (exceptionState.hadException()) |
182 return nullptr; | 183 return nullptr; |
183 if (!backendDB()) { | 184 if (!backendDB()) { |
184 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 185 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
185 return nullptr; | 186 return nullptr; |
186 } | 187 } |
187 | 188 |
188 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 189 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
189 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId,
range, maxCount, true, WebIDBCallbacksImpl::create(request).release()); | 190 backendDB()->GetAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId,
range, maxCount, true); |
190 return request; | 191 return request; |
191 } | 192 } |
192 | 193 |
193 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada
ta& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* in
dexKeys) | 194 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada
ta& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* in
dexKeys) |
194 { | 195 { |
195 ASSERT(indexKeys); | 196 ASSERT(indexKeys); |
196 NonThrowableExceptionState exceptionState; | 197 NonThrowableExceptionState exceptionState; |
197 IDBKey* indexKey = ScriptValue::to<IDBKey*>(isolate, objectValue, exceptionS
tate, indexMetadata.keyPath); | 198 IDBKey* indexKey = ScriptValue::to<IDBKey*>(isolate, objectValue, exceptionS
tate, indexMetadata.keyPath); |
198 | 199 |
199 if (!indexKey) | 200 if (!indexKey) |
(...skipping 10 matching lines...) Expand all Loading... |
210 indexKey = IDBKey::createMultiEntryArray(indexKey->array()); | 211 indexKey = IDBKey::createMultiEntryArray(indexKey->array()); |
211 | 212 |
212 for (size_t i = 0; i < indexKey->array().size(); ++i) | 213 for (size_t i = 0; i < indexKey->array().size(); ++i) |
213 indexKeys->append(indexKey->array()[i]); | 214 indexKeys->append(indexKey->array()[i]); |
214 } | 215 } |
215 } | 216 } |
216 | 217 |
217 IDBRequest* IDBObjectStore::add(ScriptState* scriptState, const ScriptValue& val
ue, const ScriptValue& key, ExceptionState& exceptionState) | 218 IDBRequest* IDBObjectStore::add(ScriptState* scriptState, const ScriptValue& val
ue, const ScriptValue& key, ExceptionState& exceptionState) |
218 { | 219 { |
219 IDB_TRACE("IDBObjectStore::add"); | 220 IDB_TRACE("IDBObjectStore::add"); |
220 return put(scriptState, WebIDBPutModeAddOnly, IDBAny::create(this), value, k
ey, exceptionState); | 221 return put(scriptState, PutMode::AddOnly, IDBAny::create(this), value, key,
exceptionState); |
221 } | 222 } |
222 | 223 |
223 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, const ScriptValue& val
ue, const ScriptValue& key, ExceptionState& exceptionState) | 224 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, const ScriptValue& val
ue, const ScriptValue& key, ExceptionState& exceptionState) |
224 { | 225 { |
225 IDB_TRACE("IDBObjectStore::put"); | 226 IDB_TRACE("IDBObjectStore::put"); |
226 return put(scriptState, WebIDBPutModeAddOrUpdate, IDBAny::create(this), valu
e, key, exceptionState); | 227 return put(scriptState, PutMode::AddOrUpdate, IDBAny::create(this), value, k
ey, exceptionState); |
227 } | 228 } |
228 | 229 |
229 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode,
IDBAny* source, const ScriptValue& value, const ScriptValue& keyValue, Exceptio
nState& exceptionState) | 230 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, PutMode putMode, IDBAn
y* source, const ScriptValue& value, const ScriptValue& keyValue, ExceptionState
& exceptionState) |
230 { | 231 { |
231 IDBKey* key = keyValue.isUndefined() ? nullptr : ScriptValue::to<IDBKey*>(sc
riptState->isolate(), keyValue, exceptionState); | 232 IDBKey* key = keyValue.isUndefined() ? nullptr : ScriptValue::to<IDBKey*>(sc
riptState->isolate(), keyValue, exceptionState); |
232 if (exceptionState.hadException()) | 233 if (exceptionState.hadException()) |
233 return nullptr; | 234 return nullptr; |
234 return put(scriptState, putMode, source, value, key, exceptionState); | 235 return put(scriptState, putMode, source, value, key, exceptionState); |
235 } | 236 } |
236 | 237 |
237 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode,
IDBAny* source, const ScriptValue& value, IDBKey* key, ExceptionState& exceptio
nState) | 238 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, PutMode putMode, IDBAn
y* source, const ScriptValue& value, IDBKey* key, ExceptionState& exceptionState
) |
238 { | 239 { |
239 if (isDeleted()) { | 240 if (isDeleted()) { |
240 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 241 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
241 return nullptr; | 242 return nullptr; |
242 } | 243 } |
243 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 244 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
244 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 245 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
245 return nullptr; | 246 return nullptr; |
246 } | 247 } |
247 if (!m_transaction->isActive()) { | 248 if (!m_transaction->isActive()) { |
(...skipping 14 matching lines...) Expand all Loading... |
262 | 263 |
263 // Keys that need to be extracted must be taken from a clone so that | 264 // Keys that need to be extracted must be taken from a clone so that |
264 // side effects (i.e. getters) are not triggered. Construct the | 265 // side effects (i.e. getters) are not triggered. Construct the |
265 // clone lazily since the operation may be expensive. | 266 // clone lazily since the operation may be expensive. |
266 ScriptValue clone; | 267 ScriptValue clone; |
267 | 268 |
268 const IDBKeyPath& keyPath = m_metadata.keyPath; | 269 const IDBKeyPath& keyPath = m_metadata.keyPath; |
269 const bool usesInLineKeys = !keyPath.isNull(); | 270 const bool usesInLineKeys = !keyPath.isNull(); |
270 const bool hasKeyGenerator = autoIncrement(); | 271 const bool hasKeyGenerator = autoIncrement(); |
271 | 272 |
272 if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) { | 273 if (putMode != PutMode::CursorUpdate && usesInLineKeys && key) { |
273 exceptionState.throwDOMException(DataError, "The object store uses in-li
ne keys and the key parameter was provided."); | 274 exceptionState.throwDOMException(DataError, "The object store uses in-li
ne keys and the key parameter was provided."); |
274 return nullptr; | 275 return nullptr; |
275 } | 276 } |
276 | 277 |
277 // This test logically belongs in IDBCursor, but must operate on the cloned
value. | 278 // This test logically belongs in IDBCursor, but must operate on the cloned
value. |
278 if (putMode == WebIDBPutModeCursorUpdate && usesInLineKeys) { | 279 if (putMode == PutMode::CursorUpdate && usesInLineKeys) { |
279 ASSERT(key); | 280 ASSERT(key); |
280 if (clone.isEmpty()) | 281 if (clone.isEmpty()) |
281 clone = deserializeScriptValue(scriptState, serializedValue.get(), &
blobInfo); | 282 clone = deserializeScriptValue(scriptState, serializedValue.get(), &
blobInfo); |
282 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), cl
one, exceptionState, keyPath); | 283 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), cl
one, exceptionState, keyPath); |
283 if (exceptionState.hadException()) | 284 if (exceptionState.hadException()) |
284 return nullptr; | 285 return nullptr; |
285 if (!keyPathKey || !keyPathKey->isEqual(key)) { | 286 if (!keyPathKey || !keyPathKey->isEqual(key)) { |
286 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."); | 287 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."); |
287 return nullptr; | 288 return nullptr; |
288 } | 289 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 for (const auto& it : m_metadata.indexes) { | 331 for (const auto& it : m_metadata.indexes) { |
331 if (clone.isEmpty()) | 332 if (clone.isEmpty()) |
332 clone = deserializeScriptValue(scriptState, serializedValue.get(), &
blobInfo); | 333 clone = deserializeScriptValue(scriptState, serializedValue.get(), &
blobInfo); |
333 IndexKeys keys; | 334 IndexKeys keys; |
334 generateIndexKeysForValue(scriptState->isolate(), it.value, clone, &keys
); | 335 generateIndexKeysForValue(scriptState->isolate(), it.value, clone, &keys
); |
335 indexIds.append(it.key); | 336 indexIds.append(it.key); |
336 indexKeys.append(keys); | 337 indexKeys.append(keys); |
337 } | 338 } |
338 | 339 |
339 IDBRequest* request = IDBRequest::create(scriptState, source, m_transaction.
get()); | 340 IDBRequest* request = IDBRequest::create(scriptState, source, m_transaction.
get()); |
340 Vector<char> wireBytes; | 341 #if 0 |
341 serializedValue->toWireBytes(wireBytes); | 342 // Should we be using toWireButes, or instead using Mojo's built-in |
342 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); | 343 // serialization? |
| 344 Vector<int8_t> valueWireBytes; |
| 345 serializedValue->toWireBytes(valueWireBytes); |
343 | 346 |
344 backendDB()->put(m_transaction->id(), id(), WebData(valueBuffer), blobInfo,
key, static_cast<WebIDBPutMode>(putMode), WebIDBCallbacksImpl::create(request).r
elease(), indexIds, indexKeys); | 347 backendDB()->Put(m_transaction->id(), id(), std::move(valueWireBytes), creat
eBlobInfo(blobInfo), createKey(key), putMode, std::move(indexIds), std::move(ind
exKeys)); |
| 348 #endif |
345 return request; | 349 return request; |
346 } | 350 } |
347 | 351 |
348 IDBRequest* IDBObjectStore::deleteFunction(ScriptState* scriptState, const Scrip
tValue& key, ExceptionState& exceptionState) | 352 IDBRequest* IDBObjectStore::deleteFunction(ScriptState* scriptState, const Scrip
tValue& key, ExceptionState& exceptionState) |
349 { | 353 { |
350 IDB_TRACE("IDBObjectStore::delete"); | 354 IDB_TRACE("IDBObjectStore::delete"); |
351 if (isDeleted()) { | 355 if (isDeleted()) { |
352 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 356 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
353 return nullptr; | 357 return nullptr; |
354 } | 358 } |
(...skipping 16 matching lines...) Expand all Loading... |
371 if (!keyRange) { | 375 if (!keyRange) { |
372 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); | 376 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); |
373 return nullptr; | 377 return nullptr; |
374 } | 378 } |
375 if (!backendDB()) { | 379 if (!backendDB()) { |
376 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 380 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
377 return nullptr; | 381 return nullptr; |
378 } | 382 } |
379 | 383 |
380 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 384 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
381 backendDB()->deleteRange(m_transaction->id(), id(), keyRange, WebIDBCallback
sImpl::create(request).release()); | 385 backendDB()->DeleteRange(m_transaction->id(), id(), keyRange); |
382 return request; | 386 return request; |
383 } | 387 } |
384 | 388 |
385 IDBRequest* IDBObjectStore::clear(ScriptState* scriptState, ExceptionState& exce
ptionState) | 389 IDBRequest* IDBObjectStore::clear(ScriptState* scriptState, ExceptionState& exce
ptionState) |
386 { | 390 { |
387 IDB_TRACE("IDBObjectStore::clear"); | 391 IDB_TRACE("IDBObjectStore::clear"); |
388 if (isDeleted()) { | 392 if (isDeleted()) { |
389 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 393 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
390 return nullptr; | 394 return nullptr; |
391 } | 395 } |
392 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 396 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
393 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 397 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
394 return nullptr; | 398 return nullptr; |
395 } | 399 } |
396 if (!m_transaction->isActive()) { | 400 if (!m_transaction->isActive()) { |
397 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 401 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
398 return nullptr; | 402 return nullptr; |
399 } | 403 } |
400 if (m_transaction->isReadOnly()) { | 404 if (m_transaction->isReadOnly()) { |
401 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction
ReadOnlyErrorMessage); | 405 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction
ReadOnlyErrorMessage); |
402 return nullptr; | 406 return nullptr; |
403 } | 407 } |
404 if (!backendDB()) { | 408 if (!backendDB()) { |
405 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 409 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
406 return nullptr; | 410 return nullptr; |
407 } | 411 } |
408 | 412 |
409 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 413 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
410 backendDB()->clear(m_transaction->id(), id(), WebIDBCallbacksImpl::create(re
quest).release()); | 414 backendDB()->Clear(m_transaction->id(), id()); |
411 return request; | 415 return request; |
412 } | 416 } |
413 | 417 |
414 namespace { | 418 namespace { |
415 // This class creates the index keys for a given index by extracting | 419 // This class creates the index keys for a given index by extracting |
416 // them from the SerializedScriptValue, for all the existing values in | 420 // them from the SerializedScriptValue, for all the existing values in |
417 // the objectStore. It only needs to be kept alive by virtue of being | 421 // the objectStore. It only needs to be kept alive by virtue of being |
418 // a listener on an IDBRequest object, in the same way that JavaScript | 422 // a listener on an IDBRequest object, in the same way that JavaScript |
419 // cursor success handlers are kept alive. | 423 // cursor success handlers are kept alive. |
420 class IndexPopulator final : public EventListener { | 424 class IndexPopulator final : public EventListener { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 472 |
469 IDBKey* primaryKey = cursor->idbPrimaryKey(); | 473 IDBKey* primaryKey = cursor->idbPrimaryKey(); |
470 ScriptValue value = cursor->value(m_scriptState.get()); | 474 ScriptValue value = cursor->value(m_scriptState.get()); |
471 | 475 |
472 IDBObjectStore::IndexKeys indexKeys; | 476 IDBObjectStore::IndexKeys indexKeys; |
473 generateIndexKeysForValue(m_scriptState->isolate(), m_indexMetadata,
value, &indexKeys); | 477 generateIndexKeysForValue(m_scriptState->isolate(), m_indexMetadata,
value, &indexKeys); |
474 | 478 |
475 HeapVector<IDBObjectStore::IndexKeys> indexKeysList; | 479 HeapVector<IDBObjectStore::IndexKeys> indexKeysList; |
476 indexKeysList.append(indexKeys); | 480 indexKeysList.append(indexKeys); |
477 | 481 |
478 m_database->backend()->setIndexKeys(m_transactionId, m_objectStoreId
, primaryKey, indexIds, indexKeysList); | 482 m_database->backend()->SetIndexKeys(m_transactionId, m_objectStoreId
, primaryKey, indexIds, indexKeysList); |
479 } else { | 483 } else { |
480 // Now that we are done indexing, tell the backend to go | 484 // Now that we are done indexing, tell the backend to go |
481 // back to processing tasks of type NormalTask. | 485 // back to processing tasks of type NormalTask. |
482 m_database->backend()->setIndexesReady(m_transactionId, m_objectStor
eId, indexIds); | 486 m_database->backend()->SetIndexesReady(m_transactionId, m_objectStor
eId, indexIds); |
483 m_database.clear(); | 487 m_database.clear(); |
484 } | 488 } |
485 | 489 |
486 } | 490 } |
487 | 491 |
488 RefPtr<ScriptState> m_scriptState; | 492 RefPtr<ScriptState> m_scriptState; |
489 Member<IDBDatabase> m_database; | 493 Member<IDBDatabase> m_database; |
490 const int64_t m_transactionId; | 494 const int64_t m_transactionId; |
491 const int64_t m_objectStoreId; | 495 const int64_t m_objectStoreId; |
492 const IDBIndexMetadata m_indexMetadata; | 496 const IDBIndexMetadata m_indexMetadata; |
493 }; | 497 }; |
494 } // namespace | 498 } // namespace |
495 | 499 |
496 IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
me, const IDBKeyPath& keyPath, const IDBIndexParameters& options, ExceptionState
& exceptionState) | 500 IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
me, const StringOrStringSequence& keyPathSeq, const IDBIndexParameters& options,
ExceptionState& exceptionState) |
497 { | 501 { |
498 IDB_TRACE("IDBObjectStore::createIndex"); | 502 IDB_TRACE("IDBObjectStore::createIndex"); |
499 if (!m_transaction->isVersionChange()) { | 503 if (!m_transaction->isVersionChange()) { |
500 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); | 504 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); |
501 return nullptr; | 505 return nullptr; |
502 } | 506 } |
503 if (isDeleted()) { | 507 if (isDeleted()) { |
504 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 508 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
505 return nullptr; | 509 return nullptr; |
506 } | 510 } |
507 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 511 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
508 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 512 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
509 return nullptr; | 513 return nullptr; |
510 } | 514 } |
511 if (!m_transaction->isActive()) { | 515 if (!m_transaction->isActive()) { |
512 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 516 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
513 return nullptr; | 517 return nullptr; |
514 } | 518 } |
| 519 IDBKeyPath keyPath(keyPathSeq); |
515 if (!keyPath.isValid()) { | 520 if (!keyPath.isValid()) { |
516 exceptionState.throwDOMException(SyntaxError, "The keyPath argument cont
ains an invalid key path."); | 521 exceptionState.throwDOMException(SyntaxError, "The keyPath argument cont
ains an invalid key path."); |
517 return nullptr; | 522 return nullptr; |
518 } | 523 } |
519 if (containsIndex(name)) { | 524 if (containsIndex(name)) { |
520 exceptionState.throwDOMException(ConstraintError, "An index with the spe
cified name already exists."); | 525 exceptionState.throwDOMException(ConstraintError, "An index with the spe
cified name already exists."); |
521 return nullptr; | 526 return nullptr; |
522 } | 527 } |
523 | 528 |
524 if (keyPath.getType() == IDBKeyPath::ArrayType && options.multiEntry()) { | 529 if (keyPath.getType() == IDBKeyPath::ArrayType && options.multiEntry()) { |
525 exceptionState.throwDOMException(InvalidAccessError, "The keyPath argume
nt was an array and the multiEntry option is true."); | 530 exceptionState.throwDOMException(InvalidAccessError, "The keyPath argume
nt was an array and the multiEntry option is true."); |
526 return nullptr; | 531 return nullptr; |
527 } | 532 } |
528 if (!backendDB()) { | 533 if (!backendDB()) { |
529 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 534 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
530 return nullptr; | 535 return nullptr; |
531 } | 536 } |
532 | 537 |
533 int64_t indexId = m_metadata.maxIndexId + 1; | 538 int64_t indexId = m_metadata.maxIndexId + 1; |
534 backendDB()->createIndex(m_transaction->id(), id(), indexId, name, keyPath,
options.unique(), options.multiEntry()); | 539 backendDB()->CreateIndex(m_transaction->id(), id(), indexId, name, keyPath,
options.unique(), options.multiEntry()); |
535 | 540 |
536 ++m_metadata.maxIndexId; | 541 ++m_metadata.maxIndexId; |
537 | 542 |
538 IDBIndexMetadata metadata(name, indexId, keyPath, options.unique(), options.
multiEntry()); | 543 IDBIndexMetadata metadata(name, indexId, keyPath, options.unique(), options.
multiEntry()); |
539 IDBIndex* index = IDBIndex::create(metadata, this, m_transaction.get()); | 544 IDBIndex* index = IDBIndex::create(metadata, this, m_transaction.get()); |
540 m_indexMap.set(name, index); | 545 m_indexMap.set(name, index); |
541 m_createdIndexes.add(index); | 546 m_createdIndexes.add(index); |
542 m_metadata.indexes.set(indexId, metadata); | 547 m_metadata.indexes.set(indexId, metadata); |
543 m_transaction->db()->indexCreated(id(), metadata); | 548 m_transaction->db()->indexCreated(id(), metadata); |
544 | 549 |
545 ASSERT(!exceptionState.hadException()); | 550 ASSERT(!exceptionState.hadException()); |
546 if (exceptionState.hadException()) | 551 if (exceptionState.hadException()) |
547 return nullptr; | 552 return nullptr; |
548 | 553 |
549 IDBRequest* indexRequest = openCursor(scriptState, nullptr, WebIDBCursorDire
ctionNext, WebIDBTaskTypePreemptive); | 554 IDBRequest* indexRequest = openCursor(scriptState, nullptr, CursorDirection:
:Next, indexed_db::mojom::blink::TaskType::Preemptive); |
550 indexRequest->preventPropagation(); | 555 indexRequest->preventPropagation(); |
551 | 556 |
552 // This is kept alive by being the success handler of the request, which is
in turn kept alive by the owning transaction. | 557 // This is kept alive by being the success handler of the request, which is
in turn kept alive by the owning transaction. |
553 IndexPopulator* indexPopulator = IndexPopulator::create(scriptState, transac
tion()->db(), m_transaction->id(), id(), metadata); | 558 IndexPopulator* indexPopulator = IndexPopulator::create(scriptState, transac
tion()->db(), m_transaction->id(), id(), metadata); |
554 indexRequest->setOnsuccess(indexPopulator); | 559 indexRequest->setOnsuccess(indexPopulator); |
555 return index; | 560 return index; |
556 } | 561 } |
557 | 562 |
558 IDBIndex* IDBObjectStore::index(const String& name, ExceptionState& exceptionSta
te) | 563 IDBIndex* IDBObjectStore::index(const String& name, ExceptionState& exceptionSta
te) |
559 { | 564 { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 int64_t indexId = findIndexId(name); | 619 int64_t indexId = findIndexId(name); |
615 if (indexId == IDBIndexMetadata::InvalidId) { | 620 if (indexId == IDBIndexMetadata::InvalidId) { |
616 exceptionState.throwDOMException(NotFoundError, IDBDatabase::noSuchIndex
ErrorMessage); | 621 exceptionState.throwDOMException(NotFoundError, IDBDatabase::noSuchIndex
ErrorMessage); |
617 return; | 622 return; |
618 } | 623 } |
619 if (!backendDB()) { | 624 if (!backendDB()) { |
620 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 625 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
621 return; | 626 return; |
622 } | 627 } |
623 | 628 |
624 backendDB()->deleteIndex(m_transaction->id(), id(), indexId); | 629 backendDB()->DeleteIndex(m_transaction->id(), id(), indexId); |
625 | 630 |
626 m_metadata.indexes.remove(indexId); | 631 m_metadata.indexes.remove(indexId); |
627 m_transaction->db()->indexDeleted(id(), indexId); | 632 m_transaction->db()->indexDeleted(id(), indexId); |
628 IDBIndexMap::iterator it = m_indexMap.find(name); | 633 IDBIndexMap::iterator it = m_indexMap.find(name); |
629 if (it != m_indexMap.end()) { | 634 if (it != m_indexMap.end()) { |
630 it->value->markDeleted(); | 635 it->value->markDeleted(); |
631 m_indexMap.remove(name); | 636 m_indexMap.remove(name); |
632 } | 637 } |
633 } | 638 } |
634 | 639 |
635 IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, const ScriptVal
ue& range, const String& directionString, ExceptionState& exceptionState) | 640 IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, const ScriptVal
ue& range, const String& directionString, ExceptionState& exceptionState) |
636 { | 641 { |
637 IDB_TRACE("IDBObjectStore::openCursor"); | 642 IDB_TRACE("IDBObjectStore::openCursor"); |
638 if (isDeleted()) { | 643 if (isDeleted()) { |
639 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 644 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
640 return nullptr; | 645 return nullptr; |
641 } | 646 } |
642 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 647 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
643 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 648 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
644 return nullptr; | 649 return nullptr; |
645 } | 650 } |
646 if (!m_transaction->isActive()) { | 651 if (!m_transaction->isActive()) { |
647 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 652 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
648 return nullptr; | 653 return nullptr; |
649 } | 654 } |
650 | 655 |
651 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri
ng); | 656 indexed_db::mojom::blink::CursorDirection direction = IDBCursor::stringToDir
ection(directionString); |
652 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti
onContext(), range, exceptionState); | 657 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti
onContext(), range, exceptionState); |
653 if (exceptionState.hadException()) | 658 if (exceptionState.hadException()) |
654 return nullptr; | 659 return nullptr; |
655 | 660 |
656 if (!backendDB()) { | 661 if (!backendDB()) { |
657 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 662 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
658 return nullptr; | 663 return nullptr; |
659 } | 664 } |
660 | 665 |
661 return openCursor(scriptState, keyRange, direction, WebIDBTaskTypeNormal); | 666 return openCursor(scriptState, keyRange, direction, indexed_db::mojom::blink
::TaskType::Normal); |
662 } | 667 } |
663 | 668 |
664 IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, IDBKeyRange* ra
nge, WebIDBCursorDirection direction, WebIDBTaskType taskType) | 669 IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, IDBKeyRange* ra
nge, CursorDirection direction, indexed_db::mojom::blink::TaskType taskType) |
665 { | 670 { |
666 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 671 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
667 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); | 672 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); |
668 | 673 |
669 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, range, direction, false, taskType, WebIDBCallbacksImpl::create(request).rele
ase()); | 674 backendDB()->OpenCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, range, direction, false, taskType); |
670 return request; | 675 return request; |
671 } | 676 } |
672 | 677 |
673 IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* scriptState, const Script
Value& range, const String& directionString, ExceptionState& exceptionState) | 678 IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* scriptState, const Script
Value& range, const String& directionString, ExceptionState& exceptionState) |
674 { | 679 { |
675 IDB_TRACE("IDBObjectStore::openKeyCursor"); | 680 IDB_TRACE("IDBObjectStore::openKeyCursor"); |
676 if (isDeleted()) { | 681 if (isDeleted()) { |
677 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 682 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
678 return nullptr; | 683 return nullptr; |
679 } | 684 } |
680 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 685 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
681 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 686 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
682 return nullptr; | 687 return nullptr; |
683 } | 688 } |
684 if (!m_transaction->isActive()) { | 689 if (!m_transaction->isActive()) { |
685 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 690 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
686 return nullptr; | 691 return nullptr; |
687 } | 692 } |
688 | 693 |
689 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri
ng); | 694 CursorDirection direction = IDBCursor::stringToDirection(directionString); |
690 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti
onContext(), range, exceptionState); | 695 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti
onContext(), range, exceptionState); |
691 if (exceptionState.hadException()) | 696 if (exceptionState.hadException()) |
692 return nullptr; | 697 return nullptr; |
693 | 698 |
694 if (!backendDB()) { | 699 if (!backendDB()) { |
695 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 700 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
696 return nullptr; | 701 return nullptr; |
697 } | 702 } |
698 | 703 |
699 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 704 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
700 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); | 705 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); |
701 | 706 |
702 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, keyRange, direction, true, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create
(request).release()); | 707 backendDB()->OpenCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid
Id, keyRange, direction, true, indexed_db::mojom::blink::TaskType::Normal); |
703 return request; | 708 return request; |
704 } | 709 } |
705 | 710 |
706 IDBRequest* IDBObjectStore::count(ScriptState* scriptState, const ScriptValue& r
ange, ExceptionState& exceptionState) | 711 IDBRequest* IDBObjectStore::count(ScriptState* scriptState, const ScriptValue& r
ange, ExceptionState& exceptionState) |
707 { | 712 { |
708 IDB_TRACE("IDBObjectStore::count"); | 713 IDB_TRACE("IDBObjectStore::count"); |
709 if (isDeleted()) { | 714 if (isDeleted()) { |
710 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 715 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
711 return nullptr; | 716 return nullptr; |
712 } | 717 } |
713 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 718 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
714 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 719 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
715 return nullptr; | 720 return nullptr; |
716 } | 721 } |
717 if (!m_transaction->isActive()) { | 722 if (!m_transaction->isActive()) { |
718 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 723 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
719 return nullptr; | 724 return nullptr; |
720 } | 725 } |
721 | 726 |
722 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti
onContext(), range, exceptionState); | 727 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti
onContext(), range, exceptionState); |
723 if (exceptionState.hadException()) | 728 if (exceptionState.hadException()) |
724 return nullptr; | 729 return nullptr; |
725 | 730 |
726 if (!backendDB()) { | 731 if (!backendDB()) { |
727 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 732 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
728 return nullptr; | 733 return nullptr; |
729 } | 734 } |
730 | 735 |
731 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 736 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
732 backendDB()->count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, k
eyRange, WebIDBCallbacksImpl::create(request).release()); | 737 backendDB()->Count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, k
eyRange); |
733 return request; | 738 return request; |
734 } | 739 } |
735 | 740 |
736 void IDBObjectStore::abort() | 741 void IDBObjectStore::abort() |
737 { | 742 { |
738 for (auto& index : m_createdIndexes) | 743 for (auto& index : m_createdIndexes) |
739 index->markDeleted(); | 744 index->markDeleted(); |
740 } | 745 } |
741 | 746 |
742 void IDBObjectStore::transactionFinished() | 747 void IDBObjectStore::transactionFinished() |
(...skipping 10 matching lines...) Expand all Loading... |
753 { | 758 { |
754 for (const auto& it : m_metadata.indexes) { | 759 for (const auto& it : m_metadata.indexes) { |
755 if (it.value.name == name) { | 760 if (it.value.name == name) { |
756 ASSERT(it.key != IDBIndexMetadata::InvalidId); | 761 ASSERT(it.key != IDBIndexMetadata::InvalidId); |
757 return it.key; | 762 return it.key; |
758 } | 763 } |
759 } | 764 } |
760 return IDBIndexMetadata::InvalidId; | 765 return IDBIndexMetadata::InvalidId; |
761 } | 766 } |
762 | 767 |
763 WebIDBDatabase* IDBObjectStore::backendDB() const | 768 IDBDatabaseProxy* IDBObjectStore::backendDB() const |
764 { | 769 { |
765 return m_transaction->backendDB(); | 770 return m_transaction->backendDB(); |
766 } | 771 } |
767 | 772 |
768 } // namespace blink | 773 } // namespace blink |
OLD | NEW |