Changeset 129038 in webkit


Ignore:
Timestamp:
Sep 19, 2012 1:35:19 PM (12 years ago)
Author:
jsbell@chromium.org
Message:

IndexedDB: Free up resources used by completed cursors earlier
https://bugs.webkit.org/show_bug.cgi?id=97023

Reviewed by Tony Chang.

Source/WebCore:

Prior to this patch, IDBCursor objects are kept around by their parent
IDBTransaction until the transaction finishes. It's possible to release
references to them earlier, when the cursor has been "run to the end",
as no further events will fire and all calls to continue() etc should fail.

This change tells the cursor it's done when "null" finally comes through in
the IDBRequest, and the cursor then lets transaction know it can be
forgotten.

The added test doesn't distinguish the new behavior, but does exercise
"finished" cursors and apparently we didn't have tests for these before.

Test: storage/indexeddb/cursor-finished.html

  • Modules/indexeddb/IDBCursor.cpp:

(WebCore::IDBCursor::close): Make idempotent; notify transaction.

  • Modules/indexeddb/IDBRequest.cpp:

(WebCore::IDBRequest::onSuccess): Tell cursor it's finished before releasing.

  • Modules/indexeddb/IDBTransaction.cpp:

(WebCore::IDBTransaction::OpenCursorNotifier::~OpenCursorNotifier):
(WebCore):
(WebCore::IDBTransaction::OpenCursorNotifier::cursorFinished): New method for explicit notification.

  • Modules/indexeddb/IDBTransaction.h:

(OpenCursorNotifier):

LayoutTests:

Test to exercise cursor methods after the cursor has been run to the end.

  • storage/indexeddb/cursor-finished-expected.txt: Added.
  • storage/indexeddb/cursor-finished.html: Added.
  • storage/indexeddb/resources/cursor-finished.js: Added.

(test):
(prepareDatabase):
(onDeleteSuccess):
(onUpgradeNeeded):
(onOpenSuccess):
(onCursorSuccess):

Location:
trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r129037 r129038  
     12012-09-19  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: Free up resources used by completed cursors earlier
     4        https://bugs.webkit.org/show_bug.cgi?id=97023
     5
     6        Reviewed by Tony Chang.
     7
     8        Test to exercise cursor methods after the cursor has been run to the end.
     9
     10        * storage/indexeddb/cursor-finished-expected.txt: Added.
     11        * storage/indexeddb/cursor-finished.html: Added.
     12        * storage/indexeddb/resources/cursor-finished.js: Added.
     13        (test):
     14        (prepareDatabase):
     15        (onDeleteSuccess):
     16        (onUpgradeNeeded):
     17        (onOpenSuccess):
     18        (onCursorSuccess):
     19
    1202012-09-19  David Grogan  <dgrogan@chromium.org>
    221
  • trunk/Source/WebCore/ChangeLog

    r129037 r129038  
     12012-09-19  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: Free up resources used by completed cursors earlier
     4        https://bugs.webkit.org/show_bug.cgi?id=97023
     5
     6        Reviewed by Tony Chang.
     7
     8        Prior to this patch, IDBCursor objects are kept around by their parent
     9        IDBTransaction until the transaction finishes. It's possible to release
     10        references to them earlier, when the cursor has been "run to the end",
     11        as no further events will fire and all calls to continue() etc should fail.
     12
     13        This change tells the cursor it's done when "null" finally comes through in
     14        the IDBRequest, and the cursor then lets transaction know it can be
     15        forgotten.
     16
     17        The added test doesn't distinguish the new behavior, but does exercise
     18        "finished" cursors and apparently we didn't have tests for these before.
     19
     20        Test: storage/indexeddb/cursor-finished.html
     21
     22        * Modules/indexeddb/IDBCursor.cpp:
     23        (WebCore::IDBCursor::close): Make idempotent; notify transaction.
     24        * Modules/indexeddb/IDBRequest.cpp:
     25        (WebCore::IDBRequest::onSuccess): Tell cursor it's finished before releasing.
     26        * Modules/indexeddb/IDBTransaction.cpp:
     27        (WebCore::IDBTransaction::OpenCursorNotifier::~OpenCursorNotifier):
     28        (WebCore):
     29        (WebCore::IDBTransaction::OpenCursorNotifier::cursorFinished): New method for explicit notification.
     30        * Modules/indexeddb/IDBTransaction.h:
     31        (OpenCursorNotifier):
     32
    1332012-09-19  David Grogan  <dgrogan@chromium.org>
    234
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp

    r128789 r129038  
    255255void IDBCursor::close()
    256256{
    257     ASSERT(m_request);
    258     m_request->finishCursor();
    259     m_request.clear();
     257    m_transactionNotifier.cursorFinished();
     258    if (m_request) {
     259        m_request->finishCursor();
     260        m_request.clear();
     261    }
    260262}
    261263
  • trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp

    r128789 r129038  
    380380{
    381381    m_result = IDBAny::create(value);
    382     m_pendingCursor.clear();
     382    if (m_pendingCursor) {
     383        m_pendingCursor->close();
     384        m_pendingCursor.clear();
     385    }
    383386    enqueueEvent(createSuccessEvent());
    384387}
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp

    r128533 r129038  
    233233IDBTransaction::OpenCursorNotifier::~OpenCursorNotifier()
    234234{
    235     m_transaction->unregisterOpenCursor(m_cursor);
     235    if (m_cursor)
     236        m_transaction->unregisterOpenCursor(m_cursor);
     237}
     238
     239void IDBTransaction::OpenCursorNotifier::cursorFinished()
     240{
     241    if (m_cursor) {
     242        m_transaction->unregisterOpenCursor(m_cursor);
     243        m_cursor = 0;
     244        m_transaction.clear();
     245    }
    236246}
    237247
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h

    r126254 r129038  
    8787        OpenCursorNotifier(PassRefPtr<IDBTransaction>, IDBCursor*);
    8888        ~OpenCursorNotifier();
     89        void cursorFinished();
    8990    private:
    9091        RefPtr<IDBTransaction> m_transaction;
Note: See TracChangeset for help on using the changeset viewer.