Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2766)

Unified Diff: webkit/dom_storage/dom_storage_map.cc

Issue 9594038: Relax strict quota limit checks when reading pre-existing DomStorage database files. The other chec… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/dom_storage/dom_storage_map.cc
===================================================================
--- webkit/dom_storage/dom_storage_map.cc (revision 124748)
+++ webkit/dom_storage/dom_storage_map.cc (working copy)
@@ -72,14 +72,17 @@
size_t old_item_size = old_value->is_null() ?
0 : size_of_item(key, old_value->string());
- size_t new_size = bytes_used_ - old_item_size + size_of_item(key, value);
- if (new_size > quota_)
+ size_t new_item_size = size_of_item(key, value);
+ size_t new_bytes_used = bytes_used_ - old_item_size + new_item_size;
+
+ // Only check quota if the size is increasing since a descrese is
benm (inactive) 2012/03/06 11:31:15 s/descrease/decrease/
michaeln 2012/03/06 20:37:51 Done.
+ // always allowed.
+ if ((new_item_size > old_item_size) && (new_bytes_used > quota_))
benm (inactive) 2012/03/06 11:31:15 should this be new_item_size >= old_item_size? Tha
michaeln 2012/03/06 20:37:51 Seems cruel to reject a change where the size is n
return false;
values_[key] = NullableString16(value, false);
ResetKeyIterator();
- bytes_used_ -= old_item_size;
- bytes_used_ += size_of_item(key, value);
+ bytes_used_ = new_bytes_used;
return true;
}
@@ -96,18 +99,13 @@
return true;
}
-bool DomStorageMap::SwapValues(ValuesMap* values) {
- size_t new_size = CountBytes(*values);
- if (new_size > quota_)
- return false;
+void DomStorageMap::SwapValues(ValuesMap* values) {
values_.swap(*values);
- bytes_used_ = new_size;
+ bytes_used_ = CountBytes(values_);
ResetKeyIterator();
- return true;
}
DomStorageMap* DomStorageMap::DeepCopy() const {
- DCHECK(CountBytes(values_) <= quota_);
DomStorageMap* copy = new DomStorageMap(quota_);
copy->values_ = values_;
copy->bytes_used_ = bytes_used_;

Powered by Google App Engine
This is Rietveld 408576698