diff options
| author | Ben Murdoch <benm@google.com> | 2009-08-25 19:38:07 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2009-08-26 12:27:28 +0100 |
| commit | 25a1523642bead2f7e7f929ba9d6d1143dce06a0 (patch) | |
| tree | fd9b52815cc32b52afe5cb2563027405fd0bf22e /src/com/android/browser/WebStorageSizeManager.java | |
| parent | 416b7cbd57715f5330fabe118aa8d1d3d7ac3ef9 (diff) | |
Use the estimated size of new databases as the default quota if we have enough space to satisfy it.
Change-Id:I23daac8fbf27f50f304ee53060353423deaed50a
Diffstat (limited to 'src/com/android/browser/WebStorageSizeManager.java')
| -rw-r--r-- | src/com/android/browser/WebStorageSizeManager.java | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/com/android/browser/WebStorageSizeManager.java b/src/com/android/browser/WebStorageSizeManager.java index 40d30a2a..d5347cb5 100644 --- a/src/com/android/browser/WebStorageSizeManager.java +++ b/src/com/android/browser/WebStorageSizeManager.java @@ -72,18 +72,11 @@ import java.util.Set; * sum of all other origins' quota) and deciding if a quota increase for the * out-of-space origin is allowed or not. * - * The default quota for an origin is min(ORIGIN_DEFAULT_QUOTA, unused_quota). + * The default quota for an origin is its estimated size. If we cannot satisfy + * the estimated size, then WebCore will not create the database. * Quota increases are done in steps, where the increase step is * min(QUOTA_INCREASE_STEP, unused_quota). * - * This approach has the drawback that space may remain unused if there - * are many websites that store a lot less content than ORIGIN_DEFAULT_QUOTA. - * We deal with this by picking a value for ORIGIN_DEFAULT_QUOTA that is smaller - * than what the HTML 5 spec recommends. At the same time, picking a very small - * value for ORIGIN_DEFAULT_QUOTA may create performance problems since it's - * more likely for origins to have to rollback and restart transactions as a - * result of reaching the quota more often. - * * When all the Web storage space is used, the WebStorageSizeManager creates * a system notification that will guide the user to the WebSettings UI. There, * the user can free some of the Web storage space by deleting all the data used @@ -215,8 +208,8 @@ class WebStorageSizeManager { * deny quota has been made. Don't forget to call this! */ public void onExceededDatabaseQuota(String url, - String databaseIdentifier, long currentQuota, long totalUsedQuota, - WebStorage.QuotaUpdater quotaUpdater) { + String databaseIdentifier, long currentQuota, long estimatedSize, + long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) { if(LOGV_ENABLED) { Log.v(LOGTAG, "Received onExceededDatabaseQuota for " @@ -252,9 +245,22 @@ class WebStorageSizeManager { // We have enough space inside mGlobalLimit. long newOriginQuota = currentQuota; if (newOriginQuota == 0) { - // This is a new origin. It wants an initial quota. - newOriginQuota = - Math.min(ORIGIN_DEFAULT_QUOTA, totalUnusedQuota); + // This is a new origin, give it the size it asked for if possible. + // If we cannot satisfy the estimatedSize, we should return 0 as + // returning a value less that what the site requested will lead + // to webcore not creating the database. + if (totalUnusedQuota >= estimatedSize) { + newOriginQuota = estimatedSize; + } else { + if (LOGV_ENABLED) { + Log.v(LOGTAG, + "onExceededDatabaseQuota: Unable to satisfy" + + " estimatedSize for the new database " + + " (estimatedSize: " + estimatedSize + + ", unused quota: " + totalUnusedQuota); + } + newOriginQuota = 0; + } } else { // This is an origin we have seen before. It wants a quota // increase. @@ -379,4 +385,5 @@ class WebStorageSizeManager { mgr.notify(OUT_OF_SPACE_ID, notification); } } -}
\ No newline at end of file +} + |
