| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 void IDBCursor::trace(Visitor* visitor) | 103 void IDBCursor::trace(Visitor* visitor) |
| 104 { | 104 { |
| 105 visitor->trace(m_request); | 105 visitor->trace(m_request); |
| 106 visitor->trace(m_source); | 106 visitor->trace(m_source); |
| 107 visitor->trace(m_transaction); | 107 visitor->trace(m_transaction); |
| 108 visitor->trace(m_key); | 108 visitor->trace(m_key); |
| 109 visitor->trace(m_primaryKey); | 109 visitor->trace(m_primaryKey); |
| 110 } | 110 } |
| 111 | 111 |
| 112 PassRefPtrWillBeRawPtr<IDBRequest> IDBCursor::update(ExecutionContext* execution
Context, ScriptValue& value, ExceptionState& exceptionState) | 112 PassRefPtrWillBeRawPtr<IDBRequest> IDBCursor::update(ScriptState* scriptState, S
criptValue& value, ExceptionState& exceptionState) |
| 113 { | 113 { |
| 114 IDB_TRACE("IDBCursor::update"); | 114 IDB_TRACE("IDBCursor::update"); |
| 115 | 115 |
| 116 if (!m_gotValue) { | 116 if (!m_gotValue) { |
| 117 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue
ErrorMessage); | 117 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue
ErrorMessage); |
| 118 return nullptr; | 118 return nullptr; |
| 119 } | 119 } |
| 120 if (isKeyCursor()) { | 120 if (isKeyCursor()) { |
| 121 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu
rsorErrorMessage); | 121 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu
rsorErrorMessage); |
| 122 return nullptr; | 122 return nullptr; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 135 } | 135 } |
| 136 if (m_transaction->isReadOnly()) { | 136 if (m_transaction->isReadOnly()) { |
| 137 exceptionState.throwDOMException(ReadOnlyError, "The record may not be u
pdated inside a read-only transaction."); | 137 exceptionState.throwDOMException(ReadOnlyError, "The record may not be u
pdated inside a read-only transaction."); |
| 138 return nullptr; | 138 return nullptr; |
| 139 } | 139 } |
| 140 | 140 |
| 141 RefPtrWillBeRawPtr<IDBObjectStore> objectStore = effectiveObjectStore(); | 141 RefPtrWillBeRawPtr<IDBObjectStore> objectStore = effectiveObjectStore(); |
| 142 const IDBKeyPath& keyPath = objectStore->metadata().keyPath; | 142 const IDBKeyPath& keyPath = objectStore->metadata().keyPath; |
| 143 const bool usesInLineKeys = !keyPath.isNull(); | 143 const bool usesInLineKeys = !keyPath.isNull(); |
| 144 if (usesInLineKeys) { | 144 if (usesInLineKeys) { |
| 145 RefPtrWillBeRawPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKe
yPath(toIsolate(executionContext), value, keyPath); | 145 RefPtrWillBeRawPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKe
yPath(scriptState->isolate(), value, keyPath); |
| 146 if (!keyPathKey || !keyPathKey->isEqual(m_primaryKey.get())) { | 146 if (!keyPathKey || !keyPathKey->isEqual(m_primaryKey.get())) { |
| 147 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."); | 147 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."); |
| 148 return nullptr; | 148 return nullptr; |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 return objectStore->put(executionContext, WebIDBDatabase::CursorUpdate, IDBA
ny::create(this), value, m_primaryKey, exceptionState); | 152 return objectStore->put(scriptState, WebIDBDatabase::CursorUpdate, IDBAny::c
reate(this), value, m_primaryKey, exceptionState); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void IDBCursor::advance(unsigned long count, ExceptionState& exceptionState) | 155 void IDBCursor::advance(unsigned long count, ExceptionState& exceptionState) |
| 156 { | 156 { |
| 157 IDB_TRACE("IDBCursor::advance"); | 157 IDB_TRACE("IDBCursor::advance"); |
| 158 if (!count) { | 158 if (!count) { |
| 159 exceptionState.throwTypeError("A count argument with value 0 (zero) was
supplied, must be greater than 0."); | 159 exceptionState.throwTypeError("A count argument with value 0 (zero) was
supplied, must be greater than 0."); |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 if (!m_gotValue) { | 162 if (!m_gotValue) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 175 if (!m_transaction->isActive()) { | 175 if (!m_transaction->isActive()) { |
| 176 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 176 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 | 179 |
| 180 m_request->setPendingCursor(this); | 180 m_request->setPendingCursor(this); |
| 181 m_gotValue = false; | 181 m_gotValue = false; |
| 182 m_backend->advance(count, WebIDBCallbacksImpl::create(m_request).leakPtr()); | 182 m_backend->advance(count, WebIDBCallbacksImpl::create(m_request).leakPtr()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void IDBCursor::continueFunction(ExecutionContext* context, const ScriptValue& k
eyValue, ExceptionState& exceptionState) | 185 void IDBCursor::continueFunction(ScriptState* scriptState, const ScriptValue& ke
yValue, ExceptionState& exceptionState) |
| 186 { | 186 { |
| 187 IDB_TRACE("IDBCursor::continue"); | 187 IDB_TRACE("IDBCursor::continue"); |
| 188 RefPtrWillBeRawPtr<IDBKey> key = keyValue.isUndefined() || keyValue.isNull()
? nullptr : scriptValueToIDBKey(toIsolate(context), keyValue); | 188 RefPtrWillBeRawPtr<IDBKey> key = keyValue.isUndefined() || keyValue.isNull()
? nullptr : scriptValueToIDBKey(scriptState->isolate(), keyValue); |
| 189 if (key && !key->isValid()) { | 189 if (key && !key->isValid()) { |
| 190 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 190 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 191 return; | 191 return; |
| 192 } | 192 } |
| 193 continueFunction(key.release(), nullptr, exceptionState); | 193 continueFunction(key.release(), nullptr, exceptionState); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void IDBCursor::continuePrimaryKey(ExecutionContext* context, const ScriptValue&
keyValue, const ScriptValue& primaryKeyValue, ExceptionState& exceptionState) | 196 void IDBCursor::continuePrimaryKey(ScriptState* scriptState, const ScriptValue&
keyValue, const ScriptValue& primaryKeyValue, ExceptionState& exceptionState) |
| 197 { | 197 { |
| 198 IDB_TRACE("IDBCursor::continuePrimaryKey"); | 198 IDB_TRACE("IDBCursor::continuePrimaryKey"); |
| 199 RefPtrWillBeRawPtr<IDBKey> key = scriptValueToIDBKey(toIsolate(context), key
Value); | 199 RefPtrWillBeRawPtr<IDBKey> key = scriptValueToIDBKey(scriptState->isolate(),
keyValue); |
| 200 RefPtrWillBeRawPtr<IDBKey> primaryKey = scriptValueToIDBKey(toIsolate(contex
t), primaryKeyValue); | 200 RefPtrWillBeRawPtr<IDBKey> primaryKey = scriptValueToIDBKey(scriptState->iso
late(), primaryKeyValue); |
| 201 if (!key->isValid() || !primaryKey->isValid()) { | 201 if (!key->isValid() || !primaryKey->isValid()) { |
| 202 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 202 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 203 return; | 203 return; |
| 204 } | 204 } |
| 205 continueFunction(key.release(), primaryKey.release(), exceptionState); | 205 continueFunction(key.release(), primaryKey.release(), exceptionState); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void IDBCursor::continueFunction(PassRefPtrWillBeRawPtr<IDBKey> key, PassRefPtrW
illBeRawPtr<IDBKey> primaryKey, ExceptionState& exceptionState) | 208 void IDBCursor::continueFunction(PassRefPtrWillBeRawPtr<IDBKey> key, PassRefPtrW
illBeRawPtr<IDBKey> primaryKey, ExceptionState& exceptionState) |
| 209 { | 209 { |
| 210 ASSERT(!primaryKey || (key && primaryKey)); | 210 ASSERT(!primaryKey || (key && primaryKey)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 | 250 |
| 251 // FIXME: We're not using the context from when continue was called, which m
eans the callback | 251 // FIXME: We're not using the context from when continue was called, which m
eans the callback |
| 252 // will be on the original context openCursor was called on. Is this
right? | 252 // will be on the original context openCursor was called on. Is this
right? |
| 253 m_request->setPendingCursor(this); | 253 m_request->setPendingCursor(this); |
| 254 m_gotValue = false; | 254 m_gotValue = false; |
| 255 m_backend->continueFunction(key, primaryKey, WebIDBCallbacksImpl::create(m_r
equest).leakPtr()); | 255 m_backend->continueFunction(key, primaryKey, WebIDBCallbacksImpl::create(m_r
equest).leakPtr()); |
| 256 } | 256 } |
| 257 | 257 |
| 258 PassRefPtrWillBeRawPtr<IDBRequest> IDBCursor::deleteFunction(ExecutionContext* c
ontext, ExceptionState& exceptionState) | 258 PassRefPtrWillBeRawPtr<IDBRequest> IDBCursor::deleteFunction(ScriptState* script
State, ExceptionState& exceptionState) |
| 259 { | 259 { |
| 260 IDB_TRACE("IDBCursor::delete"); | 260 IDB_TRACE("IDBCursor::delete"); |
| 261 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 261 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 262 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 262 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 263 return nullptr; | 263 return nullptr; |
| 264 } | 264 } |
| 265 if (!m_transaction->isActive()) { | 265 if (!m_transaction->isActive()) { |
| 266 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 266 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 267 return nullptr; | 267 return nullptr; |
| 268 } | 268 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 284 return nullptr; | 284 return nullptr; |
| 285 } | 285 } |
| 286 if (!m_transaction->backendDB()) { | 286 if (!m_transaction->backendDB()) { |
| 287 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 287 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 288 return nullptr; | 288 return nullptr; |
| 289 } | 289 } |
| 290 | 290 |
| 291 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::only(m_primaryKey, e
xceptionState); | 291 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::only(m_primaryKey, e
xceptionState); |
| 292 ASSERT(!exceptionState.hadException()); | 292 ASSERT(!exceptionState.hadException()); |
| 293 | 293 |
| 294 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny:
:create(this), m_transaction.get()); | 294 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB
Any::create(this), m_transaction.get()); |
| 295 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject
Store()->id(), keyRange.release(), WebIDBCallbacksImpl::create(request).leakPtr(
)); | 295 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject
Store()->id(), keyRange.release(), WebIDBCallbacksImpl::create(request).leakPtr(
)); |
| 296 return request.release(); | 296 return request.release(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void IDBCursor::postSuccessHandlerCallback() | 299 void IDBCursor::postSuccessHandlerCallback() |
| 300 { | 300 { |
| 301 if (m_backend) | 301 if (m_backend) |
| 302 m_backend->postSuccessHandlerCallback(); | 302 m_backend->postSuccessHandlerCallback(); |
| 303 } | 303 } |
| 304 | 304 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 case WebIDBCursor::PrevNoDuplicate: | 438 case WebIDBCursor::PrevNoDuplicate: |
| 439 return IDBCursor::directionPrevUnique(); | 439 return IDBCursor::directionPrevUnique(); |
| 440 | 440 |
| 441 default: | 441 default: |
| 442 ASSERT_NOT_REACHED(); | 442 ASSERT_NOT_REACHED(); |
| 443 return IDBCursor::directionNext(); | 443 return IDBCursor::directionNext(); |
| 444 } | 444 } |
| 445 } | 445 } |
| 446 | 446 |
| 447 } // namespace WebCore | 447 } // namespace WebCore |
| OLD | NEW |