Changeset 235344 in webkit
- Timestamp:
- Aug 26, 2018 7:43:26 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r235343 r235344 1 2018-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 1 41 2018-08-26 Wenson Hsieh <wenson_hsieh@apple.com> 2 42 -
trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp
r233122 r235344 46 46 using namespace JSC; 47 47 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) 48 Ref<IDBCursor> IDBCursor::create(IDBObjectStore& objectStore, const IDBCursorInfo& info) 49 { 50 return adoptRef(*new IDBCursor(objectStore, info)); 51 } 52 53 Ref<IDBCursor> IDBCursor::create(IDBIndex& index, const IDBCursorInfo& info) 54 { 55 return adoptRef(*new IDBCursor(index, info)); 56 } 57 58 IDBCursor::IDBCursor(IDBObjectStore& objectStore, const IDBCursorInfo& info) 59 : m_info(info) 61 60 , m_source(&objectStore) 62 61 { 63 62 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 65 IDBCursor::IDBCursor(IDBIndex& index, const IDBCursorInfo& info) 66 : m_info(info) 71 67 , m_source(&index) 72 68 { 73 69 ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current()); 74 75 suspendIfNeeded();76 70 } 77 71 … … 141 135 auto request = putResult.releaseReturnValue(); 142 136 request->setSource(*this); 143 ++m_outstandingRequestCount;144 137 145 138 return WTFMove(request); … … 270 263 ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current()); 271 264 272 ++m_outstandingRequestCount;273 274 265 m_request->willIterateCursor(*this); 275 266 transaction().iterateCursor(*this, { key, { }, count }); … … 279 270 { 280 271 ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current()); 281 282 ++m_outstandingRequestCount;283 272 284 273 m_request->willIterateCursor(*this); … … 312 301 auto request = result.releaseReturnValue(); 313 302 request->setSource(*this); 314 ++m_outstandingRequestCount;315 303 316 304 return WTFMove(request); … … 358 346 } 359 347 360 const char* IDBCursor::activeDOMObjectName() const361 {362 return "IDBCursor";363 }364 365 bool IDBCursor::canSuspendForDocumentSuspension() const366 {367 return false;368 }369 370 bool IDBCursor::hasPendingActivity() const371 {372 return m_outstandingRequestCount;373 }374 375 void IDBCursor::decrementOutstandingRequestCount()376 {377 ASSERT(m_outstandingRequestCount);378 --m_outstandingRequestCount;379 }380 381 348 } // namespace WebCore 382 349 -
trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h
r228260 r235344 28 28 #if ENABLE(INDEXED_DATABASE) 29 29 30 #include "ActiveDOMObject.h"31 30 #include "ExceptionOr.h" 32 31 #include "IDBCursorDirection.h" … … 42 41 class IDBTransaction; 43 42 44 class IDBCursor : public ScriptWrappable, public RefCounted<IDBCursor> , public ActiveDOMObject{43 class IDBCursor : public ScriptWrappable, public RefCounted<IDBCursor> { 45 44 public: 46 static Ref<IDBCursor> create(IDB Transaction&, IDBObjectStore&, const IDBCursorInfo&);47 static Ref<IDBCursor> create(IDB Transaction&, IDBIndex&, const IDBCursorInfo&);45 static Ref<IDBCursor> create(IDBObjectStore&, const IDBCursorInfo&); 46 static Ref<IDBCursor> create(IDBIndex&, const IDBCursorInfo&); 48 47 49 48 virtual ~IDBCursor(); … … 75 74 virtual bool isKeyCursorWithValue() const { return false; } 76 75 77 void decrementOutstandingRequestCount();78 79 bool hasPendingActivity() const final;80 81 76 protected: 82 IDBCursor(IDB Transaction&, IDBObjectStore&, const IDBCursorInfo&);83 IDBCursor(IDB Transaction&, IDBIndex&, const IDBCursorInfo&);77 IDBCursor(IDBObjectStore&, const IDBCursorInfo&); 78 IDBCursor(IDBIndex&, const IDBCursorInfo&); 84 79 85 80 private: 86 const char* activeDOMObjectName() const final;87 bool canSuspendForDocumentSuspension() const final;88 89 81 bool sourcesDeleted() const; 90 82 IDBObjectStore& effectiveObjectStore() const; … … 93 85 void uncheckedIterateCursor(const IDBKeyData&, unsigned count); 94 86 void uncheckedIterateCursor(const IDBKeyData&, const IDBKeyData&); 95 96 // Cursors are created with an outstanding iteration request.97 unsigned m_outstandingRequestCount { 1 };98 87 99 88 IDBCursorInfo m_info; -
trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl
r211013 r235344 25 25 26 26 [ 27 ActiveDOMObject,28 27 Conditional=INDEXED_DATABASE, 29 28 CustomToJSObject, -
trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.cpp
r228218 r235344 33 33 namespace WebCore { 34 34 35 Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDB Transaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)35 Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBObjectStore& objectStore, const IDBCursorInfo& info) 36 36 { 37 return adoptRef(*new IDBCursorWithValue( transaction,objectStore, info));37 return adoptRef(*new IDBCursorWithValue(objectStore, info)); 38 38 } 39 39 40 Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDB Transaction& transaction, IDBIndex& index, const IDBCursorInfo& info)40 Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBIndex& index, const IDBCursorInfo& info) 41 41 { 42 return adoptRef(*new IDBCursorWithValue( transaction,index, info));42 return adoptRef(*new IDBCursorWithValue(index, info)); 43 43 } 44 44 45 IDBCursorWithValue::IDBCursorWithValue(IDB Transaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)46 : IDBCursor( transaction,objectStore, info)45 IDBCursorWithValue::IDBCursorWithValue(IDBObjectStore& objectStore, const IDBCursorInfo& info) 46 : IDBCursor(objectStore, info) 47 47 { 48 48 } 49 49 50 IDBCursorWithValue::IDBCursorWithValue(IDB Transaction& transaction, IDBIndex& index, const IDBCursorInfo& info)51 : IDBCursor( transaction,index, info)50 IDBCursorWithValue::IDBCursorWithValue(IDBIndex& index, const IDBCursorInfo& info) 51 : IDBCursor(index, info) 52 52 { 53 53 } -
trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h
r200287 r235344 35 35 class IDBCursorWithValue final : public IDBCursor { 36 36 public: 37 static Ref<IDBCursorWithValue> create(IDB Transaction&, IDBObjectStore&, const IDBCursorInfo&);38 static Ref<IDBCursorWithValue> create(IDB Transaction&, IDBIndex&, const IDBCursorInfo&);37 static Ref<IDBCursorWithValue> create(IDBObjectStore&, const IDBCursorInfo&); 38 static Ref<IDBCursorWithValue> create(IDBIndex&, const IDBCursorInfo&); 39 39 40 40 virtual ~IDBCursorWithValue(); … … 43 43 44 44 private: 45 IDBCursorWithValue(IDB Transaction&, IDBObjectStore&, const IDBCursorInfo&);46 IDBCursorWithValue(IDB Transaction&, IDBIndex&, const IDBCursorInfo&);45 IDBCursorWithValue(IDBObjectStore&, const IDBCursorInfo&); 46 IDBCursorWithValue(IDBIndex&, const IDBCursorInfo&); 47 47 }; 48 48 -
trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl
r211013 r235344 26 26 [ 27 27 Conditional=INDEXED_DATABASE, 28 ActiveDOMObject,29 28 SkipVTableValidation, 30 29 JSCustomMarkFunction, -
trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp
r234995 r235344 175 175 { 176 176 ASSERT(&originThread() == &Thread::current()); 177 ASSERT(!m_cursorRequestNotifier);178 177 179 178 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 });184 179 } 185 180 … … 319 314 m_hasPendingActivity = false; 320 315 321 m_cursorRequestNotifier = nullptr;322 323 316 { 324 317 TransactionActivator activator(m_transaction.get()); … … 475 468 ASSERT(!m_pendingCursor); 476 469 ASSERT(&cursor == resultCursor()); 477 ASSERT(!m_cursorRequestNotifier);478 470 479 471 m_pendingCursor = &cursor; … … 483 475 m_domError = nullptr; 484 476 m_idbError = IDBError { }; 485 486 m_cursorRequestNotifier = std::make_unique<WTF::ScopeExit<WTF::Function<void()>>>([this]() {487 m_pendingCursor->decrementOutstandingRequestCount();488 });489 477 } 490 478 … … 502 490 } 503 491 504 m_cursorRequestNotifier = nullptr;505 492 m_pendingCursor = nullptr; 506 493 -
trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h
r228260 r235344 174 174 RefPtr<IDBCursor> m_pendingCursor; 175 175 176 std::unique_ptr<WTF::ScopeExit<WTF::Function<void()>>> m_cursorRequestNotifier;177 178 176 Ref<IDBClient::IDBConnectionProxy> m_connectionProxy; 179 177 }; -
trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
r234995 r235344 801 801 802 802 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)); 806 806 } 807 807 … … 812 812 813 813 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)); 817 817 } 818 818
Note: See TracChangeset
for help on using the changeset viewer.