Changeset 50979 in webkit
- Timestamp:
- Nov 13, 2009 4:27:25 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r50976 r50979 1 2009-11-12 Jeremy Orlow <jorlow@chromium.org> 2 3 Reviewed by Dmitry Titov. 4 5 Now that we're tracking key size in the quota, we can't fit as much in. 6 https://bugs.webkit.org/show_bug.cgi?id=31451 7 8 * storage/domstorage/quota-expected.txt: 9 * storage/domstorage/script-tests/quota.js: 10 (testQuota): 11 1 12 2009-11-13 Shinichiro Hamaji <hamaji@chromium.org> 2 13 -
trunk/LayoutTests/storage/domstorage/quota-expected.txt
r49928 r50979 19 19 Creating 'data' which contains 64K of data 20 20 PASS data.length is 65536 21 Putting 'data' into 40localStorage buckets.21 Putting 'data' into 39 localStorage buckets. 22 22 Putting 'data' into another bucket.h 23 23 PASS Hit exception as expected 24 24 Verify that data was never inserted. 25 PASS storage.getItem( 40) is null26 Removing bucket 3 9.25 PASS storage.getItem(39) is null 26 Removing bucket 38. 27 27 Adding 'Hello!' into a new bucket. 28 28 PASS Insertion worked. -
trunk/LayoutTests/storage/domstorage/script-tests/quota.js
r49928 r50979 20 20 shouldBe("data.length", "65536"); 21 21 22 debug("Putting 'data' into 40" + storageString + " buckets.");23 for (var i=0; i< 40; i++)22 debug("Putting 'data' into 39 " + storageString + " buckets."); 23 for (var i=0; i<39; i++) 24 24 storage[i] = data; 25 25 26 26 debug("Putting 'data' into another bucket.h"); 27 27 try { 28 storage[ 40] = data;28 storage[39] = data; 29 29 testFailed("Did not hit quota error."); 30 30 } catch (e) { … … 33 33 34 34 debug("Verify that data was never inserted."); 35 shouldBeNull("storage.getItem( 40)");35 shouldBeNull("storage.getItem(39)"); 36 36 37 debug("Removing bucket 3 9.");38 storage.removeItem('3 9');37 debug("Removing bucket 38."); 38 storage.removeItem('38'); 39 39 40 40 debug("Adding 'Hello!' into a new bucket."); -
trunk/WebCore/ChangeLog
r50977 r50979 1 2009-11-12 Jeremy Orlow <jorlow@chromium.org> 2 3 Reviewed by Dmitry Titov. 4 5 LocalStorage quota should include key sizes in its count 6 https://bugs.webkit.org/show_bug.cgi?id=31451 7 8 * storage/StorageMap.cpp: 9 (WebCore::StorageMap::setItem): 10 Count keys in the quota when adding a new item. 11 (WebCore::StorageMap::removeItem): 12 Remove the key's length from the quota if we're removing the item. 13 (WebCore::StorageMap::importItem): 14 Assume that we're adding things for the first time. 15 Count keys in the quota. 16 1 17 2009-11-13 Dominik Röttsches <dominik.roettsches@access-company.com> 2 18 -
trunk/WebCore/storage/StorageMap.cpp
r49160 r50979 112 112 } 113 113 114 // Quota tracking. If the quota is enabled and this would go over it, bail. 114 // Quota tracking. This is done in a couple of steps to keep the overflow tracking simple. 115 unsigned newLength = m_currentLength; 116 bool overflow = newLength + value.length() < newLength; 117 newLength += value.length(); 118 115 119 oldValue = m_map.get(key); 116 unsigned newLength = m_currentLength + value.length() - oldValue.length(); 120 overflow |= newLength - oldValue.length() > newLength; 121 newLength -= oldValue.length(); 122 123 unsigned adjustedKeyLength = oldValue.isNull() ? key.length() : 0; 124 overflow |= newLength + adjustedKeyLength < newLength; 125 newLength += adjustedKeyLength; 126 127 ASSERT(!overflow); // Overflow is bad...even if quotas are off. 117 128 bool overQuota = newLength > m_quotaSize / sizeof(UChar); 118 bool overflow = (newLength > m_currentLength) != (value.length() > oldValue.length());119 ASSERT(!overflow); // If we're debugging, make a fuss. But it's still worth checking this in the following if statement.120 129 if (m_quotaSize != noQuota && (overflow || overQuota)) { 121 130 quotaException = true; … … 144 153 145 154 oldValue = m_map.take(key); 146 if (!oldValue.isNull()) 155 if (!oldValue.isNull()) { 147 156 invalidateIterator(); 148 149 // Update quota. 157 ASSERT(m_currentLength - key.length() <= m_currentLength); 158 m_currentLength -= key.length(); 159 } 150 160 ASSERT(m_currentLength - oldValue.length() <= m_currentLength); 151 161 m_currentLength -= oldValue.length(); … … 163 173 // Be sure to copy the keys/values as items imported on a background thread are destined 164 174 // to cross a thread boundary 165 pair<HashMap<String, String>::iterator, bool> result = m_map.add(key.threadsafeCopy(), String()); 175 pair<HashMap<String, String>::iterator, bool> result = m_map.add(key.threadsafeCopy(), value.threadsafeCopy()); 176 ASSERT(result.second); // True if the key didn't exist previously. 166 177 167 if (result.second) 168 result.first->second = value.threadsafeCopy(); 169 170 // Update quota. 178 ASSERT(m_currentLength + key.length() >= m_currentLength); 179 m_currentLength += key.length(); 171 180 ASSERT(m_currentLength + value.length() >= m_currentLength); 172 181 m_currentLength += value.length();
Note: See TracChangeset
for help on using the changeset viewer.