-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: StorageArea.getKeys()
#601
Comments
@polywock I plan to implement this in Chromium as part of some work I am doing on the storage API. I’ve started a proposal PR using the template - would you like to work together on finishing that, or are you happy for me to open it? Thanks! |
@oliverdunk I appreciate the offer to be involved. But, I'll probably slow down the process. Please go ahead without me. Thank you! |
I have opened a proposal for this in #649. |
Pull request has been approved and merged. 🚀 |
Re-opening this ticket because we usually keep tickets open until there is nothing left to be done. In this case, we can use this ticket to signal the cross-browser implementation status of the feature (as issue labels here). I have opened https://bugzilla.mozilla.org/show_bug.cgi?id=1910669 to track the implementation in Firefox. |
StorageArea.getKeys()
https://bugs.webkit.org/show_bug.cgi?id=280275 Reviewed by NOBODY (OOPS!). This patch implements a web extension API to retrieve all keys for a given storage area in the browser.storage API. WECG Proposal: https://github.com/w3c/webextensions/blob/main/proposals/storage-get-keys.md WECG Original Issue: w3c/webextensions#601 * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIStorageCocoa.mm: (WebKit::WebExtensionContext::storageGetKeys): * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.h: * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.mm: (-[_WKWebExtensionStorageSQLiteStore getAllKeys:]): (-[_WKWebExtensionStorageSQLiteStore getValuesForKeys:completionHandler:]): * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIStorageAreaCocoa.mm: (WebKit::WebExtensionAPIStorageArea::getKeys): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIStorageArea.h: * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIStorageArea.idl: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIStorage.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, Errors)): (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, GetKeys)):
https://bugs.webkit.org/show_bug.cgi?id=280275 Reviewed by NOBODY (OOPS!). This patch implements a web extension API to retrieve all keys for a given storage area in the browser.storage API. WECG Proposal Issue: https://github.com/w3c/webextensions/blob/main/proposals/storage-get-keys.md WECG Original Issue: w3c/webextensions#601 * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIStorageCocoa.mm: (WebKit::WebExtensionContext::storageGetKeys): * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.h: * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.mm: (-[_WKWebExtensionStorageSQLiteStore getAllKeys:]): (-[_WKWebExtensionStorageSQLiteStore getValuesForKeys:completionHandler:]): * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIStorageAreaCocoa.mm: (WebKit::WebExtensionAPIStorageArea::getKeys): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIStorageArea.h: * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIStorageArea.idl: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIStorage.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, Errors)): (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, GetKeys)):
https://bugs.webkit.org/show_bug.cgi?id=280275 Reviewed by NOBODY (OOPS!). This patch implements a web extension API to retrieve all keys for a given storage area in the browser.storage API. WECG Proposal: https://github.com/w3c/webextensions/blob/main/proposals/storage-get-keys.md WECG Original Issue: w3c/webextensions#601 * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIStorageCocoa.mm: (WebKit::WebExtensionContext::storageGetKeys): * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.h: * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.mm: (-[_WKWebExtensionStorageSQLiteStore getAllKeys:]): (-[_WKWebExtensionStorageSQLiteStore getValuesForKeys:completionHandler:]): * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIStorageAreaCocoa.mm: (WebKit::WebExtensionAPIStorageArea::getKeys): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIStorageArea.h: * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIStorageArea.idl: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIStorage.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, Errors)): (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, GetKeys)):
https://bugs.webkit.org/show_bug.cgi?id=280275 Reviewed by NOBODY (OOPS!). This patch implements a web extension API to retrieve all keys for a given storage area in the browser.storage API. WECG Proposal: https://github.com/w3c/webextensions/blob/main/proposals/storage-get-keys.md WECG Original Issue: w3c/webextensions#601 This patch also includes the following clean-ups: - Change 'auto' to 'auto *' when assigning the result of WebExtensionContext::storageForType() to explicitly denote pointer type. - Update strongSelf retrieval to in _WKWebExtensionStorageSQLiteStore.mm methods to leverage ARC in extension code, allowing the use of Objective-C pointers instead of RetainPtr, which is only necessary in other parts of WebKit that do not utilize ARC. - Remove unnecessary explicit template types from WeakObjCPtr in _WKWebExtensionStorageSQLiteStore. * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIStorageCocoa.mm: (WebKit::WebExtensionContext::storageGet): (WebKit::WebExtensionContext::storageGetKeys): (WebKit::WebExtensionContext::storageGetBytesInUse): * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.h: * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.mm: (-[_WKWebExtensionStorageSQLiteStore getAllKeys:]): (-[_WKWebExtensionStorageSQLiteStore getValuesForKeys:completionHandler:]): (-[_WKWebExtensionStorageSQLiteStore getStorageSizeForKeys:completionHandler:]): (-[_WKWebExtensionStorageSQLiteStore getStorageSizeForAllKeysIncludingKeyedData:withCompletionHandler:]): (-[_WKWebExtensionStorageSQLiteStore setKeyedData:completionHandler:]): (-[_WKWebExtensionStorageSQLiteStore deleteValuesForKeys:completionHandler:]): * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIStorageAreaCocoa.mm: (WebKit::WebExtensionAPIStorageArea::getKeys): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIStorageArea.h: * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIStorageArea.idl: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIStorage.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, Errors)): (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, GetKeys)):
https://bugs.webkit.org/show_bug.cgi?id=280275 Reviewed by NOBODY (OOPS!). This patch implements a web extension API to retrieve all keys for a given storage area in the browser.storage API. WECG Proposal: https://github.com/w3c/webextensions/blob/main/proposals/storage-get-keys.md WECG Original Issue: w3c/webextensions#601 This patch also includes the following clean-ups: - Change 'auto' to 'auto *' when assigning the result of WebExtensionContext::storageForType() to explicitly denote pointer type. - Update strongSelf retrieval to in _WKWebExtensionStorageSQLiteStore.mm methods to leverage ARC in extension code, allowing the use of Objective-C pointers instead of RetainPtr, which is only necessary in other parts of WebKit that do not utilize ARC. - Remove unnecessary explicit template types from WeakObjCPtr in _WKWebExtensionStorageSQLiteStore. * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIStorageCocoa.mm: (WebKit::WebExtensionContext::storageGet): (WebKit::WebExtensionContext::storageGetKeys): (WebKit::WebExtensionContext::storageGetBytesInUse): * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.h: * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.mm: (-[_WKWebExtensionStorageSQLiteStore getAllKeys:]): (-[_WKWebExtensionStorageSQLiteStore getValuesForKeys:completionHandler:]): (-[_WKWebExtensionStorageSQLiteStore getStorageSizeForKeys:completionHandler:]): (-[_WKWebExtensionStorageSQLiteStore getStorageSizeForAllKeysIncludingKeyedData:withCompletionHandler:]): (-[_WKWebExtensionStorageSQLiteStore setKeyedData:completionHandler:]): (-[_WKWebExtensionStorageSQLiteStore deleteValuesForKeys:completionHandler:]): * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIStorageAreaCocoa.mm: (WebKit::WebExtensionAPIStorageArea::getKeys): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIStorageArea.h: * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIStorageArea.idl: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIStorage.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, Errors)): (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, GetKeys)):
https://bugs.webkit.org/show_bug.cgi?id=280275 Reviewed by Timothy Hatcher. This patch implements a web extension API to retrieve all keys for a given storage area in the browser.storage API. WECG Proposal: https://github.com/w3c/webextensions/blob/main/proposals/storage-get-keys.md WECG Original Issue: w3c/webextensions#601 This patch also includes the following clean-ups: - Change 'auto' to 'auto *' when assigning the result of WebExtensionContext::storageForType() to explicitly denote pointer type. - Update strongSelf retrieval to in _WKWebExtensionStorageSQLiteStore.mm methods to leverage ARC in extension code, allowing the use of Objective-C pointers instead of RetainPtr, which is only necessary in other parts of WebKit that do not utilize ARC. - Remove unnecessary explicit template types from WeakObjCPtr in _WKWebExtensionStorageSQLiteStore. * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIStorageCocoa.mm: (WebKit::WebExtensionContext::storageGet): (WebKit::WebExtensionContext::storageGetKeys): (WebKit::WebExtensionContext::storageGetBytesInUse): * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.h: * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionStorageSQLiteStore.mm: (-[_WKWebExtensionStorageSQLiteStore getAllKeys:]): (-[_WKWebExtensionStorageSQLiteStore getValuesForKeys:completionHandler:]): (-[_WKWebExtensionStorageSQLiteStore getStorageSizeForKeys:completionHandler:]): (-[_WKWebExtensionStorageSQLiteStore getStorageSizeForAllKeysIncludingKeyedData:withCompletionHandler:]): (-[_WKWebExtensionStorageSQLiteStore setKeyedData:completionHandler:]): (-[_WKWebExtensionStorageSQLiteStore deleteValuesForKeys:completionHandler:]): * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIStorageAreaCocoa.mm: (WebKit::WebExtensionAPIStorageArea::getKeys): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIStorageArea.h: * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIStorageArea.idl: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIStorage.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, Errors)): (TestWebKitAPI::TEST(WKWebExtensionAPIStorage, GetKeys)): Canonical link: https://commits.webkit.org/284602@main
Safari landed this in the their technology preview release: 🎉
Missing: |
Taken from #505, as an alternative proposal suggested by @tophf and @Rob--W. It's significantly different from my original proposal, so I'm creating a separate proposal for it.
Background
I regularly need to use storage keys that involve dynamic elements like flag:[tabId]. The only way to get all keys starting with the prefix
flag:
is using StorageArea.get() to get all the storage items and then to filter.This isn't efficient. The storage areas support 10MB of data and even more with the unlimitedStorage permission. That's potentially a huge amount of storage data that needs to be serialized and sent over. There's also a special concern when using the Sync storage area.
Proposal
A method to get all keys without the corresponding values.
Resources
https://developer.mozilla.org/en-US/docs/Web/API/IDBIndex/getAllKeys
The text was updated successfully, but these errors were encountered: