[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.16-1409-g5afdf4d
jorlow at chromium.org
jorlow at chromium.org
Thu Dec 3 13:36:38 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit bb7fb2fbcd0e27227d9cd5196340a19b3ea0d21a
Author: jorlow at chromium.org <jorlow at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Nov 14 00:27:25 2009 +0000
2009-11-12 Jeremy Orlow <jorlow at chromium.org>
Reviewed by Dmitry Titov.
LocalStorage quota should include key sizes in its count
https://bugs.webkit.org/show_bug.cgi?id=31451
* storage/StorageMap.cpp:
(WebCore::StorageMap::setItem):
Count keys in the quota when adding a new item.
(WebCore::StorageMap::removeItem):
Remove the key's length from the quota if we're removing the item.
(WebCore::StorageMap::importItem):
Assume that we're adding things for the first time.
Count keys in the quota.
2009-11-12 Jeremy Orlow <jorlow at chromium.org>
Reviewed by Dmitry Titov.
Now that we're tracking key size in the quota, we can't fit as much in.
https://bugs.webkit.org/show_bug.cgi?id=31451
* storage/domstorage/quota-expected.txt:
* storage/domstorage/script-tests/quota.js:
(testQuota):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5f1a28e..a79a96c 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2009-11-12 Jeremy Orlow <jorlow at chromium.org>
+
+ Reviewed by Dmitry Titov.
+
+ Now that we're tracking key size in the quota, we can't fit as much in.
+ https://bugs.webkit.org/show_bug.cgi?id=31451
+
+ * storage/domstorage/quota-expected.txt:
+ * storage/domstorage/script-tests/quota.js:
+ (testQuota):
+
2009-11-13 Shinichiro Hamaji <hamaji at chromium.org>
Reviewed by Darin Adler.
diff --git a/LayoutTests/storage/domstorage/quota-expected.txt b/LayoutTests/storage/domstorage/quota-expected.txt
index 3f1b554..248ff79 100644
--- a/LayoutTests/storage/domstorage/quota-expected.txt
+++ b/LayoutTests/storage/domstorage/quota-expected.txt
@@ -18,12 +18,12 @@ storage.clear()
PASS storage.length is 0
Creating 'data' which contains 64K of data
PASS data.length is 65536
-Putting 'data' into 40 localStorage buckets.
+Putting 'data' into 39 localStorage buckets.
Putting 'data' into another bucket.h
PASS Hit exception as expected
Verify that data was never inserted.
-PASS storage.getItem(40) is null
-Removing bucket 39.
+PASS storage.getItem(39) is null
+Removing bucket 38.
Adding 'Hello!' into a new bucket.
PASS Insertion worked.
PASS successfullyParsed is true
diff --git a/LayoutTests/storage/domstorage/script-tests/quota.js b/LayoutTests/storage/domstorage/script-tests/quota.js
index b6fbb23..ad9afe9 100644
--- a/LayoutTests/storage/domstorage/script-tests/quota.js
+++ b/LayoutTests/storage/domstorage/script-tests/quota.js
@@ -19,23 +19,23 @@ function testQuota(storageString)
data += data;
shouldBe("data.length", "65536");
- debug("Putting 'data' into 40 " + storageString + " buckets.");
- for (var i=0; i<40; i++)
+ debug("Putting 'data' into 39 " + storageString + " buckets.");
+ for (var i=0; i<39; i++)
storage[i] = data;
debug("Putting 'data' into another bucket.h");
try {
- storage[40] = data;
+ storage[39] = data;
testFailed("Did not hit quota error.");
} catch (e) {
testPassed("Hit exception as expected");
}
debug("Verify that data was never inserted.");
- shouldBeNull("storage.getItem(40)");
+ shouldBeNull("storage.getItem(39)");
- debug("Removing bucket 39.");
- storage.removeItem('39');
+ debug("Removing bucket 38.");
+ storage.removeItem('38');
debug("Adding 'Hello!' into a new bucket.");
try {
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index cccf38d..ab20a86 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2009-11-12 Jeremy Orlow <jorlow at chromium.org>
+
+ Reviewed by Dmitry Titov.
+
+ LocalStorage quota should include key sizes in its count
+ https://bugs.webkit.org/show_bug.cgi?id=31451
+
+ * storage/StorageMap.cpp:
+ (WebCore::StorageMap::setItem):
+ Count keys in the quota when adding a new item.
+ (WebCore::StorageMap::removeItem):
+ Remove the key's length from the quota if we're removing the item.
+ (WebCore::StorageMap::importItem):
+ Assume that we're adding things for the first time.
+ Count keys in the quota.
+
2009-11-13 Dominik Röttsches <dominik.roettsches at access-company.com>
Reviewed by Eric Seidel.
diff --git a/WebCore/storage/StorageMap.cpp b/WebCore/storage/StorageMap.cpp
index 5498d9e..bb08671 100644
--- a/WebCore/storage/StorageMap.cpp
+++ b/WebCore/storage/StorageMap.cpp
@@ -111,12 +111,21 @@ PassRefPtr<StorageMap> StorageMap::setItem(const String& key, const String& valu
return newStorageMap.release();
}
- // Quota tracking. If the quota is enabled and this would go over it, bail.
+ // Quota tracking. This is done in a couple of steps to keep the overflow tracking simple.
+ unsigned newLength = m_currentLength;
+ bool overflow = newLength + value.length() < newLength;
+ newLength += value.length();
+
oldValue = m_map.get(key);
- unsigned newLength = m_currentLength + value.length() - oldValue.length();
+ overflow |= newLength - oldValue.length() > newLength;
+ newLength -= oldValue.length();
+
+ unsigned adjustedKeyLength = oldValue.isNull() ? key.length() : 0;
+ overflow |= newLength + adjustedKeyLength < newLength;
+ newLength += adjustedKeyLength;
+
+ ASSERT(!overflow); // Overflow is bad...even if quotas are off.
bool overQuota = newLength > m_quotaSize / sizeof(UChar);
- bool overflow = (newLength > m_currentLength) != (value.length() > oldValue.length());
- ASSERT(!overflow); // If we're debugging, make a fuss. But it's still worth checking this in the following if statement.
if (m_quotaSize != noQuota && (overflow || overQuota)) {
quotaException = true;
return 0;
@@ -143,10 +152,11 @@ PassRefPtr<StorageMap> StorageMap::removeItem(const String& key, String& oldValu
}
oldValue = m_map.take(key);
- if (!oldValue.isNull())
+ if (!oldValue.isNull()) {
invalidateIterator();
-
- // Update quota.
+ ASSERT(m_currentLength - key.length() <= m_currentLength);
+ m_currentLength -= key.length();
+ }
ASSERT(m_currentLength - oldValue.length() <= m_currentLength);
m_currentLength -= oldValue.length();
@@ -162,12 +172,11 @@ void StorageMap::importItem(const String& key, const String& value)
{
// Be sure to copy the keys/values as items imported on a background thread are destined
// to cross a thread boundary
- pair<HashMap<String, String>::iterator, bool> result = m_map.add(key.threadsafeCopy(), String());
-
- if (result.second)
- result.first->second = value.threadsafeCopy();
+ pair<HashMap<String, String>::iterator, bool> result = m_map.add(key.threadsafeCopy(), value.threadsafeCopy());
+ ASSERT(result.second); // True if the key didn't exist previously.
- // Update quota.
+ ASSERT(m_currentLength + key.length() >= m_currentLength);
+ m_currentLength += key.length();
ASSERT(m_currentLength + value.length() >= m_currentLength);
m_currentLength += value.length();
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list