Index: chrome/browser/extensions/settings/settings_storage_quota_enforcer.cc |
diff --git a/chrome/browser/extensions/settings/settings_storage_quota_enforcer.cc b/chrome/browser/extensions/settings/settings_storage_quota_enforcer.cc |
index 6f59c77d84d4a977f628235d73a21381c30ccb6c..da481b0ba9879271a682f5ea803c8edd4adb32d6 100644 |
--- a/chrome/browser/extensions/settings/settings_storage_quota_enforcer.cc |
+++ b/chrome/browser/extensions/settings/settings_storage_quota_enforcer.cc |
@@ -98,8 +98,7 @@ SettingsStorageQuotaEnforcer::SettingsStorageQuotaEnforcer( |
} |
} |
-SettingsStorageQuotaEnforcer::~SettingsStorageQuotaEnforcer( |
- ) {} |
+SettingsStorageQuotaEnforcer::~SettingsStorageQuotaEnforcer() {} |
SettingsStorage::ReadResult SettingsStorageQuotaEnforcer::Get( |
const std::string& key) { |
@@ -111,29 +110,29 @@ SettingsStorage::ReadResult SettingsStorageQuotaEnforcer::Get( |
return delegate_->Get(keys); |
} |
-SettingsStorage::ReadResult |
-SettingsStorageQuotaEnforcer::Get() { |
+SettingsStorage::ReadResult SettingsStorageQuotaEnforcer::Get() { |
return delegate_->Get(); |
} |
-SettingsStorage::WriteResult |
-SettingsStorageQuotaEnforcer::Set( |
- const std::string& key, const Value& value) { |
+SettingsStorage::WriteResult SettingsStorageQuotaEnforcer::Set( |
+ WriteOptions options, const std::string& key, const Value& value) { |
size_t new_used_total = used_total_; |
std::map<std::string, size_t> new_used_per_setting = used_per_setting_; |
Allocate(key, value, &new_used_total, &new_used_per_setting); |
- if (new_used_total > quota_bytes_) { |
- return QuotaExceededFor(TOTAL_BYTES); |
- } |
- if (new_used_per_setting[key] > quota_bytes_per_setting_) { |
- return QuotaExceededFor(BYTES_PER_SETTING); |
- } |
- if (new_used_per_setting.size() > max_keys_) { |
- return QuotaExceededFor(KEY_COUNT); |
+ if (options != FORCE) { |
not at google - send to devlin
2011/11/17 07:02:53
Change #3: not enforcing quota from Set (here and
Matt Perry
2011/11/17 19:53:51
It looks like FORCE only has an effect for Set().
not at google - send to devlin
2011/11/18 03:35:21
Yep. I added it to Remove and Clear for consisten
|
+ if (new_used_total > quota_bytes_) { |
+ return QuotaExceededFor(TOTAL_BYTES); |
+ } |
+ if (new_used_per_setting[key] > quota_bytes_per_setting_) { |
+ return QuotaExceededFor(BYTES_PER_SETTING); |
+ } |
+ if (new_used_per_setting.size() > max_keys_) { |
+ return QuotaExceededFor(KEY_COUNT); |
+ } |
} |
- WriteResult result = delegate_->Set(key, value); |
+ WriteResult result = delegate_->Set(options, key, value); |
if (result.HasError()) { |
return result; |
} |
@@ -143,26 +142,29 @@ SettingsStorageQuotaEnforcer::Set( |
return result; |
} |
-SettingsStorage::WriteResult |
-SettingsStorageQuotaEnforcer::Set( |
- const DictionaryValue& values) { |
+SettingsStorage::WriteResult SettingsStorageQuotaEnforcer::Set( |
+ WriteOptions options, const DictionaryValue& values) { |
size_t new_used_total = used_total_; |
std::map<std::string, size_t> new_used_per_setting = used_per_setting_; |
for (DictionaryValue::Iterator it(values); it.HasNext(); it.Advance()) { |
Allocate(it.key(), it.value(), &new_used_total, &new_used_per_setting); |
- if (new_used_per_setting[it.key()] > quota_bytes_per_setting_) { |
+ |
+ if (options != FORCE && |
+ new_used_per_setting[it.key()] > quota_bytes_per_setting_) { |
return QuotaExceededFor(BYTES_PER_SETTING); |
} |
} |
- if (new_used_total > quota_bytes_) { |
- return QuotaExceededFor(TOTAL_BYTES); |
- } |
- if (new_used_per_setting.size() > max_keys_) { |
- return QuotaExceededFor(KEY_COUNT); |
+ if (options != FORCE) { |
+ if (new_used_total > quota_bytes_) { |
+ return QuotaExceededFor(TOTAL_BYTES); |
+ } |
+ if (new_used_per_setting.size() > max_keys_) { |
+ return QuotaExceededFor(KEY_COUNT); |
+ } |
} |
- WriteResult result = delegate_->Set(values); |
+ WriteResult result = delegate_->Set(options, values); |
if (result.HasError()) { |
return result; |
} |
@@ -172,10 +174,9 @@ SettingsStorageQuotaEnforcer::Set( |
return result; |
} |
-SettingsStorage::WriteResult |
-SettingsStorageQuotaEnforcer::Remove( |
- const std::string& key) { |
- WriteResult result = delegate_->Remove(key); |
+SettingsStorage::WriteResult SettingsStorageQuotaEnforcer::Remove( |
+ WriteOptions options, const std::string& key) { |
+ WriteResult result = delegate_->Remove(options, key); |
if (result.HasError()) { |
return result; |
} |
@@ -183,10 +184,9 @@ SettingsStorageQuotaEnforcer::Remove( |
return result; |
} |
-SettingsStorage::WriteResult |
-SettingsStorageQuotaEnforcer::Remove( |
- const std::vector<std::string>& keys) { |
- WriteResult result = delegate_->Remove(keys); |
+SettingsStorage::WriteResult SettingsStorageQuotaEnforcer::Remove( |
+ WriteOptions options, const std::vector<std::string>& keys) { |
+ WriteResult result = delegate_->Remove(options, keys); |
if (result.HasError()) { |
return result; |
} |
@@ -198,10 +198,9 @@ SettingsStorageQuotaEnforcer::Remove( |
return result; |
} |
-SettingsStorage::WriteResult |
-SettingsStorageQuotaEnforcer::Clear( |
- ) { |
- WriteResult result = delegate_->Clear(); |
+SettingsStorage::WriteResult SettingsStorageQuotaEnforcer::Clear( |
+ WriteOptions options) { |
+ WriteResult result = delegate_->Clear(options); |
if (result.HasError()) { |
return result; |
} |