Closed Bug 1637166 Opened 4 years ago Closed 4 years ago

Expose getBytesInUse to browser.storage.sync consumers

Categories

(WebExtensions :: Storage, enhancement, P1)

enhancement

Tracking

(firefox78 fixed)

RESOLVED FIXED
mozilla78
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.

Attachment #9147539 - Attachment is obsolete: true

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!

Attachment #9149769 - Attachment description: Bug 1637166 - Expose quota constants and getBytesInUse to browser.storage.sync consumers. r?rpl → Bug 1637166 - Expose getBytesInUse to browser.storage.sync consumers. r?rpl
Pushed by mhammond@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c4e34b335521
Expose getBytesInUse to browser.storage.sync consumers. r=rpl
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla78

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 the getBytesInUse 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)
Keywords: dev-doc-needed

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:

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?

Flags: needinfo?(lgreco)

(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.

(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:

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.

Flags: needinfo?(lgreco)

Thanks Luca!

Summary: Expose quota constants and getBytesInUse to browser.storage.sync consumers → Expose getBytesInUse to browser.storage.sync consumers
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: