Changeset 195997 in webkit
- Timestamp:
- Feb 1, 2016 5:42:54 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r195954 r195997 1187 1187 bindings/js/JSIDBAnyCustom.cpp 1188 1188 bindings/js/JSIDBCursorCustom.cpp 1189 bindings/js/JSIDBCursorWithValueCustom.cpp 1189 1190 bindings/js/JSIDBDatabaseCustom.cpp 1190 1191 bindings/js/JSIDBObjectStoreCustom.cpp -
trunk/Source/WebCore/ChangeLog
r195992 r195997 1 2016-02-01 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: Cursors (still) do not keep their opening request alive. 4 https://bugs.webkit.org/show_bug.cgi?id=153724 5 6 Reviewed by Alex Christensen. 7 8 No new tests (All existing tests pass without flakiness). 9 10 IDBCursors did not properly keep their JS wrappers alive. 11 Making them ActiveDOMObjects that keep track of how many requests might be in flight fixes this. 12 This also makes them actually keep their opening-request live via the opaque-root mechanism. 13 14 IDBCursorWithValue also needed to opt in to all of these mechanisms. 15 16 * CMakeLists.txt: 17 * WebCore.xcodeproj/project.pbxproj: 18 19 * Modules/indexeddb/IDBCursor.h: 20 (WebCore::IDBCursor::hasPendingActivity): The base IDBCursor always has no pending activity, 21 to maintain current behavior in LegacyIDB. This weirdness will go away when LegacyIDB does. 22 * Modules/indexeddb/IDBCursor.idl: 23 * Modules/indexeddb/IDBCursorWithValue.idl: 24 25 Track a count for all outstanding requests to keep the cursor alive as an ActiveDOMObject. 26 * Modules/indexeddb/client/IDBCursorImpl.cpp: 27 (WebCore::IDBClient::IDBCursor::IDBCursor): 28 (WebCore::IDBClient::IDBCursor::update): 29 (WebCore::IDBClient::IDBCursor::uncheckedIterateCursor): 30 (WebCore::IDBClient::IDBCursor::deleteFunction): 31 (WebCore::IDBClient::IDBCursor::activeDOMObjectName): 32 (WebCore::IDBClient::IDBCursor::canSuspendForDocumentSuspension): 33 (WebCore::IDBClient::IDBCursor::hasPendingActivity): 34 (WebCore::IDBClient::IDBCursor::decrementOutstandingRequestCount): 35 * Modules/indexeddb/client/IDBCursorImpl.h: 36 37 Rework the "delete" family of functions on the object store to allow for returning a modern IDBRequest. 38 A lot of this can go away when LegacyIDB does. 39 * Modules/indexeddb/client/IDBObjectStoreImpl.cpp: 40 (WebCore::IDBClient::IDBObjectStore::deleteFunction): 41 (WebCore::IDBClient::IDBObjectStore::doDelete): 42 (WebCore::IDBClient::IDBObjectStore::modernDelete): 43 * Modules/indexeddb/client/IDBObjectStoreImpl.h: 44 45 * Modules/indexeddb/client/IDBRequestImpl.cpp: 46 (WebCore::IDBClient::IDBRequest::setSource): Setup a ScopeGuard to decrement the cursor's request 47 count whenever it makes sense to do so. 48 (WebCore::IDBClient::IDBRequest::dispatchEvent): Clear the ScopeGuard (if it exists) to decrement the count. 49 (WebCore::IDBClient::IDBRequest::willIterateCursor): Set the ScopeGuard. 50 (WebCore::IDBClient::IDBRequest::didOpenOrIterateCursor): Clear the ScopeGuard (if it exists) to decrement the count. 51 * Modules/indexeddb/client/IDBRequestImpl.h: 52 53 * Modules/indexeddb/server/UniqueIDBDatabase.cpp: 54 (WebCore::IDBServer::ScopeGuard::ScopeGuard): Deleted. 55 (WebCore::IDBServer::ScopeGuard::~ScopeGuard): Deleted. 56 (WebCore::IDBServer::ScopeGuard::enable): Deleted. 57 (WebCore::IDBServer::ScopeGuard::disable): Deleted. 58 59 * bindings/js/JSIDBCursorWithValueCustom.cpp: Added. 60 (WebCore::JSIDBCursorWithValue::visitAdditionalChildren): 61 62 * platform/ScopeGuard.h: Added. 63 (WebCore::ScopeGuard::ScopeGuard): 64 (WebCore::ScopeGuard::~ScopeGuard): 65 (WebCore::ScopeGuard::enable): 66 (WebCore::ScopeGuard::disable): 67 1 68 2016-02-01 Sun-woo Nam <sunny.nam@samsung.com> 2 69 -
trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h
r194967 r195997 77 77 virtual bool isModernCursor() const { return false; } 78 78 79 virtual bool hasPendingActivity() const { return false; } 80 79 81 protected: 80 82 IDBCursor(); -
trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl
r194967 r195997 27 27 Conditional=INDEXED_DATABASE, 28 28 EnabledAtRuntime=IndexedDB, 29 ActiveDOMObject, 29 30 SkipVTableValidation, 30 31 JSCustomMarkFunction, -
trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl
r189746 r195997 27 27 Conditional=INDEXED_DATABASE, 28 28 EnabledAtRuntime=IndexedDB, 29 ActiveDOMObject, 29 30 SkipVTableValidation, 31 JSCustomMarkFunction, 30 32 ] interface IDBCursorWithValue : IDBCursor { 31 33 readonly attribute any value; -
trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp
r194967 r195997 45 45 } 46 46 47 IDBCursor::IDBCursor(IDBTransaction&, IDBObjectStore& objectStore, const IDBCursorInfo& info) 48 : m_info(info) 47 IDBCursor::IDBCursor(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info) 48 : ActiveDOMObject(transaction.scriptExecutionContext()) 49 , m_info(info) 49 50 , m_source(IDBAny::create(objectStore).leakRef()) 50 51 , m_objectStore(&objectStore) 51 52 { 52 } 53 54 IDBCursor::IDBCursor(IDBTransaction&, IDBIndex& index, const IDBCursorInfo& info) 55 : m_info(info) 53 suspendIfNeeded(); 54 } 55 56 IDBCursor::IDBCursor(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info) 57 : ActiveDOMObject(transaction.scriptExecutionContext()) 58 , m_info(info) 56 59 , m_source(IDBAny::create(index).leakRef()) 57 60 , m_index(&index) 58 61 { 62 suspendIfNeeded(); 59 63 } 60 64 … … 164 168 ASSERT(request); 165 169 request->setSource(*this); 170 ++m_outstandingRequestCount; 171 166 172 return request; 167 173 } … … 282 288 void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, unsigned long count) 283 289 { 290 ++m_outstandingRequestCount; 291 284 292 m_request->willIterateCursor(*this); 285 293 transaction().iterateCursor(*this, key, count); … … 325 333 } 326 334 327 return effectiveObjectStore().deleteFunction(context, m_deprecatedCurrentPrimaryKey.jsValue(), ec); 335 auto request = effectiveObjectStore().modernDelete(context, m_deprecatedCurrentPrimaryKey.jsValue(), ec); 336 if (ec.code) 337 return nullptr; 338 339 ASSERT(request); 340 request->setSource(*this); 341 ++m_outstandingRequestCount; 342 343 return request; 328 344 } 329 345 … … 360 376 } 361 377 378 const char* IDBCursor::activeDOMObjectName() const 379 { 380 return "IDBCursor"; 381 } 382 383 bool IDBCursor::canSuspendForDocumentSuspension() const 384 { 385 return false; 386 } 387 388 bool IDBCursor::hasPendingActivity() const 389 { 390 return m_outstandingRequestCount; 391 } 392 393 void IDBCursor::decrementOutstandingRequestCount() 394 { 395 ASSERT(m_outstandingRequestCount); 396 --m_outstandingRequestCount; 397 } 398 362 399 } // namespace IDBClient 363 400 } // namespace WebCore -
trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h
r194967 r195997 43 43 class IDBTransaction; 44 44 45 class IDBCursor : public WebCore::IDBCursorWithValue {45 class IDBCursor : public WebCore::IDBCursorWithValue, public ActiveDOMObject { 46 46 public: 47 47 static Ref<IDBCursor> create(IDBTransaction&, IDBIndex&, const IDBCursorInfo&); … … 75 75 virtual bool isModernCursor() const override final { return true; } 76 76 77 void decrementOutstandingRequestCount(); 78 77 79 protected: 78 80 IDBCursor(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&); … … 80 82 81 83 private: 84 // ActiveDOMObject. 85 virtual const char* activeDOMObjectName() const override final; 86 virtual bool canSuspendForDocumentSuspension() const override final; 87 virtual bool hasPendingActivity() const override final; 88 89 // Cursors are created with an outstanding iteration request. 90 unsigned m_outstandingRequestCount { 1 }; 91 82 92 IDBCursorInfo m_info; 83 93 Ref<IDBAny> m_source; -
trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp
r194733 r195997 341 341 } 342 342 343 344 343 RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) 344 { 345 return doDelete(context, keyRange, ec); 346 } 347 348 RefPtr<IDBRequest> IDBObjectStore::doDelete(ScriptExecutionContext* context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) 345 349 { 346 350 LOG(IndexedDB, "IDBObjectStore::deleteFunction"); … … 382 386 RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec) 383 387 { 384 return deleteFunction(context, key.jsValue(), ec);385 } 386 387 RefPtr< WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, JSC::JSValue key, ExceptionCodeWithMessage& ec)388 return modernDelete(context, key.jsValue(), ec); 389 } 390 391 RefPtr<IDBRequest> IDBObjectStore::modernDelete(ScriptExecutionContext* context, JSC::JSValue key, ExceptionCodeWithMessage& ec) 388 392 { 389 393 DOMRequestState requestState(context); … … 395 399 } 396 400 397 return d eleteFunction(context, &IDBKeyRange::create(idbKey.get()).get(), ec);401 return doDelete(context, &IDBKeyRange::create(idbKey.get()).get(), ec); 398 402 } 399 403 -
trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h
r193878 r195997 81 81 82 82 RefPtr<IDBRequest> putForCursorUpdate(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCodeWithMessage&); 83 84 RefPtr<WebCore::IDBRequest> deleteFunction(ScriptExecutionContext*, JSC::JSValue key, ExceptionCodeWithMessage&); 83 RefPtr<IDBRequest> modernDelete(ScriptExecutionContext*, JSC::JSValue key, ExceptionCodeWithMessage&); 85 84 86 85 void markAsDeleted(); … … 105 104 RefPtr<IDBRequest> putOrAdd(JSC::ExecState&, JSC::JSValue, RefPtr<IDBKey>, IndexedDB::ObjectStoreOverwriteMode, InlineKeyCheck, ExceptionCodeWithMessage&); 106 105 RefPtr<WebCore::IDBRequest> doCount(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&); 106 RefPtr<IDBRequest> doDelete(ScriptExecutionContext* context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec); 107 107 108 108 IDBObjectStoreInfo m_info; -
trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp
r194872 r195997 153 153 void IDBRequest::setSource(IDBCursor& cursor) 154 154 { 155 ASSERT(!m_cursorRequestNotifier); 156 155 157 m_source = IDBAny::create(cursor); 158 m_cursorRequestNotifier = std::make_unique<ScopeGuard>([this]() { 159 ASSERT(m_source->type() == IDBAny::Type::IDBCursor || m_source->type() == IDBAny::Type::IDBCursorWithValue); 160 m_source->modernIDBCursor()->decrementOutstandingRequestCount(); 161 }); 156 162 } 157 163 … … 284 290 m_hasPendingActivity = false; 285 291 292 m_cursorRequestNotifier = nullptr; 293 286 294 bool dontPreventDefault; 287 295 { … … 365 373 ASSERT(!m_pendingCursor); 366 374 ASSERT(&cursor == resultCursor()); 375 ASSERT(!m_cursorRequestNotifier); 367 376 368 377 m_pendingCursor = &cursor; … … 372 381 m_domError = nullptr; 373 382 m_idbError = { }; 383 384 m_cursorRequestNotifier = std::make_unique<ScopeGuard>([this]() { 385 m_pendingCursor->decrementOutstandingRequestCount(); 386 }); 374 387 } 375 388 … … 385 398 } 386 399 400 m_cursorRequestNotifier = nullptr; 387 401 m_pendingCursor = nullptr; 388 402 -
trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h
r194754 r195997 33 33 #include "IDBResourceIdentifier.h" 34 34 #include "IDBTransactionImpl.h" 35 #include "ScopeGuard.h" 35 36 #include <wtf/RefCounted.h> 36 37 … … 147 148 148 149 RefPtr<IDBCursor> m_pendingCursor; 150 151 std::unique_ptr<ScopeGuard> m_cursorRequestNotifier; 149 152 }; 150 153 -
trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
r195689 r195997 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 35 35 #include "IDBTransactionInfo.h" 36 36 #include "Logging.h" 37 #include "ScopeGuard.h" 37 38 #include "UniqueIDBDatabaseConnection.h" 38 39 #include <wtf/MainThread.h> … … 675 676 return *globalObject.get()->globalExec(); 676 677 } 677 678 class ScopeGuard {679 public:680 ScopeGuard()681 {682 }683 684 ScopeGuard(std::function<void()> function)685 : m_function(WTFMove(function))686 {687 }688 689 ~ScopeGuard()690 {691 if (m_function)692 m_function();693 }694 695 void enable(std::function<void()> function)696 {697 m_function = WTFMove(function);698 }699 700 void disable()701 {702 m_function = nullptr;703 }704 705 private:706 std::function<void()> m_function { nullptr };707 };708 678 709 679 void UniqueIDBDatabase::performPutOrAdd(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData& keyData, const ThreadSafeDataBuffer& originalRecordValue, IndexedDB::ObjectStoreOverwriteMode overwriteMode) -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r195954 r195997 1980 1980 51405C88190B014400754F94 /* SelectionRectGatherer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51405C86190B014400754F94 /* SelectionRectGatherer.cpp */; }; 1981 1981 51405C89190B014400754F94 /* SelectionRectGatherer.h in Headers */ = {isa = PBXBuildFile; fileRef = 51405C87190B014400754F94 /* SelectionRectGatherer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1982 5141298E1C5FD83A0059E714 /* JSIDBCursorWithValueCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5141298D1C5FD7E90059E714 /* JSIDBCursorWithValueCustom.cpp */; }; 1983 514129901C601ACC0059E714 /* ScopeGuard.h in Headers */ = {isa = PBXBuildFile; fileRef = 5141298F1C601A890059E714 /* ScopeGuard.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1982 1984 5145B1091BC48E2E00E86219 /* IDBResourceIdentifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5145B1071BC4890B00E86219 /* IDBResourceIdentifier.cpp */; }; 1983 1985 5145B10A1BC48E2E00E86219 /* IDBResourceIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 5145B1081BC4890B00E86219 /* IDBResourceIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 9468 9470 51405C86190B014400754F94 /* SelectionRectGatherer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectionRectGatherer.cpp; sourceTree = "<group>"; }; 9469 9471 51405C87190B014400754F94 /* SelectionRectGatherer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionRectGatherer.h; sourceTree = "<group>"; }; 9472 5141298D1C5FD7E90059E714 /* JSIDBCursorWithValueCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBCursorWithValueCustom.cpp; sourceTree = "<group>"; }; 9473 5141298F1C601A890059E714 /* ScopeGuard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopeGuard.h; sourceTree = "<group>"; }; 9470 9474 5145B1071BC4890B00E86219 /* IDBResourceIdentifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBResourceIdentifier.cpp; sourceTree = "<group>"; }; 9471 9475 5145B1081BC4890B00E86219 /* IDBResourceIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBResourceIdentifier.h; sourceTree = "<group>"; }; … … 22305 22309 511EF2CC17F0FDF100E4FA16 /* JSIDBAnyCustom.cpp */, 22306 22310 512BDB4C1C46B0FF006494DF /* JSIDBCursorCustom.cpp */, 22311 5141298D1C5FD7E90059E714 /* JSIDBCursorWithValueCustom.cpp */, 22307 22312 511EF2CD17F0FDF100E4FA16 /* JSIDBDatabaseCustom.cpp */, 22308 22313 511EF2CE17F0FDF100E4FA16 /* JSIDBObjectStoreCustom.cpp */, … … 22795 22800 5162C7F211F77EFA00612EFE /* SchemeRegistry.cpp */, 22796 22801 5162C7F311F77EFB00612EFE /* SchemeRegistry.h */, 22802 5141298F1C601A890059E714 /* ScopeGuard.h */, 22797 22803 BC8AE34C12EA096A00EB3AE6 /* ScrollableArea.cpp */, 22798 22804 BC8AE34D12EA096A00EB3AE6 /* ScrollableArea.h */, … … 25642 25648 31C0FF4E0E4CEFDD007D6FE5 /* DOMWebKitTransitionEventInternal.h in Headers */, 25643 25649 85C7F5E70AAFBAFB004014DD /* DOMWheelEvent.h in Headers */, 25650 514129901C601ACC0059E714 /* ScopeGuard.h in Headers */, 25644 25651 85989DD10ACC8BBD00A0BC51 /* DOMWheelEventInternal.h in Headers */, 25645 25652 1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */, … … 31252 31259 1A22464B0CC98DDB00C05240 /* SQLiteStatement.cpp in Sources */, 31253 31260 1A22464D0CC98DDB00C05240 /* SQLiteTransaction.cpp in Sources */, 31261 5141298E1C5FD83A0059E714 /* JSIDBCursorWithValueCustom.cpp in Sources */, 31254 31262 97BC6A411505F081001B74AC /* SQLResultSet.cpp in Sources */, 31255 31263 97BC6A441505F081001B74AC /* SQLResultSetRowList.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.