File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
content/common/dom_storage Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,14 @@ size_t CountBytes(const DOMStorageValuesMap& values) {
2727
2828} // namespace
2929
30+ size_t DomStorageMap::quota_override_ = 0 ;
31+
3032DOMStorageMap::DOMStorageMap (size_t quota)
3133 : bytes_used_(0 ),
3234 quota_ (quota) {
3335 ResetKeyIterator ();
36+ if (quota_override_)
37+ quota_ = quota_override_;
3438}
3539
3640DOMStorageMap::~DOMStorageMap () {}
@@ -77,8 +81,8 @@ bool DOMStorageMap::SetItem(
7781
7882 // Only check quota if the size is increasing, this allows
7983 // shrinking changes to pre-existing files that are over budget.
80- // if (new_item_size > old_item_size && new_bytes_used > quota_)
81- // return false;
84+ if (new_item_size > old_item_size && new_bytes_used > quota_)
85+ return false ;
8286
8387 values_[key] = base::NullableString16 (value, false );
8488 ResetKeyIterator ();
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ namespace content {
2121class CONTENT_EXPORT DOMStorageMap
2222 : public base::RefCountedThreadSafe<DOMStorageMap> {
2323 public:
24- explicit DOMStorageMap (size_t quota);
24+ explicit DomStorageMap (size_t quota);
25+ static void SetQuotaOverride (size_t quota) {quota_override_ = quota; }
2526
2627 unsigned Length () const ;
2728 base::NullableString16 Key (unsigned index);
@@ -44,7 +45,7 @@ class CONTENT_EXPORT DOMStorageMap
4445
4546 size_t bytes_used () const { return bytes_used_; }
4647 size_t quota () const { return quota_; }
47- void set_quota (size_t quota) { quota_ = quota; }
48+ void set_quota (size_t quota) { quota_ = quota > quota_override_ ? quota : quota_override_ ; }
4849
4950 private:
5051 friend class base ::RefCountedThreadSafe<DOMStorageMap>;
@@ -57,6 +58,7 @@ class CONTENT_EXPORT DOMStorageMap
5758 unsigned last_key_index_;
5859 size_t bytes_used_;
5960 size_t quota_;
61+ static size_t quota_override_;
6062};
6163
6264} // namespace content
You can’t perform that action at this time.
0 commit comments