Expose getBytesInUse to browser.storage.sync consumers
Categories
(WebExtensions :: Storage, enhancement, P1)
Tracking
(firefox78 fixed)
Tracking | Status | |
---|---|---|
firefox78 | --- | fixed |
People
(Reporter: markh, Assigned: markh)
References
Details
(Keywords: dev-doc-complete)
Attachments
(1 file, 1 obsolete file)
Bug 1637165 adds them to the core implementation, but this bug is to expose them to extensions. It also depends on the core browser.storage.sync implementation in bug 1623245.
Assignee | ||
Comment 1•4 years ago
|
||
Depends on D74610
Assignee | ||
Comment 2•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Comment 3•4 years ago
|
||
Hi Luca,
I've attached a WIP in phabricator - thanks to your help, I was able to have getBytesInUse()
exposed, but I still can't work out how to get the constants exposed. I've left a few attempts in the patch and what I hope to test. It would be great if you could give me some advice on how to get these constants working!
Updated•4 years ago
|
Pushed by mhammond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c4e34b335521 Expose getBytesInUse to browser.storage.sync consumers. r=rpl
Comment 5•4 years ago
|
||
bugherder |
Comment 6•4 years ago
|
||
Just noticed that we didn't add the dev-doc-needed keyword on this issue.
We should add to the MDN docs (and also in the browser-compat-data as well) the following changes:
- mention
browser.storage.getBytesInUse
is supported in Firefox >= 78, - mention that only the
browser.storage.sync
area is supporting thegetBytesInUse
method (on the contrary is still NOT supported in all other storage areas, e.g.browser.storage.local.getBytesInUse
is still not available and marked as unsupported)
Comment 7•4 years ago
|
||
I've updated https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/sync#Storage_quotas_for_sync_data with information on the quotas, and also pointed to that from https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/set.
I've also updated BCD to:
- note that Firefox did not previously enforce storage limits, but now does: https://github.com/mdn/browser-compat-data/pull/6399
- update Firefox compat data to say that getBytesInUse is now supported, in sync storage only: https://github.com/mdn/browser-compat-data/pull/6398
The BCD PRs are not yet deployed, so won't appear in pages for a couple more days at least.
Please let me know if you think this covers it.
I did have one question: there are three storage limits (total size, item size, item count) but getBytesInUse can only help with one of these. This makes getBytesInUse seem not terribly useful, since extensions still have to deal with this error. Am I missing something here?
Assignee | ||
Comment 8•4 years ago
|
||
(In reply to Will Bamberg [:wbamberg] from comment #7)
I did have one question: there are three storage limits (total size, item size, item count) but getBytesInUse can only help with one of these. This makes getBytesInUse seem not terribly useful, since extensions still have to deal with this error. Am I missing something here?
It's useful for total size and item size (it takes an arg which will calculate the latter) - but yeah, it's no help for item count. Consumers would need to get all storage and do something like Object.keys(...).length
or similar (but they could also do that to work out the others, so :shrug!). Obviously it would be quite easy to add a new API, but chrome doesn't define one so we didn't.
Comment 9•4 years ago
|
||
(In reply to Will Bamberg [:wbamberg] from comment #7)
I've updated https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/sync#Storage_quotas_for_sync_data with information on the quotas, and also pointed to that from https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/set.
Thanks Will, the updates applied on these two pages looks good to me.
I've also updated BCD to:
- note that Firefox did not previously enforce storage limits, but now does: https://github.com/mdn/browser-compat-data/pull/6399
- update Firefox compat data to say that getBytesInUse is now supported, in sync storage only: https://github.com/mdn/browser-compat-data/pull/6398
The BCD PRs are not yet deployed, so won't appear in pages for a couple more days at least.
Thanks!
As a side note, https://github.com/mdn/browser-compat-data/pull/6398 has not been merged yet (and so it doesn't appear yet in the compatibility table, on the contrary https://github.com/mdn/browser-compat-data/pull/6399 is already deployed and it is already visible in the compatibility table as expected).
Please let me know if you think this covers it.
lgtm
I did have one question: there are three storage limits (total size, item size, item count) but getBytesInUse can only help with one of these. This makes getBytesInUse seem not terribly useful, since extensions still have to deal with this error. Am I missing something here?
I confirm what Mark already described in comment 8.
Updated•4 years ago
|
Description
•