Commit 66b08a08 authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Remove quota if set to zero

When site data is removed, persistent quota gets resetted to zero.
Instead of keeping the origin in the database, we should just delete it
to remove traces of browsing_data.

Bug: 849677
Change-Id: Ice2282274012fe8d2cb65bbac0b328523e8ce666
Reviewed-on: https://chromium-review.googlesource.com/1087057Reviewed-by: default avatarTaiju Tsuiki <tzik@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564821}
parent 44914628
...@@ -198,6 +198,8 @@ bool QuotaDatabase::SetHostQuota(const std::string& host, ...@@ -198,6 +198,8 @@ bool QuotaDatabase::SetHostQuota(const std::string& host,
DCHECK_GE(quota, 0); DCHECK_GE(quota, 0);
if (!LazyOpen(true)) if (!LazyOpen(true))
return false; return false;
if (quota == 0)
return DeleteHostQuota(host, type);
if (!InsertOrReplaceHostQuota(host, type, quota)) if (!InsertOrReplaceHostQuota(host, type, quota))
return false; return false;
ScheduleCommit(); ScheduleCommit();
......
...@@ -112,6 +112,10 @@ class QuotaDatabaseTest : public testing::Test { ...@@ -112,6 +112,10 @@ class QuotaDatabaseTest : public testing::Test {
// Delete temporary storage quota. // Delete temporary storage quota.
EXPECT_TRUE(db.DeleteHostQuota(kHost, kTemporary)); EXPECT_TRUE(db.DeleteHostQuota(kHost, kTemporary));
EXPECT_FALSE(db.GetHostQuota(kHost, kTemporary, &quota)); EXPECT_FALSE(db.GetHostQuota(kHost, kTemporary, &quota));
// Delete persistent quota by setting it to zero.
EXPECT_TRUE(db.SetHostQuota(kHost, kPersistent, 0));
EXPECT_FALSE(db.GetHostQuota(kHost, kPersistent, &quota));
} }
void GlobalQuota(const base::FilePath& kDbFile) { void GlobalQuota(const base::FilePath& kDbFile) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment