WebKit Bugzilla
Attachment 348060 Details for
Bug 188938
: Make IDBCursor::m_request a WeakPtr
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188938-20180824172649.patch (text/plain), 4.71 KB, created by
youenn fablet
on 2018-08-24 17:26:50 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2018-08-24 17:26:50 PDT
Size:
4.71 KB
patch
obsolete
>Subversion Revision: 235321 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 0db27f8d3b6356c0d282988952996b01dbb6fd48..3ec15653f7f8f14a8050bf46be8385b53cd48354 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,24 @@ >+2018-08-24 Youenn Fablet <youenn@apple.com> >+ >+ Make IDBCursor::m_request a WeakPtr >+ https://bugs.webkit.org/show_bug.cgi?id=188938 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Make m_request a WeakPtr so that if m_request is destroyed, the related cursor will not use the invalid pointer. >+ >+ Covered by existing tests. >+ >+ * Modules/indexeddb/IDBCursor.cpp: >+ (WebCore::IDBCursor::continuePrimaryKey): Other continue and advance methods that are calling uncheckedIterateCursor do check for m_request. >+ Apply the same check for continuePrimaryKey. >+ (WebCore::IDBCursor::uncheckedIterateCursor): >+ * Modules/indexeddb/IDBCursor.h: >+ (WebCore::IDBCursor::setRequest): >+ (WebCore::IDBCursor::clearRequest): >+ (WebCore::IDBCursor::request): >+ * Modules/indexeddb/IDBRequest.h: >+ > 2018-08-24 Andy Estes <aestes@apple.com> > > [Apple Pay] Allow $0 totals >diff --git a/Source/WebCore/Modules/indexeddb/IDBCursor.cpp b/Source/WebCore/Modules/indexeddb/IDBCursor.cpp >index 05db83417e5c01c9567a52c02b29dc2760a370c0..d84590a078eb5bf25ea9dffc0dfab4eb4d02b920 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBCursor.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBCursor.cpp >@@ -174,6 +174,9 @@ ExceptionOr<void> IDBCursor::advance(unsigned count) > > ExceptionOr<void> IDBCursor::continuePrimaryKey(ExecState& state, JSValue keyValue, JSValue primaryKeyValue) > { >+ if (!m_request) >+ return Exception { InvalidStateError }; >+ > if (!transaction().isActive()) > return Exception { TransactionInactiveError, "Failed to execute 'continuePrimaryKey' on 'IDBCursor': The transaction is inactive or finished."_s }; > >@@ -267,6 +270,7 @@ ExceptionOr<void> IDBCursor::continueFunction(const IDBKeyData& key) > > void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, unsigned count) > { >+ ASSERT(m_request); > ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current()); > > ++m_outstandingRequestCount; >@@ -277,6 +281,7 @@ void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, unsigned count) > > void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, const IDBKeyData& primaryKey) > { >+ ASSERT(m_request); > ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current()); > > ++m_outstandingRequestCount; >diff --git a/Source/WebCore/Modules/indexeddb/IDBCursor.h b/Source/WebCore/Modules/indexeddb/IDBCursor.h >index 49030569911a77979eaddd934ae0480c42841886..bb7e10d2e8ef298a280d739b0c161e187d737c72 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBCursor.h >+++ b/Source/WebCore/Modules/indexeddb/IDBCursor.h >@@ -33,6 +33,7 @@ > #include "IDBCursorInfo.h" > #include <JavaScriptCore/Strong.h> > #include <wtf/Variant.h> >+#include <wtf/WeakPtr.h> > > namespace WebCore { > >@@ -66,9 +67,9 @@ public: > > const IDBCursorInfo& info() const { return m_info; } > >- void setRequest(IDBRequest& request) { m_request = &request; } >- void clearRequest() { m_request = nullptr; } >- IDBRequest* request() { return m_request; } >+ void setRequest(IDBRequest& request) { m_request = makeWeakPtr(&request); } >+ void clearRequest() { m_request.clear(); } >+ IDBRequest* request() { return m_request.get(); } > > void setGetResult(IDBRequest&, const IDBGetResult&); > >@@ -98,7 +99,7 @@ private: > > IDBCursorInfo m_info; > Source m_source; >- IDBRequest* m_request { nullptr }; >+ WeakPtr<IDBRequest> m_request; > > bool m_gotValue { false }; > >diff --git a/Source/WebCore/Modules/indexeddb/IDBRequest.h b/Source/WebCore/Modules/indexeddb/IDBRequest.h >index e914344fe8dfdc4d06a0684112ea67f042f1c6c3..0061566cf1ffd81b63253ffb3997cf6d584b25a5 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBRequest.h >+++ b/Source/WebCore/Modules/indexeddb/IDBRequest.h >@@ -36,6 +36,7 @@ > #include <JavaScriptCore/Strong.h> > #include <wtf/Function.h> > #include <wtf/Scope.h> >+#include <wtf/WeakPtr.h> > > namespace WebCore { > >@@ -56,7 +57,7 @@ class IDBConnectionProxy; > class IDBConnectionToServer; > } > >-class IDBRequest : public EventTargetWithInlineData, public IDBActiveDOMObject, public RefCounted<IDBRequest> { >+class IDBRequest : public EventTargetWithInlineData, public IDBActiveDOMObject, public RefCounted<IDBRequest>, public CanMakeWeakPtr<IDBRequest> { > public: > static Ref<IDBRequest> create(ScriptExecutionContext&, IDBObjectStore&, IDBTransaction&); > static Ref<IDBRequest> create(ScriptExecutionContext&, IDBCursor&, IDBTransaction&);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188938
: 348060