Bug 29991 - Implement per-storage-area quotas for LocalStorage
Summary: Implement per-storage-area quotas for LocalStorage
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Jeremy Orlow
URL:
Keywords:
: 22765 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-10-01 18:38 PDT by Jeremy Orlow
Modified: 2009-10-05 13:39 PDT (History)
3 users (show)

See Also:


Attachments
Patch v1 (25.21 KB, patch)
2009-10-01 18:40 PDT, Jeremy Orlow
dglazkov: review+
jorlow: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Orlow 2009-10-01 18:38:06 PDT
Implement per-storage-area quotas for LocalStorage

There are two previous bugs for this that attempted to solve this in different ways but were eventually abandoned: https://bugs.webkit.org/show_bug.cgi?id=26155 and https://bugs.webkit.org/show_bug.cgi?id=22765  I've cc'ed their owners on this one.

I put 90% of the code in StorageMap since the decision to allow an update is closely tied to quota tracking.  The quota is set via a page's Settings class.  Like with the local storage path and whether it's enabled, it's assumed that all pages in the same group will have the same settings.  The setting defaults to 5mb which is what the spec suggests, but it can easily be changed to anything else--including StorageMap::noQuota.  Any values in LocalStorage are grandfathered in regarudless of quota, so importItem only tracks (and will never block) imports.

I believe this change is a good transition to more complex quota management.  For example, if we wanted to track quotas in the SQLite DB, then we'd just add a function to the StorageMap that sets the quota.  This would be fine since all use of LocalStorage is blocked on the import completing, so you'd never hit a quota error in the mean time.  Also, if embedders wanted to ask the user whether to expand the quota whenever it's hit (before deciding whether or not to raise an exception), a callback via the chrome client should be fairly easy.  That said, I think it's best to add these features in steps rather than one huge patch.  (Both of these are on my TODO list, btw.)

Included is a layout test that verifies the behavior.  It assumes the default quota is 5mb (since that's what Settings defaults to).

I'll post the patch in a moment.
Comment 1 Jeremy Orlow 2009-10-01 18:40:29 PDT
Created attachment 40489 [details]
Patch v1
Comment 2 Dimitri Glazkov (Google) 2009-10-02 11:53:40 PDT
Comment on attachment 40489 [details]
Patch v1

r=me.
Comment 3 Yael 2009-10-05 13:39:21 PDT
*** Bug 22765 has been marked as a duplicate of this bug. ***