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_cached_area.cc

Issue 12398008: Purge in-memory localStorage areas if the # of areas exceeds the limit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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_cached_area.cc
diff --git a/webkit/dom_storage/dom_storage_cached_area.cc b/webkit/dom_storage/dom_storage_cached_area.cc
index 30d6291d32a5e184f9aa013b3f4a81b658b23a02..2e1ec2023ab0e9d4a92d46a6a94f91fe64539839 100644
--- a/webkit/dom_storage/dom_storage_cached_area.cc
+++ b/webkit/dom_storage/dom_storage_cached_area.cc
@@ -13,10 +13,12 @@
namespace dom_storage {
DomStorageCachedArea::DomStorageCachedArea(
- int64 namespace_id, const GURL& origin, DomStorageProxy* proxy)
+ int64 namespace_id, const GURL& origin, DomStorageProxy* proxy,
+ int64 storage_size)
: ignore_all_mutations_(false),
namespace_id_(namespace_id), origin_(origin),
- proxy_(proxy), weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ proxy_(proxy), weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ global_storage_size_(storage_size) {
}
DomStorageCachedArea::~DomStorageCachedArea() {
@@ -47,6 +49,12 @@ bool DomStorageCachedArea::SetItem(
if (key.length() + value.length() > dom_storage::kPerAreaQuota)
return false;
+ // TENTATIVE: Limit the global data to 512MB.
+ if (key.length() + value.length() + global_storage_size_
+ > 512 * 1024 * 1024) {
+ return false;
+ }
+
PrimeIfNeeded(connection_id);
NullableString16 unused;
if (!map_->SetItem(key, value, &unused))

Powered by Google App Engine
This is Rietveld 408576698