forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Bypass localStorage quota (ref electron#8337)
- Loading branch information
Showing
4 changed files
with
80 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Jacob Quant <jacobq@gmail.com> | ||
Date: Tue, 6 Nov 2018 09:47:22 -0600 | ||
Subject: dom_storage_limits.patch | ||
|
||
|
||
content/common/dom_storage/dom_storage_map.cc | 2 ++ | ||
content/common/dom_storage/dom_storage_types.h | 2 +- | ||
content/renderer/dom_storage/dom_storage_cached_area.cc | 2 ++ | ||
content/renderer/dom_storage/local_storage_cached_area.cc | 2 ++ | ||
4 files changed, 7 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/content/common/dom_storage/dom_storage_map.cc b/content/common/dom_storage/dom_storage_map.cc | ||
index fd088fb170be..b90b6cf9132d 100644 | ||
--- a/content/common/dom_storage/dom_storage_map.cc | ||
+++ b/content/common/dom_storage/dom_storage_map.cc | ||
@@ -185,10 +185,12 @@ bool DOMStorageMap::SetItemInternal(MapType* map_type, | ||
size_t new_item_size = size_in_storage(key, value); | ||
size_t new_storage_used = storage_used_ - old_item_size + new_item_size; | ||
|
||
+#if 0 | ||
// 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_storage_used > quota_) | ||
return false; | ||
+#endif | ||
|
||
(*map_type)[key] = value; | ||
ResetKeyIterator(); | ||
diff --git a/content/common/dom_storage/dom_storage_types.h b/content/common/dom_storage/dom_storage_types.h | ||
index e87afe5b8ee0..dabbed539038 100644 | ||
--- a/content/common/dom_storage/dom_storage_types.h | ||
+++ b/content/common/dom_storage/dom_storage_types.h | ||
@@ -21,7 +21,7 @@ typedef std::map<base::string16, base::NullableString16> DOMStorageValuesMap; | ||
|
||
// The quota for each storage area. | ||
// This value is enforced in renderer processes and the browser process. | ||
-const size_t kPerStorageAreaQuota = 10 * 1024 * 1024; | ||
+const size_t kPerStorageAreaQuota = std::numeric_limits<int>::max(); // raise kMaxBytesPerHour limit without bypassing; | ||
|
||
// In the browser process we allow some overage to | ||
// accomodate concurrent writes from different renderers | ||
diff --git a/content/renderer/dom_storage/dom_storage_cached_area.cc b/content/renderer/dom_storage/dom_storage_cached_area.cc | ||
index 402c27727ff1..f5908a1c55f9 100644 | ||
--- a/content/renderer/dom_storage/dom_storage_cached_area.cc | ||
+++ b/content/renderer/dom_storage/dom_storage_cached_area.cc | ||
@@ -53,11 +53,13 @@ bool DOMStorageCachedArea::SetItem(int connection_id, | ||
const base::string16& key, | ||
const base::string16& value, | ||
const GURL& page_url) { | ||
+#if 0 | ||
// A quick check to reject obviously overbudget items to avoid | ||
// the priming the cache. | ||
if ((key.length() + value.length()) * sizeof(base::char16) > | ||
kPerStorageAreaQuota) | ||
return false; | ||
+#endif | ||
|
||
PrimeIfNeeded(connection_id); | ||
base::NullableString16 old_value; | ||
diff --git a/content/renderer/dom_storage/local_storage_cached_area.cc b/content/renderer/dom_storage/local_storage_cached_area.cc | ||
index ffa21c9200d0..0edbd6152292 100644 | ||
--- a/content/renderer/dom_storage/local_storage_cached_area.cc | ||
+++ b/content/renderer/dom_storage/local_storage_cached_area.cc | ||
@@ -141,11 +141,13 @@ bool LocalStorageCachedArea::SetItem(const base::string16& key, | ||
const base::string16& value, | ||
const GURL& page_url, | ||
const std::string& storage_area_id) { | ||
+#if 0 | ||
// A quick check to reject obviously overbudget items to avoid priming the | ||
// cache. | ||
if ((key.length() + value.length()) * sizeof(base::char16) > | ||
kPerStorageAreaQuota) | ||
return false; | ||
+#endif | ||
|
||
EnsureLoaded(); | ||
bool result = false; |
This file was deleted.
Oops, something went wrong.