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

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, 9 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 125211)
+++ 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, this allows
+ // shrinking changes to pre-existing files that are over budget.
+ if (new_item_size > old_item_size && new_bytes_used > quota_)
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,14 @@
return true;
}
-bool DomStorageMap::SwapValues(ValuesMap* values) {
- size_t new_size = CountBytes(*values);
- if (new_size > quota_)
- return false;
+void DomStorageMap::SwapValues(ValuesMap* values) {
+ // Note: A pre-existing file may be over the quota budget.
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