Changeset 130095 in webkit


Ignore:
Timestamp:
Oct 1, 2012, 4:14:13 PM (13 years ago)
Author:
jsbell@chromium.org
Message:

Source/WebCore: IndexedDB: Fire error rather than raising on request creation if transaction aborts asynchronously.
https://bugs.webkit.org/show_bug.cgi?id=93054

Reviewed by Tony Chang.

All IDB data operations are asynchronous, producing IDBRequest objects. This was implemented
by passing all data from the front-end to the back-end synchronously, and synchronously
returning an exception code back if the request was invalid. Previous changes have moved
request validation to the front-end except for the case of the back-end transaction having
asynchronously aborted in the mean time.

To eliminate that case (which would allow front-end to back-end communication to be
asynchronous in multi-process ports), change from returning an exception code to relying on
the front-end to abort the request when the abort event finally arrives.

The difference would be noticeable in scripts - in a multi-process environment:

var request1 = store.get(0);
request1.onerror = errorHandler; (A)
(B)
var request2 = store.get(0); (C)
request2.onerror = errorHandler;
(D)

If the transaction back-end were to asynchronously abort at exactly point (B), then prior to
this patch an exception would be thrown at (C). With this patch, no exception but (D) would
fire, same as (A).

The back-end explicitly fires an error callback as well, as intermediate layers may rely on
this to stop tracking the pending callback.

No new layout tests - change is not observable in single-process ports.
Added webkit_unit_test IDBRequestTest.AbortErrorAfterAbort to verify that IDBRequest
is resilient to this pattern, but it was previous.

  • Modules/indexeddb/IDBCursor.cpp:

(WebCore::IDBCursor::advance): Back end should never fail a request.
(WebCore::IDBCursor::continueFunction): Ditto.
(WebCore::IDBCursor::deleteFunction): Ditto, and also move "is key cursor" test
here from back-end.

  • Modules/indexeddb/IDBCursorBackendImpl.cpp:

(WebCore::IDBCursorBackendImpl::continueFunction): Change from EC to firing error.
(WebCore::IDBCursorBackendImpl::advance): Ditto.
(WebCore::IDBCursorBackendImpl::deleteFunction): Ditto, and remove test moved to FE.
(WebCore::IDBCursorBackendImpl::prefetchContinue): Ditto.

  • Modules/indexeddb/IDBDatabaseError.cpp:

(WebCore::IDBDatabaseError::create): Add overload that looks up message via code.
(WebCore::IDBDatabaseError::IDBDatabaseError): Look up message via exception table.

  • Modules/indexeddb/IDBDatabaseException.h: Add getErrorDescription.
  • Modules/indexeddb/IDBDatabaseException.cpp: Implementation of getErrorDescription.
  • Modules/indexeddb/IDBIndex.cpp:

(WebCore::IDBIndex::openCursor): Back end should never fail a request.
(WebCore::IDBIndex::count): Ditto.
(WebCore::IDBIndex::openKeyCursor): Ditto.
(WebCore::IDBIndex::get): Ditto.
(WebCore::IDBIndex::getKey): Ditto.

  • Modules/indexeddb/IDBIndexBackendImpl.cpp:

(WebCore::IDBIndexBackendImpl::openCursor): Change from EC to firing error.
(WebCore::IDBIndexBackendImpl::openKeyCursor): Ditto.
(WebCore::IDBIndexBackendImpl::count): Ditto.
(WebCore::IDBIndexBackendImpl::get): Ditto.
(WebCore::IDBIndexBackendImpl::getKey): Ditto.

  • Modules/indexeddb/IDBObjectStore.cpp:

(WebCore::IDBObjectStore::get): Back end should never fail a request.
(WebCore::IDBObjectStore::put): Ditto.
(WebCore::IDBObjectStore::deleteFunction): Ditto.
(WebCore::IDBObjectStore::clear): Ditto.
(WebCore): Ditto.
(WebCore::IDBObjectStore::openCursor): Ditto.
(WebCore::IDBObjectStore::count): Ditto.

  • Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:

(WebCore::IDBObjectStoreBackendImpl::get): Change from EC to firing error.
(WebCore::IDBObjectStoreBackendImpl::putWithIndexKeys): Ditto.
(WebCore):
(WebCore::IDBObjectStoreBackendImpl::deleteFunction): Ditto.
(WebCore::IDBObjectStoreBackendImpl::clear): Ditto.
(WebCore::IDBObjectStoreBackendImpl::openCursor): Ditto.
(WebCore::IDBObjectStoreBackendImpl::count): Ditto.

Source/WebKit/chromium: IndexedDB: Move onSuccess(IDBDatabaseBackendInterface) to IDBOpenDBRequest
https://bugs.webkit.org/show_bug.cgi?id=94757

Reviewed by Tony Chang.

  • tests/IDBRequestTest.cpp: Ensure IDBRequest can handle Error after abort.

(WebCore::TEST): Added AbortAfter

Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r130093 r130095  
     12012-10-01  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: Fire error rather than raising on request creation if transaction aborts asynchronously.
     4        https://bugs.webkit.org/show_bug.cgi?id=93054
     5
     6        Reviewed by Tony Chang.
     7
     8        All IDB data operations are asynchronous, producing IDBRequest objects. This was implemented
     9        by passing all data from the front-end to the back-end synchronously, and synchronously
     10        returning an exception code back if the request was invalid. Previous changes have moved
     11        request validation to the front-end except for the case of the back-end transaction having
     12        asynchronously aborted in the mean time.
     13
     14        To eliminate that case (which would allow front-end to back-end communication to be
     15        asynchronous in multi-process ports), change from returning an exception code to relying on
     16        the front-end to abort the request when the abort event finally arrives.
     17
     18        The difference would be noticeable in scripts - in a multi-process environment:
     19
     20        var request1 = store.get(0);
     21        request1.onerror = errorHandler; // (A)
     22        // (B)
     23        var request2 = store.get(0); // (C)
     24        request2.onerror = errorHandler; // (D)
     25
     26        If the transaction back-end were to asynchronously abort at exactly point (B), then prior to
     27        this patch an exception would be thrown at (C). With this patch, no exception but (D) would
     28        fire, same as (A).
     29
     30        The back-end explicitly fires an error callback as well, as intermediate layers may rely on
     31        this to stop tracking the pending callback.
     32
     33        No new layout tests - change is not observable in single-process ports.
     34        Added webkit_unit_test IDBRequestTest.AbortErrorAfterAbort to verify that IDBRequest
     35        is resilient to this pattern, but it was previous.
     36
     37        * Modules/indexeddb/IDBCursor.cpp:
     38        (WebCore::IDBCursor::advance): Back end should never fail a request.
     39        (WebCore::IDBCursor::continueFunction): Ditto.
     40        (WebCore::IDBCursor::deleteFunction): Ditto, and also move "is key cursor" test
     41        here from back-end.
     42        * Modules/indexeddb/IDBCursorBackendImpl.cpp:
     43        (WebCore::IDBCursorBackendImpl::continueFunction): Change from EC to firing error.
     44        (WebCore::IDBCursorBackendImpl::advance): Ditto.
     45        (WebCore::IDBCursorBackendImpl::deleteFunction): Ditto, and remove test moved to FE.
     46        (WebCore::IDBCursorBackendImpl::prefetchContinue): Ditto.
     47        * Modules/indexeddb/IDBDatabaseError.cpp:
     48        (WebCore::IDBDatabaseError::create): Add overload that looks up message via code.
     49        (WebCore::IDBDatabaseError::IDBDatabaseError): Look up message via exception table.
     50        * Modules/indexeddb/IDBDatabaseException.h: Add getErrorDescription.
     51        * Modules/indexeddb/IDBDatabaseException.cpp: Implementation of getErrorDescription.
     52        * Modules/indexeddb/IDBIndex.cpp:
     53        (WebCore::IDBIndex::openCursor): Back end should never fail a request.
     54        (WebCore::IDBIndex::count): Ditto.
     55        (WebCore::IDBIndex::openKeyCursor): Ditto.
     56        (WebCore::IDBIndex::get): Ditto.
     57        (WebCore::IDBIndex::getKey): Ditto.
     58        * Modules/indexeddb/IDBIndexBackendImpl.cpp:
     59        (WebCore::IDBIndexBackendImpl::openCursor): Change from EC to firing error.
     60        (WebCore::IDBIndexBackendImpl::openKeyCursor): Ditto.
     61        (WebCore::IDBIndexBackendImpl::count): Ditto.
     62        (WebCore::IDBIndexBackendImpl::get): Ditto.
     63        (WebCore::IDBIndexBackendImpl::getKey): Ditto.
     64        * Modules/indexeddb/IDBObjectStore.cpp:
     65        (WebCore::IDBObjectStore::get): Back end should never fail a request.
     66        (WebCore::IDBObjectStore::put): Ditto.
     67        (WebCore::IDBObjectStore::deleteFunction): Ditto.
     68        (WebCore::IDBObjectStore::clear): Ditto.
     69        (WebCore): Ditto.
     70        (WebCore::IDBObjectStore::openCursor): Ditto.
     71        (WebCore::IDBObjectStore::count): Ditto.
     72        * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
     73        (WebCore::IDBObjectStoreBackendImpl::get): Change from EC to firing error.
     74        (WebCore::IDBObjectStoreBackendImpl::putWithIndexKeys): Ditto.
     75        (WebCore):
     76        (WebCore::IDBObjectStoreBackendImpl::deleteFunction): Ditto.
     77        (WebCore::IDBObjectStoreBackendImpl::clear): Ditto.
     78        (WebCore::IDBObjectStoreBackendImpl::openCursor): Ditto.
     79        (WebCore::IDBObjectStoreBackendImpl::count): Ditto.
     80
    1812012-10-01  Ryosuke Niwa  <rniwa@webkit.org>
    282
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp

    r129038 r130095  
    177177    m_gotValue = false;
    178178    m_backend->advance(count, m_request, ec);
    179     if (ec)
    180         m_request->markEarlyDeath();
     179    ASSERT(!ec);
    181180}
    182181
     
    219218    m_gotValue = false;
    220219    m_backend->continueFunction(key, m_request, ec);
    221     if (ec)
    222         m_request->markEarlyDeath();
     220    ASSERT(!ec);
    223221}
    224222
     
    235233    }
    236234
    237     if (!m_gotValue) {
     235    if (!m_gotValue || isKeyCursor()) {
    238236        ec = IDBDatabaseException::IDB_INVALID_STATE_ERR;
    239237        return 0;
     
    241239    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
    242240    m_backend->deleteFunction(request, ec);
    243     if (ec) {
    244         request->markEarlyDeath();
    245         return 0;
    246     }
     241    ASSERT(!ec);
    247242    return request.release();
    248243}
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.cpp

    r125728 r130095  
    6464}
    6565
    66 void IDBCursorBackendImpl::continueFunction(PassRefPtr<IDBKey> prpKey, PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode& ec)
     66void IDBCursorBackendImpl::continueFunction(PassRefPtr<IDBKey> prpKey, PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode&)
    6767{
    6868    IDB_TRACE("IDBCursorBackendImpl::continue");
    69 
    70     if (!m_transaction->scheduleTask(m_taskType, createCallbackTask(&IDBCursorBackendImpl::continueFunctionInternal, this, prpKey, prpCallbacks)))
    71         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
    72 }
    73 
    74 void IDBCursorBackendImpl::advance(unsigned long count, PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode& ec)
     69    RefPtr<IDBCallbacks> callbacks = prpCallbacks;
     70
     71    if (!m_transaction->scheduleTask(m_taskType, createCallbackTask(&IDBCursorBackendImpl::continueFunctionInternal, this, prpKey, callbacks)))
     72        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
     73}
     74
     75void IDBCursorBackendImpl::advance(unsigned long count, PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode&)
    7576{
    7677    IDB_TRACE("IDBCursorBackendImpl::advance");
    77 
    78     if (!m_transaction->scheduleTask(createCallbackTask(&IDBCursorBackendImpl::advanceInternal, this, count, prpCallbacks)))
    79         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     78    RefPtr<IDBCallbacks> callbacks = prpCallbacks;
     79
     80    if (!m_transaction->scheduleTask(createCallbackTask(&IDBCursorBackendImpl::advanceInternal, this, count, callbacks)))
     81        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    8082}
    8183
     
    108110}
    109111
    110 void IDBCursorBackendImpl::deleteFunction(PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode& ec)
     112void IDBCursorBackendImpl::deleteFunction(PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode&)
    111113{
    112114    IDB_TRACE("IDBCursorBackendImpl::delete");
    113115    ASSERT(m_transaction->mode() != IDBTransaction::READ_ONLY);
    114116
    115     if (!m_cursor || m_cursorType == IndexKeyCursor) {
    116         ec = IDBDatabaseException::IDB_INVALID_STATE_ERR;
    117         return;
    118     }
    119 
     117    ExceptionCode ec = 0;
    120118    RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(m_cursor->primaryKey(), ec);
    121119    ASSERT(!ec);
    122120
    123121    m_objectStore->deleteFunction(keyRange.release(), prpCallbacks, m_transaction.get(), ec);
    124 }
    125 
    126 void IDBCursorBackendImpl::prefetchContinue(int numberToFetch, PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode& ec)
     122    ASSERT(!ec);
     123}
     124
     125void IDBCursorBackendImpl::prefetchContinue(int numberToFetch, PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode&)
    127126{
    128127    IDB_TRACE("IDBCursorBackendImpl::prefetchContinue");
    129     if (!m_transaction->scheduleTask(m_taskType, createCallbackTask(&IDBCursorBackendImpl::prefetchContinueInternal, this, numberToFetch, prpCallbacks)))
    130         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     128    RefPtr<IDBCallbacks> callbacks = prpCallbacks;
     129    if (!m_transaction->scheduleTask(m_taskType, createCallbackTask(&IDBCursorBackendImpl::prefetchContinueInternal, this, numberToFetch, callbacks)))
     130        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    131131}
    132132
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseError.h

    r127757 r130095  
    3838class IDBDatabaseError : public RefCounted<IDBDatabaseError> {
    3939public:
     40    static PassRefPtr<IDBDatabaseError> create(unsigned short code)
     41    {
     42        ASSERT(code >= IDBDatabaseException::IDBDatabaseExceptionOffset);
     43        ASSERT(code < IDBDatabaseException::IDBDatabaseExceptionMax);
     44        return adoptRef(new IDBDatabaseError(code));
     45    }
     46
    4047    static PassRefPtr<IDBDatabaseError> create(unsigned short code, const String& message)
    4148    {
     
    5360
    5461private:
     62    IDBDatabaseError(unsigned short code)
     63        : m_code(code), m_message(IDBDatabaseException::getErrorDescription(code)) { }
    5564    IDBDatabaseError(unsigned short code, const String& message)
    56             : m_code(code), m_message(message) { }
     65        : m_code(code), m_message(message) { }
    5766
    5867    const unsigned short m_code;
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseException.cpp

    r123112 r130095  
    104104}
    105105
     106String IDBDatabaseException::getErrorDescription(ExceptionCode ec)
     107{
     108    const IDBDatabaseExceptionNameDescription* entry = getErrorEntry(ec);
     109    ASSERT(entry);
     110    if (!entry)
     111        return "Unknown error.";
     112
     113    return entry->description;
     114}
     115
    106116ExceptionCode IDBDatabaseException::getLegacyErrorCode(ExceptionCode ec)
    107117{
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseException.h

    r123112 r130095  
    7979    static bool initializeDescription(ExceptionCode, ExceptionCodeDescription*);
    8080    static String getErrorName(ExceptionCode);
     81    static String getErrorDescription(ExceptionCode);
    8182    static ExceptionCode getLegacyErrorCode(ExceptionCode);
    8283
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp

    r126968 r130095  
    7878    request->setCursorDetails(IDBCursorBackendInterface::IndexCursor, direction);
    7979    m_backend->openCursor(keyRange, direction, request, m_transaction->backend(), ec);
    80     if (ec) {
    81         request->markEarlyDeath();
    82         return 0;
    83     }
     80    ASSERT(!ec);
    8481    return request;
    8582}
     
    128125    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
    129126    m_backend->count(keyRange, request, m_transaction->backend(), ec);
    130     if (ec) {
    131         request->markEarlyDeath();
    132         return 0;
    133     }
     127    ASSERT(!ec);
    134128    return request;
    135129}
     
    162156    request->setCursorDetails(IDBCursorBackendInterface::IndexKeyCursor, direction);
    163157    m_backend->openKeyCursor(keyRange, direction, request, m_transaction->backend(), ec);
    164     if (ec) {
    165         request->markEarlyDeath();
    166         return 0;
    167     }
     158    ASSERT(!ec);
    168159    return request;
    169160}
     
    226217    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
    227218    m_backend->get(keyRange, request, m_transaction->backend(), ec);
    228     if (ec) {
    229         request->markEarlyDeath();
    230         return 0;
    231     }
     219    ASSERT(!ec);
    232220    return request;
    233221}
     
    261249    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
    262250    m_backend->getKey(keyRange, request, m_transaction->backend(), ec);
    263     if (ec) {
    264         request->markEarlyDeath();
    265         return 0;
    266     }
     251    ASSERT(!ec);
    267252    return request;
    268253}
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp

    r129066 r130095  
    104104}
    105105
    106 void IDBIndexBackendImpl::openCursor(PassRefPtr<IDBKeyRange> prpKeyRange, unsigned short direction, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     106void IDBIndexBackendImpl::openCursor(PassRefPtr<IDBKeyRange> prpKeyRange, unsigned short direction, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
    107107{
    108108    IDB_TRACE("IDBIndexBackendImpl::openCursor");
     
    113113    if (!transaction->scheduleTask(
    114114            createCallbackTask(&openCursorInternal, index, keyRange, direction, IDBCursorBackendInterface::IndexCursor, callbacks, transaction)))
    115         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
    116 }
    117 
    118 void IDBIndexBackendImpl::openKeyCursor(PassRefPtr<IDBKeyRange> prpKeyRange, unsigned short direction, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     115        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
     116}
     117
     118void IDBIndexBackendImpl::openKeyCursor(PassRefPtr<IDBKeyRange> prpKeyRange, unsigned short direction, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
    119119{
    120120    IDB_TRACE("IDBIndexBackendImpl::openKeyCursor");
     
    125125    if (!transaction->scheduleTask(
    126126            createCallbackTask(&openCursorInternal, index, keyRange, direction, IDBCursorBackendInterface::IndexKeyCursor, callbacks, transaction)))
    127         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     127        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    128128}
    129129
     
    146146}
    147147
    148 void IDBIndexBackendImpl::count(PassRefPtr<IDBKeyRange> range, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     148void IDBIndexBackendImpl::count(PassRefPtr<IDBKeyRange> range, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
    149149{
    150150    IDB_TRACE("IDBIndexBackendImpl::count");
     
    152152    if (!transaction->scheduleTask(
    153153            createCallbackTask(&countInternal, this, range, callbacks, transaction)))
    154         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     154        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    155155}
    156156
     
    213213
    214214
    215 void IDBIndexBackendImpl::get(PassRefPtr<IDBKeyRange> prpKeyRange, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     215void IDBIndexBackendImpl::get(PassRefPtr<IDBKeyRange> prpKeyRange, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
    216216{
    217217    IDB_TRACE("IDBIndexBackendImpl::get");
     
    221221    RefPtr<IDBTransactionBackendImpl> transaction = IDBTransactionBackendImpl::from(transactionPtr);
    222222    if (!transaction->scheduleTask(createCallbackTask(&getInternal, index, keyRange, callbacks, transaction)))
    223         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
    224 }
    225 
    226 void IDBIndexBackendImpl::getKey(PassRefPtr<IDBKeyRange> prpKeyRange, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     223        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
     224}
     225
     226void IDBIndexBackendImpl::getKey(PassRefPtr<IDBKeyRange> prpKeyRange, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
    227227{
    228228    IDB_TRACE("IDBIndexBackendImpl::getKey");
     
    233233    if (!transaction->scheduleTask(
    234234            createCallbackTask(&getKeyInternal, index, keyRange, callbacks, transaction)))
    235         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     235        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    236236}
    237237
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp

    r128789 r130095  
    8989    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
    9090    m_backend->get(keyRange, request, m_transaction->backend(), ec);
    91     if (ec) {
    92         request->markEarlyDeath();
    93         return 0;
    94     }
     91    ASSERT(!ec);
    9592    return request.release();
    9693}
     
    220217    RefPtr<IDBRequest> request = IDBRequest::create(context, source, m_transaction.get());
    221218    m_backend->putWithIndexKeys(serializedValue.release(), key.release(), putMode, request, m_transaction->backend(), indexNames, indexKeys, ec);
    222     if (ec) {
    223         request->markEarlyDeath();
    224         return 0;
    225     }
     219    ASSERT(!ec);
    226220    return request.release();
    227221}
     
    249243    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
    250244    m_backend->deleteFunction(keyRange, request, m_transaction->backend(), ec);
    251     if (ec) {
    252         request->markEarlyDeath();
    253         return 0;
    254     }
     245    ASSERT(!ec);
    255246    return request.release();
    256247}
     
    283274    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
    284275    m_backend->clear(request, m_transaction->backend(), ec);
    285     if (ec) {
    286         request->markEarlyDeath();
    287         return 0;
    288     }
     276    ASSERT(!ec);
    289277    return request.release();
    290278}
     
    515503    request->setCursorDetails(IDBCursorBackendInterface::ObjectStoreCursor, direction);
    516504    m_backend->openCursor(range, direction, request, taskType, m_transaction->backend(), ec);
    517     if (ec) {
    518         request->markEarlyDeath();
    519         return 0;
    520     }
     505    ASSERT(!ec);
    521506    return request.release();
    522507}
     
    565550    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
    566551    m_backend->count(range, request, m_transaction->backend(), ec);
    567     if (ec) {
    568         request->markEarlyDeath();
    569         return 0;
    570     }
     552    ASSERT(!ec);
    571553    return request.release();
    572554}
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp

    r129066 r130095  
    7979}
    8080
    81 void IDBObjectStoreBackendImpl::get(PassRefPtr<IDBKeyRange> prpKeyRange, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     81void IDBObjectStoreBackendImpl::get(PassRefPtr<IDBKeyRange> prpKeyRange, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
    8282{
    8383    IDB_TRACE("IDBObjectStoreBackendImpl::get");
     
    8888    if (!transaction->scheduleTask(
    8989            createCallbackTask(&IDBObjectStoreBackendImpl::getInternal, objectStore, keyRange, callbacks, transaction)))
    90         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     90        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    9191}
    9292
     
    121121}
    122122
    123 void IDBObjectStoreBackendImpl::putWithIndexKeys(PassRefPtr<SerializedScriptValue> prpValue, PassRefPtr<IDBKey> prpKey, PutMode putMode, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, const Vector<String>& indexNames, const Vector<IndexKeys>& indexKeys, ExceptionCode& ec)
     123void IDBObjectStoreBackendImpl::putWithIndexKeys(PassRefPtr<SerializedScriptValue> prpValue, PassRefPtr<IDBKey> prpKey, PutMode putMode, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, const Vector<String>& indexNames, const Vector<IndexKeys>& indexKeys, ExceptionCode&)
    124124{
    125125    IDB_TRACE("IDBObjectStoreBackendImpl::putWithIndexKeys");
     
    139139    if (!transaction->scheduleTask(
    140140            createCallbackTask(&IDBObjectStoreBackendImpl::putInternal, objectStore, value, key, putMode, callbacks, transaction, newIndexNames.release(), newIndexKeys.release())))
    141         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     141        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    142142}
    143143
     
    369369}
    370370
    371 void IDBObjectStoreBackendImpl::deleteFunction(PassRefPtr<IDBKeyRange> prpKeyRange, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     371void IDBObjectStoreBackendImpl::deleteFunction(PassRefPtr<IDBKeyRange> prpKeyRange, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
    372372{
    373373    IDB_TRACE("IDBObjectStoreBackendImpl::delete");
     
    382382    if (!transaction->scheduleTask(
    383383            createCallbackTask(&IDBObjectStoreBackendImpl::deleteInternal, objectStore, keyRange, callbacks, transaction)))
    384         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     384        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    385385}
    386386
     
    414414}
    415415
    416 void IDBObjectStoreBackendImpl::clear(PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     416void IDBObjectStoreBackendImpl::clear(PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
    417417{
    418418    IDB_TRACE("IDBObjectStoreBackendImpl::clear");
     
    426426    if (!transaction->scheduleTask(
    427427            createCallbackTask(&IDBObjectStoreBackendImpl::clearInternal, objectStore, callbacks, transaction)))
    428         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     428        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    429429}
    430430
     
    504504}
    505505
    506 void IDBObjectStoreBackendImpl::openCursor(PassRefPtr<IDBKeyRange> prpRange, IDBCursor::Direction direction, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface::TaskType taskType, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     506void IDBObjectStoreBackendImpl::openCursor(PassRefPtr<IDBKeyRange> prpRange, IDBCursor::Direction direction, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface::TaskType taskType, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
    507507{
    508508    IDB_TRACE("IDBObjectStoreBackendImpl::openCursor");
     
    513513    if (!transaction->scheduleTask(
    514514            createCallbackTask(&IDBObjectStoreBackendImpl::openCursorInternal, objectStore, range, direction, callbacks, taskType, transaction))) {
    515         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     515        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    516516    }
    517517}
     
    537537}
    538538
    539 void IDBObjectStoreBackendImpl::count(PassRefPtr<IDBKeyRange> range, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     539void IDBObjectStoreBackendImpl::count(PassRefPtr<IDBKeyRange> range, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
    540540{
    541541    IDB_TRACE("IDBObjectStoreBackendImpl::count");
     
    543543    if (!transaction->scheduleTask(
    544544            createCallbackTask(&IDBObjectStoreBackendImpl::countInternal, this, range, callbacks, transaction)))
    545         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
     545        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    546546}
    547547
  • trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp

    r129038 r130095  
    175175    m_errorMessage = String();
    176176    m_result.clear();
    177     onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR, "The transaction was aborted, so the request cannot be fulfilled."));
     177    onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR));
    178178    m_requestAborted = true;
    179179}
  • trunk/Source/WebKit/chromium/ChangeLog

    r130052 r130095  
     12012-10-01  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: Move onSuccess(IDBDatabaseBackendInterface) to IDBOpenDBRequest
     4        https://bugs.webkit.org/show_bug.cgi?id=94757
     5
     6        Reviewed by Tony Chang.
     7
     8        * tests/IDBRequestTest.cpp: Ensure IDBRequest can handle Error after abort.
     9        (WebCore::TEST): Added AbortAfter
     10
    1112012-10-01  Ilya Tikhonovsky  <loislo@chromium.org>
    212
  • trunk/Source/WebKit/chromium/tests/IDBRequestTest.cpp

    r126461 r130095  
    5959}
    6060
     61TEST(IDBRequestTest, AbortErrorAfterAbort)
     62{
     63    ScriptExecutionContext* context = 0;
     64    IDBTransaction* transaction = 0;
     65    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::createInvalid(), transaction);
     66    EXPECT_EQ(request->readyState(), "pending");
     67
     68    // Simulate the IDBTransaction having received onAbort from back end and aborting the request:
     69    request->abort();
     70
     71    // Now simulate the back end having fired an abort error at the request to clear up any intermediaries.
     72    // Ensure an assertion is not raised.
     73    request->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR, "Description goes here."));
     74}
     75
    6176} // namespace
    6277
Note: See TracChangeset for help on using the changeset viewer.