Changeset 86422 in webkit


Ignore:
Timestamp:
May 13, 2011 3:21:02 AM (13 years ago)
Author:
hans@chromium.org
Message:

2011-05-05 Hans Wennborg <hans@chromium.org>

Reviewed by Steve Block.

IndexedDB: Transaction rollback prevented by open SQLite statement
https://bugs.webkit.org/show_bug.cgi?id=60032

Add test for veryfing that transaction roll-back works, even with a
previously opened cursor still around.

  • storage/indexeddb/transaction-rollback-expected.txt: Added.
  • storage/indexeddb/transaction-rollback.html: Added.

2011-05-05 Hans Wennborg <hans@chromium.org>

Reviewed by Steve Block.

IndexedDB: Transaction rollback prevented by open SQLite statement
https://bugs.webkit.org/show_bug.cgi?id=60032

Let the IDBTransactionbackendImpl keep track of all open cursors, and
"close" them (i.e. finalizing the underlying SQLiteStatement) before
committing or rolling back the transaction. This fixes the problem
with opened cursors preventing transaction rollback.

Test: storage/indexeddb/transaction-rollback.html

  • storage/IDBBackingStore.h:
  • storage/IDBCursorBackendImpl.cpp: (WebCore::IDBCursorBackendImpl::IDBCursorBackendImpl): (WebCore::IDBCursorBackendImpl::~IDBCursorBackendImpl): (WebCore::IDBCursorBackendImpl::close):
  • storage/IDBCursorBackendImpl.h:
  • storage/IDBLevelDBBackingStore.cpp:
  • storage/IDBSQLiteBackingStore.cpp:
  • storage/IDBTransactionBackendImpl.cpp: (WebCore::IDBTransactionBackendImpl::abort): (WebCore::IDBTransactionBackendImpl::registerOpenCursor): (WebCore::IDBTransactionBackendImpl::unregisterOpenCursor): (WebCore::IDBTransactionBackendImpl::commit): (WebCore::IDBTransactionBackendImpl::closeOpenCursors):
  • storage/IDBTransactionBackendImpl.h:
  • storage/IDBTransactionBackendInterface.h: (WebCore::IDBTransactionBackendInterface::registerOpenCursor): (WebCore::IDBTransactionBackendInterface::unregisterOpenCursor):

2011-05-05 Hans Wennborg <hans@chromium.org>

Reviewed by Steve Block.

IndexedDB: Transaction rollback prevented by open SQLite statement
https://bugs.webkit.org/show_bug.cgi?id=60032

Implement two new methods in IDBTransactionBackendInterface.

  • src/IDBTransactionBackendProxy.cpp: (WebKit::IDBTransactionBackendProxy::registerOpenCursor): (WebKit::IDBTransactionBackendProxy::unregisterOpenCursor):
  • src/IDBTransactionBackendProxy.h:
Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r86420 r86422  
     12011-05-05  Hans Wennborg  <hans@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        IndexedDB: Transaction rollback prevented by open SQLite statement
     6        https://bugs.webkit.org/show_bug.cgi?id=60032
     7
     8        Add test for veryfing that transaction roll-back works, even with a
     9        previously opened cursor still around.
     10
     11        * storage/indexeddb/transaction-rollback-expected.txt: Added.
     12        * storage/indexeddb/transaction-rollback.html: Added.
     13
    1142011-05-13  Sergio Villar Senin  <svillar@igalia.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r86418 r86422  
     12011-05-05  Hans Wennborg  <hans@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        IndexedDB: Transaction rollback prevented by open SQLite statement
     6        https://bugs.webkit.org/show_bug.cgi?id=60032
     7
     8        Let the IDBTransactionbackendImpl keep track of all open cursors, and
     9        "close" them (i.e. finalizing the underlying SQLiteStatement) before
     10        committing or rolling back the transaction. This fixes the problem
     11        with opened cursors preventing transaction rollback.
     12
     13        Test: storage/indexeddb/transaction-rollback.html
     14
     15        * storage/IDBBackingStore.h:
     16        * storage/IDBCursorBackendImpl.cpp:
     17        (WebCore::IDBCursorBackendImpl::IDBCursorBackendImpl):
     18        (WebCore::IDBCursorBackendImpl::~IDBCursorBackendImpl):
     19        (WebCore::IDBCursorBackendImpl::close):
     20        * storage/IDBCursorBackendImpl.h:
     21        * storage/IDBLevelDBBackingStore.cpp:
     22        * storage/IDBSQLiteBackingStore.cpp:
     23        * storage/IDBTransactionBackendImpl.cpp:
     24        (WebCore::IDBTransactionBackendImpl::abort):
     25        (WebCore::IDBTransactionBackendImpl::registerOpenCursor):
     26        (WebCore::IDBTransactionBackendImpl::unregisterOpenCursor):
     27        (WebCore::IDBTransactionBackendImpl::commit):
     28        (WebCore::IDBTransactionBackendImpl::closeOpenCursors):
     29        * storage/IDBTransactionBackendImpl.h:
     30        * storage/IDBTransactionBackendInterface.h:
     31        (WebCore::IDBTransactionBackendInterface::registerOpenCursor):
     32        (WebCore::IDBTransactionBackendInterface::unregisterOpenCursor):
     33
    1342011-05-13  Patrick Gansterer  <paroga@webkit.org>
    235
  • trunk/Source/WebCore/storage/IDBBackingStore.h

    r83443 r86422  
    9292        virtual PassRefPtr<ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() = 0;
    9393        virtual int64_t indexDataId() = 0;
    94         virtual ~Cursor() {};
     94        virtual void close() = 0;
     95        virtual ~Cursor() { };
    9596    };
    9697
  • trunk/Source/WebCore/storage/IDBCursorBackendImpl.cpp

    r80220 r86422  
    4949    , m_objectStore(objectStore)
    5050{
     51    m_transaction->registerOpenCursor(this);
    5152}
    5253
    5354IDBCursorBackendImpl::~IDBCursorBackendImpl()
    5455{
     56    m_transaction->unregisterOpenCursor(this);
    5557}
    5658
     
    121123}
    122124
     125void IDBCursorBackendImpl::close()
     126{
     127    if (m_cursor)
     128        m_cursor->close();
     129}
     130
    123131} // namespace WebCore
    124132
  • trunk/Source/WebCore/storage/IDBCursorBackendImpl.h

    r80315 r86422  
    6262    virtual void continueFunction(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, ExceptionCode&);
    6363    virtual void deleteFunction(PassRefPtr<IDBCallbacks>, ExceptionCode&);
     64    void close();
    6465
    6566private:
  • trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp

    r85122 r86422  
    813813    virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() = 0; // FIXME: I don't think this is actually used, so drop it.
    814814    virtual int64_t indexDataId() = 0;
     815    virtual void close() { }
    815816
    816817    virtual bool loadCurrentRow() = 0;
  • trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp

    r83443 r86422  
    709709    virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() = 0;
    710710    virtual int64_t indexDataId() = 0;
     711    virtual void close() { m_query.finalize(); }
    711712
    712713    virtual void loadCurrentRow() = 0;
  • trunk/Source/WebCore/storage/IDBTransactionBackendImpl.cpp

    r80315 r86422  
    3030
    3131#include "IDBBackingStore.h"
     32#include "IDBCursorBackendImpl.h"
    3233#include "IDBDatabaseBackendImpl.h"
    3334#include "IDBDatabaseException.h"
     
    114115    m_taskTimer.stop();
    115116    m_taskEventTimer.stop();
     117
     118    closeOpenCursors();
    116119    m_transaction->rollback();
    117120
     
    129132}
    130133
     134void IDBTransactionBackendImpl::registerOpenCursor(IDBCursorBackendImpl* cursor)
     135{
     136    m_openCursors.add(cursor);
     137}
     138
     139void IDBTransactionBackendImpl::unregisterOpenCursor(IDBCursorBackendImpl* cursor)
     140{
     141    m_openCursors.remove(cursor);
     142}
     143
    131144void IDBTransactionBackendImpl::didCompleteTaskEvents()
    132145{
     
    167180
    168181    m_state = Finished;
     182    closeOpenCursors();
    169183    m_transaction->commit();
    170184    m_callbacks->onComplete();
     
    211225}
    212226
     227void IDBTransactionBackendImpl::closeOpenCursors()
     228{
     229    for (HashSet<IDBCursorBackendImpl*>::iterator i = m_openCursors.begin(); i != m_openCursors.end(); ++i)
     230        (*i)->close();
     231    m_openCursors.clear();
     232}
     233
    213234};
    214235
  • trunk/Source/WebCore/storage/IDBTransactionBackendImpl.h

    r80315 r86422  
    3535#include "Timer.h"
    3636#include <wtf/Deque.h>
     37#include <wtf/HashSet.h>
    3738#include <wtf/RefPtr.h>
    3839
     
    5253    virtual void abort();
    5354    virtual void setCallbacks(IDBTransactionCallbacks* callbacks) { m_callbacks = callbacks; }
     55    virtual void registerOpenCursor(IDBCursorBackendImpl*);
     56    virtual void unregisterOpenCursor(IDBCursorBackendImpl*);
    5457
    5558    void run();
     
    7073    void taskTimerFired(Timer<IDBTransactionBackendImpl>*);
    7174    void taskEventTimerFired(Timer<IDBTransactionBackendImpl>*);
     75    void closeOpenCursors();
    7276
    7377    RefPtr<DOMStringList> m_objectStoreNames;
     
    8892    Timer<IDBTransactionBackendImpl> m_taskEventTimer;
    8993    int m_pendingEvents;
     94
     95    HashSet<IDBCursorBackendImpl*> m_openCursors;
    9096};
    9197
  • trunk/Source/WebCore/storage/IDBTransactionBackendInterface.h

    r85713 r86422  
    3737namespace WebCore {
    3838
     39class IDBCursorBackendImpl;
    3940class IDBObjectStoreBackendInterface;
    4041class IDBTransactionCallbacks;
     
    5455    virtual void abort() = 0;
    5556    virtual void setCallbacks(IDBTransactionCallbacks*) = 0;
     57    virtual void registerOpenCursor(IDBCursorBackendImpl*) = 0;
     58    virtual void unregisterOpenCursor(IDBCursorBackendImpl*) = 0;
    5659};
    5760
  • trunk/Source/WebKit/chromium/ChangeLog

    r86418 r86422  
     12011-05-05  Hans Wennborg  <hans@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        IndexedDB: Transaction rollback prevented by open SQLite statement
     6        https://bugs.webkit.org/show_bug.cgi?id=60032
     7
     8        Implement two new methods in IDBTransactionBackendInterface.
     9
     10        * src/IDBTransactionBackendProxy.cpp:
     11        (WebKit::IDBTransactionBackendProxy::registerOpenCursor):
     12        (WebKit::IDBTransactionBackendProxy::unregisterOpenCursor):
     13        * src/IDBTransactionBackendProxy.h:
     14
    1152011-05-13  Patrick Gansterer  <paroga@webkit.org>
    216
  • trunk/Source/WebKit/chromium/src/IDBTransactionBackendProxy.cpp

    r86067 r86422  
    7373}
    7474
     75void IDBTransactionBackendProxy::registerOpenCursor(WebCore::IDBCursorBackendImpl*)
     76{
     77    ASSERT_NOT_REACHED();
     78}
     79
     80void IDBTransactionBackendProxy::unregisterOpenCursor(WebCore::IDBCursorBackendImpl*)
     81{
     82    ASSERT_NOT_REACHED();
     83}
     84
    7585bool IDBTransactionBackendProxy::scheduleTask(PassOwnPtr<ScriptExecutionContext::Task>, PassOwnPtr<ScriptExecutionContext::Task>)
    7686{
  • trunk/Source/WebKit/chromium/src/IDBTransactionBackendProxy.h

    r82917 r86422  
    4848    virtual void didCompleteTaskEvents();
    4949    virtual void setCallbacks(WebCore::IDBTransactionCallbacks*);
     50    virtual void registerOpenCursor(WebCore::IDBCursorBackendImpl*);
     51    virtual void unregisterOpenCursor(WebCore::IDBCursorBackendImpl*);
    5052
    5153    WebIDBTransaction* getWebIDBTransaction() const { return m_webIDBTransaction.get(); }
Note: See TracChangeset for help on using the changeset viewer.