| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return prevunique; | 73 return prevunique; |
| 74 } | 74 } |
| 75 | 75 |
| 76 | 76 |
| 77 IDBCursor::IDBCursor(PassRefPtr<IDBCursorBackendInterface> backend, IndexedDB::C
ursorDirection direction, IDBRequest* request, IDBAny* source, IDBTransaction* t
ransaction) | 77 IDBCursor::IDBCursor(PassRefPtr<IDBCursorBackendInterface> backend, IndexedDB::C
ursorDirection direction, IDBRequest* request, IDBAny* source, IDBTransaction* t
ransaction) |
| 78 : m_backend(backend) | 78 : m_backend(backend) |
| 79 , m_request(request) | 79 , m_request(request) |
| 80 , m_direction(direction) | 80 , m_direction(direction) |
| 81 , m_source(source) | 81 , m_source(source) |
| 82 , m_transaction(transaction) | 82 , m_transaction(transaction) |
| 83 , m_transactionNotifier(transaction, this) | |
| 84 , m_gotValue(false) | 83 , m_gotValue(false) |
| 85 , m_keyDirty(true) | 84 , m_keyDirty(true) |
| 86 , m_primaryKeyDirty(true) | 85 , m_primaryKeyDirty(true) |
| 87 , m_valueDirty(true) | 86 , m_valueDirty(true) |
| 88 { | 87 { |
| 89 ASSERT(m_backend); | 88 ASSERT(m_backend); |
| 90 ASSERT(m_request); | 89 ASSERT(m_request); |
| 91 ASSERT(m_source->type() == IDBAny::IDBObjectStoreType || m_source->type() ==
IDBAny::IDBIndexType); | 90 ASSERT(m_source->type() == IDBAny::IDBObjectStoreType || m_source->type() ==
IDBAny::IDBIndexType); |
| 92 ASSERT(m_transaction); | 91 ASSERT(m_transaction); |
| 93 ScriptWrappable::init(this); | 92 ScriptWrappable::init(this); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 void IDBCursor::postSuccessHandlerCallback() | 266 void IDBCursor::postSuccessHandlerCallback() |
| 268 { | 267 { |
| 269 if (m_backend) | 268 if (m_backend) |
| 270 m_backend->postSuccessHandlerCallback(); | 269 m_backend->postSuccessHandlerCallback(); |
| 271 } | 270 } |
| 272 | 271 |
| 273 void IDBCursor::close() | 272 void IDBCursor::close() |
| 274 { | 273 { |
| 275 // The notifier may be the last reference to this cursor. | 274 // The notifier may be the last reference to this cursor. |
| 276 RefPtr<IDBCursor> protect(this); | 275 RefPtr<IDBCursor> protect(this); |
| 277 m_transactionNotifier.cursorFinished(); | 276 m_request.clear(); |
| 278 if (m_request) { | |
| 279 m_request->finishCursor(); | |
| 280 m_request.clear(); | |
| 281 } | |
| 282 m_backend.clear(); | 277 m_backend.clear(); |
| 283 } | 278 } |
| 284 | 279 |
| 280 void IDBCursor::checkForReferenceCycle() |
| 281 { |
| 282 // If this cursor and its request have the only references |
| 283 // to each other, then explicitly break the cycle. |
| 284 if (!m_request || m_request->getResultCursor() != this) |
| 285 return; |
| 286 |
| 287 if (!hasOneRef() || !m_request->hasOneRef()) |
| 288 return; |
| 289 |
| 290 m_request.clear(); |
| 291 } |
| 292 |
| 285 ScriptValue IDBCursor::key(ScriptExecutionContext* context) | 293 ScriptValue IDBCursor::key(ScriptExecutionContext* context) |
| 286 { | 294 { |
| 287 m_keyDirty = false; | 295 m_keyDirty = false; |
| 288 DOMRequestState requestState(context); | 296 DOMRequestState requestState(context); |
| 289 return idbKeyToScriptValue(&requestState, m_key); | 297 return idbKeyToScriptValue(&requestState, m_key); |
| 290 } | 298 } |
| 291 | 299 |
| 292 ScriptValue IDBCursor::primaryKey(ScriptExecutionContext* context) | 300 ScriptValue IDBCursor::primaryKey(ScriptExecutionContext* context) |
| 293 { | 301 { |
| 294 m_primaryKeyDirty = false; | 302 m_primaryKeyDirty = false; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 case IndexedDB::CursorPrevNoDuplicate: | 386 case IndexedDB::CursorPrevNoDuplicate: |
| 379 return IDBCursor::directionPrevUnique(); | 387 return IDBCursor::directionPrevUnique(); |
| 380 | 388 |
| 381 default: | 389 default: |
| 382 ASSERT_NOT_REACHED(); | 390 ASSERT_NOT_REACHED(); |
| 383 return IDBCursor::directionNext(); | 391 return IDBCursor::directionNext(); |
| 384 } | 392 } |
| 385 } | 393 } |
| 386 | 394 |
| 387 } // namespace WebCore | 395 } // namespace WebCore |
| OLD | NEW |