Changeset 235344 in webkit


Ignore:
Timestamp:
Aug 26, 2018 7:43:26 PM (6 years ago)
Author:
youenn@apple.com
Message:

IDBCursor does not need to be an ActiveDOMObject
https://bugs.webkit.org/show_bug.cgi?id=188937

Reviewed by Alex Christensen.

Remove ActiveDOMObject from IDBCursor IDL.
Update constructors and call sites accordingly.
This allows removing m_outstandingRequestCount and related code in IDBRequest.

Covered by existing tests.

  • Modules/indexeddb/IDBCursor.cpp:

(WebCore::IDBCursor::create):
(WebCore::IDBCursor::IDBCursor):
(WebCore::IDBCursor::update):
(WebCore::IDBCursor::uncheckedIterateCursor):
(WebCore::IDBCursor::deleteFunction):
(WebCore::IDBCursor::activeDOMObjectName const): Deleted.
(WebCore::IDBCursor::canSuspendForDocumentSuspension const): Deleted.
(WebCore::IDBCursor::hasPendingActivity const): Deleted.
(WebCore::IDBCursor::decrementOutstandingRequestCount): Deleted.

  • Modules/indexeddb/IDBCursor.h:
  • Modules/indexeddb/IDBCursor.idl:
  • Modules/indexeddb/IDBCursorWithValue.cpp:

(WebCore::IDBCursorWithValue::create):
(WebCore::IDBCursorWithValue::IDBCursorWithValue):

  • Modules/indexeddb/IDBCursorWithValue.h:
  • Modules/indexeddb/IDBCursorWithValue.idl:
  • Modules/indexeddb/IDBRequest.cpp:

(WebCore::IDBRequest::setSource):
(WebCore::IDBRequest::dispatchEvent):
(WebCore::IDBRequest::willIterateCursor):
(WebCore::IDBRequest::didOpenOrIterateCursor):

  • Modules/indexeddb/IDBRequest.h:
  • Modules/indexeddb/IDBTransaction.cpp:

(WebCore::IDBTransaction::requestOpenCursor):

  • WebCore.xcodeproj/project.pbxproj:
Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r235343 r235344  
     12018-08-26  Youenn Fablet  <youenn@apple.com>
     2
     3        IDBCursor does not need to be an ActiveDOMObject
     4        https://bugs.webkit.org/show_bug.cgi?id=188937
     5
     6        Reviewed by Alex Christensen.
     7
     8        Remove ActiveDOMObject from IDBCursor IDL.
     9        Update constructors and call sites accordingly.
     10        This allows removing m_outstandingRequestCount and related code in IDBRequest.
     11
     12        Covered by existing tests.
     13
     14        * Modules/indexeddb/IDBCursor.cpp:
     15        (WebCore::IDBCursor::create):
     16        (WebCore::IDBCursor::IDBCursor):
     17        (WebCore::IDBCursor::update):
     18        (WebCore::IDBCursor::uncheckedIterateCursor):
     19        (WebCore::IDBCursor::deleteFunction):
     20        (WebCore::IDBCursor::activeDOMObjectName const): Deleted.
     21        (WebCore::IDBCursor::canSuspendForDocumentSuspension const): Deleted.
     22        (WebCore::IDBCursor::hasPendingActivity const): Deleted.
     23        (WebCore::IDBCursor::decrementOutstandingRequestCount): Deleted.
     24        * Modules/indexeddb/IDBCursor.h:
     25        * Modules/indexeddb/IDBCursor.idl:
     26        * Modules/indexeddb/IDBCursorWithValue.cpp:
     27        (WebCore::IDBCursorWithValue::create):
     28        (WebCore::IDBCursorWithValue::IDBCursorWithValue):
     29        * Modules/indexeddb/IDBCursorWithValue.h:
     30        * Modules/indexeddb/IDBCursorWithValue.idl:
     31        * Modules/indexeddb/IDBRequest.cpp:
     32        (WebCore::IDBRequest::setSource):
     33        (WebCore::IDBRequest::dispatchEvent):
     34        (WebCore::IDBRequest::willIterateCursor):
     35        (WebCore::IDBRequest::didOpenOrIterateCursor):
     36        * Modules/indexeddb/IDBRequest.h:
     37        * Modules/indexeddb/IDBTransaction.cpp:
     38        (WebCore::IDBTransaction::requestOpenCursor):
     39        * WebCore.xcodeproj/project.pbxproj:
     40
    1412018-08-26  Wenson Hsieh  <wenson_hsieh@apple.com>
    242
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp

    r233122 r235344  
    4646using namespace JSC;
    4747
    48 Ref<IDBCursor> IDBCursor::create(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
    49 {
    50     return adoptRef(*new IDBCursor(transaction, objectStore, info));
    51 }
    52 
    53 Ref<IDBCursor> IDBCursor::create(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
    54 {
    55     return adoptRef(*new IDBCursor(transaction, index, info));
    56 }
    57 
    58 IDBCursor::IDBCursor(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
    59     : ActiveDOMObject(transaction.scriptExecutionContext())
    60     , m_info(info)
     48Ref<IDBCursor> IDBCursor::create(IDBObjectStore& objectStore, const IDBCursorInfo& info)
     49{
     50    return adoptRef(*new IDBCursor(objectStore, info));
     51}
     52
     53Ref<IDBCursor> IDBCursor::create(IDBIndex& index, const IDBCursorInfo& info)
     54{
     55    return adoptRef(*new IDBCursor(index, info));
     56}
     57
     58IDBCursor::IDBCursor(IDBObjectStore& objectStore, const IDBCursorInfo& info)
     59    : m_info(info)
    6160    , m_source(&objectStore)
    6261{
    6362    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
    64 
    65     suspendIfNeeded();
    66 }
    67 
    68 IDBCursor::IDBCursor(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
    69     : ActiveDOMObject(transaction.scriptExecutionContext())
    70     , m_info(info)
     63}
     64
     65IDBCursor::IDBCursor(IDBIndex& index, const IDBCursorInfo& info)
     66    : m_info(info)
    7167    , m_source(&index)
    7268{
    7369    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
    74 
    75     suspendIfNeeded();
    7670}
    7771
     
    141135    auto request = putResult.releaseReturnValue();
    142136    request->setSource(*this);
    143     ++m_outstandingRequestCount;
    144137
    145138    return WTFMove(request);
     
    270263    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
    271264
    272     ++m_outstandingRequestCount;
    273 
    274265    m_request->willIterateCursor(*this);
    275266    transaction().iterateCursor(*this, { key, { }, count });
     
    279270{
    280271    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
    281 
    282     ++m_outstandingRequestCount;
    283272
    284273    m_request->willIterateCursor(*this);
     
    312301    auto request = result.releaseReturnValue();
    313302    request->setSource(*this);
    314     ++m_outstandingRequestCount;
    315303
    316304    return WTFMove(request);
     
    358346}
    359347
    360 const char* IDBCursor::activeDOMObjectName() const
    361 {
    362     return "IDBCursor";
    363 }
    364 
    365 bool IDBCursor::canSuspendForDocumentSuspension() const
    366 {
    367     return false;
    368 }
    369 
    370 bool IDBCursor::hasPendingActivity() const
    371 {
    372     return m_outstandingRequestCount;
    373 }
    374 
    375 void IDBCursor::decrementOutstandingRequestCount()
    376 {
    377     ASSERT(m_outstandingRequestCount);
    378     --m_outstandingRequestCount;
    379 }
    380 
    381348} // namespace WebCore
    382349
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h

    r228260 r235344  
    2828#if ENABLE(INDEXED_DATABASE)
    2929
    30 #include "ActiveDOMObject.h"
    3130#include "ExceptionOr.h"
    3231#include "IDBCursorDirection.h"
     
    4241class IDBTransaction;
    4342
    44 class IDBCursor : public ScriptWrappable, public RefCounted<IDBCursor>, public ActiveDOMObject {
     43class IDBCursor : public ScriptWrappable, public RefCounted<IDBCursor> {
    4544public:
    46     static Ref<IDBCursor> create(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
    47     static Ref<IDBCursor> create(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
     45    static Ref<IDBCursor> create(IDBObjectStore&, const IDBCursorInfo&);
     46    static Ref<IDBCursor> create(IDBIndex&, const IDBCursorInfo&);
    4847   
    4948    virtual ~IDBCursor();
     
    7574    virtual bool isKeyCursorWithValue() const { return false; }
    7675
    77     void decrementOutstandingRequestCount();
    78 
    79     bool hasPendingActivity() const final;
    80 
    8176protected:
    82     IDBCursor(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
    83     IDBCursor(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
     77    IDBCursor(IDBObjectStore&, const IDBCursorInfo&);
     78    IDBCursor(IDBIndex&, const IDBCursorInfo&);
    8479
    8580private:
    86     const char* activeDOMObjectName() const final;
    87     bool canSuspendForDocumentSuspension() const final;
    88 
    8981    bool sourcesDeleted() const;
    9082    IDBObjectStore& effectiveObjectStore() const;
     
    9385    void uncheckedIterateCursor(const IDBKeyData&, unsigned count);
    9486    void uncheckedIterateCursor(const IDBKeyData&, const IDBKeyData&);
    95 
    96     // Cursors are created with an outstanding iteration request.
    97     unsigned m_outstandingRequestCount { 1 };
    9887
    9988    IDBCursorInfo m_info;
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl

    r211013 r235344  
    2525
    2626[
    27     ActiveDOMObject,
    2827    Conditional=INDEXED_DATABASE,
    2928    CustomToJSObject,
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.cpp

    r228218 r235344  
    3333namespace WebCore {
    3434
    35 Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
     35Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBObjectStore& objectStore, const IDBCursorInfo& info)
    3636{
    37     return adoptRef(*new IDBCursorWithValue(transaction, objectStore, info));
     37    return adoptRef(*new IDBCursorWithValue(objectStore, info));
    3838}
    3939
    40 Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
     40Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBIndex& index, const IDBCursorInfo& info)
    4141{
    42     return adoptRef(*new IDBCursorWithValue(transaction, index, info));
     42    return adoptRef(*new IDBCursorWithValue(index, info));
    4343}
    4444
    45 IDBCursorWithValue::IDBCursorWithValue(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
    46     : IDBCursor(transaction, objectStore, info)
     45IDBCursorWithValue::IDBCursorWithValue(IDBObjectStore& objectStore, const IDBCursorInfo& info)
     46    : IDBCursor(objectStore, info)
    4747{
    4848}
    4949
    50 IDBCursorWithValue::IDBCursorWithValue(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
    51     : IDBCursor(transaction, index, info)
     50IDBCursorWithValue::IDBCursorWithValue(IDBIndex& index, const IDBCursorInfo& info)
     51    : IDBCursor(index, info)
    5252{
    5353}
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h

    r200287 r235344  
    3535class IDBCursorWithValue final : public IDBCursor {
    3636public:
    37     static Ref<IDBCursorWithValue> create(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
    38     static Ref<IDBCursorWithValue> create(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
     37    static Ref<IDBCursorWithValue> create(IDBObjectStore&, const IDBCursorInfo&);
     38    static Ref<IDBCursorWithValue> create(IDBIndex&, const IDBCursorInfo&);
    3939
    4040    virtual ~IDBCursorWithValue();
     
    4343
    4444private:
    45     IDBCursorWithValue(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
    46     IDBCursorWithValue(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
     45    IDBCursorWithValue(IDBObjectStore&, const IDBCursorInfo&);
     46    IDBCursorWithValue(IDBIndex&, const IDBCursorInfo&);
    4747};
    4848
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl

    r211013 r235344  
    2626[
    2727    Conditional=INDEXED_DATABASE,
    28     ActiveDOMObject,
    2928    SkipVTableValidation,
    3029    JSCustomMarkFunction,
  • trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp

    r234995 r235344  
    175175{
    176176    ASSERT(&originThread() == &Thread::current());
    177     ASSERT(!m_cursorRequestNotifier);
    178177
    179178    m_source = Source { &cursor };
    180     m_cursorRequestNotifier = std::make_unique<WTF::ScopeExit<WTF::Function<void()>>>([this]() {
    181         ASSERT(WTF::holds_alternative<RefPtr<IDBCursor>>(m_source.value()));
    182         WTF::get<RefPtr<IDBCursor>>(m_source.value())->decrementOutstandingRequestCount();
    183     });
    184179}
    185180
     
    319314    m_hasPendingActivity = false;
    320315
    321     m_cursorRequestNotifier = nullptr;
    322 
    323316    {
    324317        TransactionActivator activator(m_transaction.get());
     
    475468    ASSERT(!m_pendingCursor);
    476469    ASSERT(&cursor == resultCursor());
    477     ASSERT(!m_cursorRequestNotifier);
    478470
    479471    m_pendingCursor = &cursor;
     
    483475    m_domError = nullptr;
    484476    m_idbError = IDBError { };
    485 
    486     m_cursorRequestNotifier = std::make_unique<WTF::ScopeExit<WTF::Function<void()>>>([this]() {
    487         m_pendingCursor->decrementOutstandingRequestCount();
    488     });
    489477}
    490478
     
    502490    }
    503491
    504     m_cursorRequestNotifier = nullptr;
    505492    m_pendingCursor = nullptr;
    506493
  • trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h

    r228260 r235344  
    174174    RefPtr<IDBCursor> m_pendingCursor;
    175175
    176     std::unique_ptr<WTF::ScopeExit<WTF::Function<void()>>> m_cursorRequestNotifier;
    177 
    178176    Ref<IDBClient::IDBConnectionProxy> m_connectionProxy;
    179177};
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp

    r234995 r235344  
    801801
    802802    if (info.cursorType() == IndexedDB::CursorType::KeyOnly)
    803         return doRequestOpenCursor(state, IDBCursor::create(*this, objectStore, info));
    804 
    805     return doRequestOpenCursor(state, IDBCursorWithValue::create(*this, objectStore, info));
     803        return doRequestOpenCursor(state, IDBCursor::create(objectStore, info));
     804
     805    return doRequestOpenCursor(state, IDBCursorWithValue::create(objectStore, info));
    806806}
    807807
     
    812812
    813813    if (info.cursorType() == IndexedDB::CursorType::KeyOnly)
    814         return doRequestOpenCursor(state, IDBCursor::create(*this, index, info));
    815 
    816     return doRequestOpenCursor(state, IDBCursorWithValue::create(*this, index, info));
     814        return doRequestOpenCursor(state, IDBCursor::create(index, info));
     815
     816    return doRequestOpenCursor(state, IDBCursorWithValue::create(index, info));
    817817}
    818818
Note: See TracChangeset for help on using the changeset viewer.