diff options
author | Ben Murdoch <benm@google.com> | 2010-02-09 17:03:07 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-02-18 19:17:31 +0000 |
commit | 34b89ef113c7e5e365f75ec692a98a5484834ca0 (patch) | |
tree | 35954444ffed1b7b4cf2610d9e8d5941294e83bd /src/com/android/browser/WebStorageSizeManager.java | |
parent | 96ab239a56b9efc53794a900128fa449853f5f1e (diff) | |
download | packages_apps_Browser-34b89ef113c7e5e365f75ec692a98a5484834ca0.zip packages_apps_Browser-34b89ef113c7e5e365f75ec692a98a5484834ca0.tar.gz packages_apps_Browser-34b89ef113c7e5e365f75ec692a98a5484834ca0.tar.bz2 |
When a second database is created on an origin, ensure that the quota for that origin is large enough to cover both databases (old and new).
Fix for 2417477
Change-Id: I914b29a5f90a11fe3c3dc9a927a8720197b03560
Diffstat (limited to 'src/com/android/browser/WebStorageSizeManager.java')
-rw-r--r-- | src/com/android/browser/WebStorageSizeManager.java | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/com/android/browser/WebStorageSizeManager.java b/src/com/android/browser/WebStorageSizeManager.java index 3afcadc..dcf2f8b 100644 --- a/src/com/android/browser/WebStorageSizeManager.java +++ b/src/com/android/browser/WebStorageSizeManager.java @@ -209,6 +209,9 @@ class WebStorageSizeManager { * @param databaseIdentifier the identifier of the database on * which the transaction that caused the quota overflow was run * @param currentQuota the current quota for the origin. + * @param estimatedSize the estimated size of a new database, or 0 if + * this has been invoked in response to an existing database + * overflowing its quota. * @param totalUsedQuota is the sum of all origins' quota. * @param quotaUpdater The callback to run when a decision to allow or * deny quota has been made. Don't forget to call this! @@ -248,7 +251,8 @@ class WebStorageSizeManager { } return; } - // We have enough space inside mGlobalLimit. + + // We have some space inside mGlobalLimit. long newOriginQuota = currentQuota; if (newOriginQuota == 0) { // This is a new origin, give it the size it asked for if possible. @@ -260,19 +264,31 @@ class WebStorageSizeManager { } else { if (LOGV_ENABLED) { Log.v(LOGTAG, - "onExceededDatabaseQuota: Unable to satisfy" + - " estimatedSize for the new database " + - " (estimatedSize: " + estimatedSize + - ", unused quota: " + totalUnusedQuota); + "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. - newOriginQuota += - Math.min(QUOTA_INCREASE_STEP, totalUnusedQuota); + // increase. There are two circumstances: either the origin + // is creating a new database or it has overflowed an existing database. + + // Increase the quota. If estimatedSize == 0, then this is a quota overflow + // rather than the creation of a new database. + long quotaIncrease = estimatedSize == 0 ? + Math.min(QUOTA_INCREASE_STEP, totalUnusedQuota) : + estimatedSize; + newOriginQuota += quotaIncrease; + + if (quotaIncrease > totalUnusedQuota) { + // We can't fit, so deny quota. + newOriginQuota = currentQuota; + } } + quotaUpdater.updateQuota(newOriginQuota); if(LOGV_ENABLED) { |