| 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 20 matching lines...) Expand all Loading... |
| 31 #include "IDBAny.h" | 31 #include "IDBAny.h" |
| 32 #include "IDBBindingUtilities.h" | 32 #include "IDBBindingUtilities.h" |
| 33 #include "IDBCallbacks.h" | 33 #include "IDBCallbacks.h" |
| 34 #include "IDBCursorBackendInterface.h" | 34 #include "IDBCursorBackendInterface.h" |
| 35 #include "IDBKey.h" | 35 #include "IDBKey.h" |
| 36 #include "IDBObjectStore.h" | 36 #include "IDBObjectStore.h" |
| 37 #include "IDBRequest.h" | 37 #include "IDBRequest.h" |
| 38 #include "IDBTracing.h" | 38 #include "IDBTracing.h" |
| 39 #include "IDBTransaction.h" | 39 #include "IDBTransaction.h" |
| 40 #include "ScriptExecutionContext.h" | 40 #include "ScriptExecutionContext.h" |
| 41 #include "SerializedScriptValue.h" |
| 41 | 42 |
| 42 namespace WebCore { | 43 namespace WebCore { |
| 43 | 44 |
| 44 PassRefPtr<IDBCursor> IDBCursor::create(PassRefPtr<IDBCursorBackendInterface> ba
ckend, Direction direction, IDBRequest* request, IDBAny* source, IDBTransaction*
transaction) | 45 PassRefPtr<IDBCursor> IDBCursor::create(PassRefPtr<IDBCursorBackendInterface> ba
ckend, Direction direction, IDBRequest* request, IDBAny* source, IDBTransaction*
transaction) |
| 45 { | 46 { |
| 46 return adoptRef(new IDBCursor(backend, direction, request, source, transacti
on)); | 47 return adoptRef(new IDBCursor(backend, direction, request, source, transacti
on)); |
| 47 } | 48 } |
| 48 | 49 |
| 49 const AtomicString& IDBCursor::directionNext() | 50 const AtomicString& IDBCursor::directionNext() |
| 50 { | 51 { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 m_backend->postSuccessHandlerCallback(); | 255 m_backend->postSuccessHandlerCallback(); |
| 255 } | 256 } |
| 256 | 257 |
| 257 void IDBCursor::close() | 258 void IDBCursor::close() |
| 258 { | 259 { |
| 259 ASSERT(m_request); | 260 ASSERT(m_request); |
| 260 m_request->finishCursor(); | 261 m_request->finishCursor(); |
| 261 m_request.clear(); | 262 m_request.clear(); |
| 262 } | 263 } |
| 263 | 264 |
| 264 void IDBCursor::setValueReady(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primary
Key, ScriptValue& value) | 265 void IDBCursor::setValueReady(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primary
Key, PassRefPtr<SerializedScriptValue> prpValue) |
| 265 { | 266 { |
| 266 m_currentKey = key; | 267 m_currentKey = key; |
| 267 m_currentPrimaryKey = primaryKey; | 268 m_currentPrimaryKey = primaryKey; |
| 268 | 269 |
| 270 RefPtr<SerializedScriptValue> value = prpValue; |
| 269 if (!isKeyCursor()) { | 271 if (!isKeyCursor()) { |
| 270 RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); | 272 RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); |
| 271 const IDBObjectStoreMetadata metadata = objectStore->metadata(); | 273 const IDBObjectStoreMetadata metadata = objectStore->metadata(); |
| 272 if (metadata.autoIncrement && !metadata.keyPath.isNull()) { | 274 if (metadata.autoIncrement && !metadata.keyPath.isNull()) { |
| 273 #ifndef NDEBUG | 275 #ifndef NDEBUG |
| 274 RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(v
alue, metadata.keyPath); | 276 RefPtr<IDBKey> expectedKey = createIDBKeyFromSerializedValueAndKeyPa
th(value, metadata.keyPath); |
| 275 ASSERT(!expectedKey || expectedKey->isEqual(m_currentPrimaryKey.get(
))); | 277 ASSERT(!expectedKey || expectedKey->isEqual(m_currentPrimaryKey.get(
))); |
| 276 #endif | 278 #endif |
| 277 bool injected = injectIDBKeyIntoScriptValue(m_currentPrimaryKey, val
ue, metadata.keyPath); | 279 RefPtr<SerializedScriptValue> valueAfterInjection = injectIDBKeyInto
SerializedValue(m_currentPrimaryKey, value, metadata.keyPath); |
| 280 ASSERT(valueAfterInjection); |
| 278 // FIXME: There is no way to report errors here. Move this into onSu
ccessWithContinuation so that we can abort the transaction there. See: https://b
ugs.webkit.org/show_bug.cgi?id=92278 | 281 // FIXME: There is no way to report errors here. Move this into onSu
ccessWithContinuation so that we can abort the transaction there. See: https://b
ugs.webkit.org/show_bug.cgi?id=92278 |
| 279 ASSERT_UNUSED(injected, injected); | 282 if (valueAfterInjection) |
| 283 value = valueAfterInjection; |
| 280 } | 284 } |
| 281 } | 285 } |
| 282 m_currentValue = IDBAny::create(value); | 286 m_currentValue = IDBAny::create(value.release()); |
| 283 | 287 |
| 284 m_gotValue = true; | 288 m_gotValue = true; |
| 285 m_valueIsDirty = true; | 289 m_valueIsDirty = true; |
| 286 } | 290 } |
| 287 | 291 |
| 288 PassRefPtr<IDBObjectStore> IDBCursor::effectiveObjectStore() | 292 PassRefPtr<IDBObjectStore> IDBCursor::effectiveObjectStore() |
| 289 { | 293 { |
| 290 if (m_source->type() == IDBAny::IDBObjectStoreType) | 294 if (m_source->type() == IDBAny::IDBObjectStoreType) |
| 291 return m_source->idbObjectStore(); | 295 return m_source->idbObjectStore(); |
| 292 RefPtr<IDBIndex> index = m_source->idbIndex(); | 296 RefPtr<IDBIndex> index = m_source->idbIndex(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 329 |
| 326 default: | 330 default: |
| 327 ec = NATIVE_TYPE_ERR; | 331 ec = NATIVE_TYPE_ERR; |
| 328 return IDBCursor::directionNext(); | 332 return IDBCursor::directionNext(); |
| 329 } | 333 } |
| 330 } | 334 } |
| 331 | 335 |
| 332 } // namespace WebCore | 336 } // namespace WebCore |
| 333 | 337 |
| 334 #endif // ENABLE(INDEXED_DATABASE) | 338 #endif // ENABLE(INDEXED_DATABASE) |
| OLD | NEW |