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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 IDBCursor::~IDBCursor() | 96 IDBCursor::~IDBCursor() |
97 { | 97 { |
98 } | 98 } |
99 | 99 |
100 PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value,
ExceptionState& exceptionState) | 100 PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value,
ExceptionState& exceptionState) |
101 { | 101 { |
102 IDB_TRACE("IDBCursor::update"); | 102 IDB_TRACE("IDBCursor::update"); |
103 | 103 |
104 if (!m_gotValue) { | 104 if (!m_gotValue) { |
105 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue
ErrorMessage); | 105 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue
ErrorMessage); |
106 return 0; | 106 return nullptr; |
107 } | 107 } |
108 if (isKeyCursor()) { | 108 if (isKeyCursor()) { |
109 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu
rsorErrorMessage); | 109 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu
rsorErrorMessage); |
110 return 0; | 110 return nullptr; |
111 } | 111 } |
112 if (isDeleted()) { | 112 if (isDeleted()) { |
113 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD
eletedErrorMessage); | 113 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD
eletedErrorMessage); |
114 return 0; | 114 return nullptr; |
115 } | 115 } |
116 if (m_transaction->isFinished()) { | 116 if (m_transaction->isFinished()) { |
117 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 117 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
118 return 0; | 118 return nullptr; |
119 } | 119 } |
120 if (!m_transaction->isActive()) { | 120 if (!m_transaction->isActive()) { |
121 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 121 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
122 return 0; | 122 return nullptr; |
123 } | 123 } |
124 if (m_transaction->isReadOnly()) { | 124 if (m_transaction->isReadOnly()) { |
125 exceptionState.throwDOMException(ReadOnlyError, "The record may not be u
pdated inside a read-only transaction."); | 125 exceptionState.throwDOMException(ReadOnlyError, "The record may not be u
pdated inside a read-only transaction."); |
126 return 0; | 126 return nullptr; |
127 } | 127 } |
128 | 128 |
129 RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); | 129 RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); |
130 const IDBKeyPath& keyPath = objectStore->metadata().keyPath; | 130 const IDBKeyPath& keyPath = objectStore->metadata().keyPath; |
131 const bool usesInLineKeys = !keyPath.isNull(); | 131 const bool usesInLineKeys = !keyPath.isNull(); |
132 if (usesInLineKeys) { | 132 if (usesInLineKeys) { |
133 RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(m_requ
est->requestState(), value, keyPath); | 133 RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(m_requ
est->requestState(), value, keyPath); |
134 if (!keyPathKey || !keyPathKey->isEqual(m_primaryKey.get())) { | 134 if (!keyPathKey || !keyPathKey->isEqual(m_primaryKey.get())) { |
135 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."); | 135 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."); |
136 return 0; | 136 return nullptr; |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 return objectStore->put(WebIDBDatabase::CursorUpdate, IDBAny::create(this),
state, value, m_primaryKey, exceptionState); | 140 return objectStore->put(WebIDBDatabase::CursorUpdate, IDBAny::create(this),
state, value, m_primaryKey, exceptionState); |
141 } | 141 } |
142 | 142 |
143 void IDBCursor::advance(unsigned long count, ExceptionState& exceptionState) | 143 void IDBCursor::advance(unsigned long count, ExceptionState& exceptionState) |
144 { | 144 { |
145 IDB_TRACE("IDBCursor::advance"); | 145 IDB_TRACE("IDBCursor::advance"); |
146 if (!count) { | 146 if (!count) { |
(...skipping 20 matching lines...) Expand all Loading... |
167 | 167 |
168 m_request->setPendingCursor(this); | 168 m_request->setPendingCursor(this); |
169 m_gotValue = false; | 169 m_gotValue = false; |
170 m_backend->advance(count, WebIDBCallbacksImpl::create(m_request).leakPtr()); | 170 m_backend->advance(count, WebIDBCallbacksImpl::create(m_request).leakPtr()); |
171 } | 171 } |
172 | 172 |
173 void IDBCursor::continueFunction(ExecutionContext* context, const ScriptValue& k
eyValue, ExceptionState& exceptionState) | 173 void IDBCursor::continueFunction(ExecutionContext* context, const ScriptValue& k
eyValue, ExceptionState& exceptionState) |
174 { | 174 { |
175 IDB_TRACE("IDBCursor::continue"); | 175 IDB_TRACE("IDBCursor::continue"); |
176 DOMRequestState requestState(context); | 176 DOMRequestState requestState(context); |
177 RefPtr<IDBKey> key = keyValue.isUndefined() || keyValue.isNull() ? 0 : scrip
tValueToIDBKey(&requestState, keyValue); | 177 RefPtr<IDBKey> key = keyValue.isUndefined() || keyValue.isNull() ? nullptr :
scriptValueToIDBKey(&requestState, keyValue); |
178 if (key && !key->isValid()) { | 178 if (key && !key->isValid()) { |
179 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 179 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
180 return; | 180 return; |
181 } | 181 } |
182 continueFunction(key.release(), 0, exceptionState); | 182 continueFunction(key.release(), nullptr, exceptionState); |
183 } | 183 } |
184 | 184 |
185 void IDBCursor::continuePrimaryKey(ExecutionContext* context, const ScriptValue&
keyValue, const ScriptValue& primaryKeyValue, ExceptionState& exceptionState) | 185 void IDBCursor::continuePrimaryKey(ExecutionContext* context, const ScriptValue&
keyValue, const ScriptValue& primaryKeyValue, ExceptionState& exceptionState) |
186 { | 186 { |
187 IDB_TRACE("IDBCursor::continuePrimaryKey"); | 187 IDB_TRACE("IDBCursor::continuePrimaryKey"); |
188 DOMRequestState requestState(context); | 188 DOMRequestState requestState(context); |
189 RefPtr<IDBKey> key = scriptValueToIDBKey(&requestState, keyValue); | 189 RefPtr<IDBKey> key = scriptValueToIDBKey(&requestState, keyValue); |
190 RefPtr<IDBKey> primaryKey = scriptValueToIDBKey(&requestState, primaryKeyVal
ue); | 190 RefPtr<IDBKey> primaryKey = scriptValueToIDBKey(&requestState, primaryKeyVal
ue); |
191 if (!key->isValid() || !primaryKey->isValid()) { | 191 if (!key->isValid() || !primaryKey->isValid()) { |
192 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 192 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 m_request->setPendingCursor(this); | 243 m_request->setPendingCursor(this); |
244 m_gotValue = false; | 244 m_gotValue = false; |
245 m_backend->continueFunction(key, primaryKey, WebIDBCallbacksImpl::create(m_r
equest).leakPtr()); | 245 m_backend->continueFunction(key, primaryKey, WebIDBCallbacksImpl::create(m_r
equest).leakPtr()); |
246 } | 246 } |
247 | 247 |
248 PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ExecutionContext* context, Exce
ptionState& exceptionState) | 248 PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ExecutionContext* context, Exce
ptionState& exceptionState) |
249 { | 249 { |
250 IDB_TRACE("IDBCursor::delete"); | 250 IDB_TRACE("IDBCursor::delete"); |
251 if (m_transaction->isFinished()) { | 251 if (m_transaction->isFinished()) { |
252 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 252 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
253 return 0; | 253 return nullptr; |
254 } | 254 } |
255 if (!m_transaction->isActive()) { | 255 if (!m_transaction->isActive()) { |
256 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 256 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
257 return 0; | 257 return nullptr; |
258 } | 258 } |
259 if (m_transaction->isReadOnly()) { | 259 if (m_transaction->isReadOnly()) { |
260 exceptionState.throwDOMException(ReadOnlyError, "The record may not be d
eleted inside a read-only transaction."); | 260 exceptionState.throwDOMException(ReadOnlyError, "The record may not be d
eleted inside a read-only transaction."); |
261 return 0; | 261 return nullptr; |
262 } | 262 } |
263 | 263 |
264 if (!m_gotValue) { | 264 if (!m_gotValue) { |
265 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue
ErrorMessage); | 265 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue
ErrorMessage); |
266 return 0; | 266 return nullptr; |
267 } | 267 } |
268 if (isKeyCursor()) { | 268 if (isKeyCursor()) { |
269 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu
rsorErrorMessage); | 269 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu
rsorErrorMessage); |
270 return 0; | 270 return nullptr; |
271 } | 271 } |
272 if (isDeleted()) { | 272 if (isDeleted()) { |
273 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD
eletedErrorMessage); | 273 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD
eletedErrorMessage); |
274 return 0; | 274 return nullptr; |
275 } | 275 } |
276 | 276 |
277 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(m_primaryKey, exceptionStat
e); | 277 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(m_primaryKey, exceptionStat
e); |
278 ASSERT(!exceptionState.hadException()); | 278 ASSERT(!exceptionState.hadException()); |
279 | 279 |
280 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); | 280 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); |
281 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject
Store()->id(), keyRange.release(), WebIDBCallbacksImpl::create(request).leakPtr(
)); | 281 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject
Store()->id(), keyRange.release(), WebIDBCallbacksImpl::create(request).leakPtr(
)); |
282 return request.release(); | 282 return request.release(); |
283 } | 283 } |
284 | 284 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 case WebIDBCursor::PrevNoDuplicate: | 411 case WebIDBCursor::PrevNoDuplicate: |
412 return IDBCursor::directionPrevUnique(); | 412 return IDBCursor::directionPrevUnique(); |
413 | 413 |
414 default: | 414 default: |
415 ASSERT_NOT_REACHED(); | 415 ASSERT_NOT_REACHED(); |
416 return IDBCursor::directionNext(); | 416 return IDBCursor::directionNext(); |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 } // namespace WebCore | 420 } // namespace WebCore |
OLD | NEW |