diff options
author | kalman <kalman@chromium.org> | 2014-10-31 16:31:39 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-31 23:32:03 +0000 |
commit | 2c396aacf26fefdd174c86fb7a83c05c2212bd1d (patch) | |
tree | b72104d18a20221e023c79d5f570b8583cede206 /extensions/browser/quota_service_unittest.cc | |
parent | 128179a85d0225f6eff4f177daae5ce3ec797f3b (diff) | |
download | chromium_src-2c396aacf26fefdd174c86fb7a83c05c2212bd1d.zip chromium_src-2c396aacf26fefdd174c86fb7a83c05c2212bd1d.tar.gz chromium_src-2c396aacf26fefdd174c86fb7a83c05c2212bd1d.tar.bz2 |
Remove the extension QuotaService::SustainedLimit and its last client, the
storage.sync MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE limit. I'll be relaxing
the quota over a few CLs and having 2 limiting mechanisms just complicates
things.
BUG=406406
R=zea@chromium.org
Review URL: https://codereview.chromium.org/685603003
Cr-Commit-Position: refs/heads/master@{#302352}
Diffstat (limited to 'extensions/browser/quota_service_unittest.cc')
-rw-r--r-- | extensions/browser/quota_service_unittest.cc | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/extensions/browser/quota_service_unittest.cc b/extensions/browser/quota_service_unittest.cc index 5bd0400..b33910a 100644 --- a/extensions/browser/quota_service_unittest.cc +++ b/extensions/browser/quota_service_unittest.cc @@ -21,7 +21,6 @@ typedef QuotaLimitHeuristic::Bucket Bucket; typedef QuotaLimitHeuristic::Config Config; typedef QuotaLimitHeuristic::BucketList BucketList; typedef QuotaService::TimedLimit TimedLimit; -typedef QuotaService::SustainedLimit SustainedLimit; namespace { @@ -88,24 +87,6 @@ class TimedLimitMockFunction : public MockFunction { ~TimedLimitMockFunction() override {} }; -class ChainedLimitsMockFunction : public MockFunction { - public: - explicit ChainedLimitsMockFunction(const std::string& name) - : MockFunction(name) {} - void GetQuotaLimitHeuristics( - QuotaLimitHeuristics* heuristics) const override { - // No more than 2 per minute sustained over 5 minutes. - heuristics->push_back(new SustainedLimit( - TimeDelta::FromMinutes(5), k2PerMinute, new Mapper(), kGenericName)); - // No more than 20 per hour. - heuristics->push_back( - new TimedLimit(k20PerHour, new Mapper(), kGenericName)); - } - - private: - ~ChainedLimitsMockFunction() override {} -}; - class FrozenMockFunction : public MockFunction { public: explicit FrozenMockFunction(const std::string& name) : MockFunction(name) {} @@ -189,31 +170,6 @@ TEST_F(QuotaLimitHeuristicTest, Timed) { EXPECT_FALSE(lim.Apply(&b, k1MinuteAfterStart + TimeDelta::FromSeconds(3))); } -TEST_F(QuotaLimitHeuristicTest, Sustained) { - SustainedLimit lim( - TimeDelta::FromMinutes(5), k2PerMinute, new MockMapper(), kGenericName); - Bucket bucket; - - bucket.Reset(k2PerMinute, kStartTime); - DoMoreThan2PerMinuteFor5Minutes(kStartTime, &lim, &bucket, -1); - // This straw breaks the camel's back. - EXPECT_FALSE(lim.Apply(&bucket, kStartTime + TimeDelta::FromMinutes(6))); - - // The heuristic resets itself on a safe request. - EXPECT_TRUE(lim.Apply(&bucket, kStartTime + TimeDelta::FromDays(1))); - - // Do the same as above except don't exhaust final bucket. - bucket.Reset(k2PerMinute, kStartTime); - DoMoreThan2PerMinuteFor5Minutes(kStartTime, &lim, &bucket, -1); - EXPECT_TRUE(lim.Apply(&bucket, kStartTime + TimeDelta::FromMinutes(7))); - - // Do the same as above except don't exhaust the 3rd (w.l.o.g) bucket. - bucket.Reset(k2PerMinute, kStartTime); - DoMoreThan2PerMinuteFor5Minutes(kStartTime, &lim, &bucket, 3); - // If the 3rd bucket were exhausted, this would fail (see first test). - EXPECT_TRUE(lim.Apply(&bucket, kStartTime + TimeDelta::FromMinutes(6))); -} - TEST_F(QuotaServiceTest, NoHeuristic) { scoped_refptr<MockFunction> f(new MockFunction("foo")); base::ListValue args; @@ -298,59 +254,6 @@ TEST_F(QuotaServiceTest, SingleHeuristic) { kStartTime + TimeDelta::FromSeconds(30))); } -TEST_F(QuotaServiceTest, ChainedHeuristics) { - scoped_refptr<MockFunction> f(new ChainedLimitsMockFunction("foo")); - base::ListValue args; - args.Append(new base::FundamentalValue(1)); - - // First, test that the low limit can be avoided but the higher one is hit. - // One event per minute for 20 minutes comes in under the sustained limit, - // but is equal to the timed limit. - for (int i = 0; i < 20; i++) { - EXPECT_EQ( - "", - service_->Assess(extension_a_, - f.get(), - &args, - kStartTime + TimeDelta::FromSeconds(10 + i * 60))); - } - - // This will bring us to 21 events in an hour, which is a violation. - EXPECT_NE("", - service_->Assess(extension_a_, - f.get(), - &args, - kStartTime + TimeDelta::FromMinutes(30))); - - // Now, check that we can still hit the lower limit. - for (int i = 0; i < 5; i++) { - EXPECT_EQ( - "", - service_->Assess(extension_b_, - f.get(), - &args, - kStartTime + TimeDelta::FromSeconds(10 + i * 60))); - EXPECT_EQ( - "", - service_->Assess(extension_b_, - f.get(), - &args, - kStartTime + TimeDelta::FromSeconds(15 + i * 60))); - EXPECT_EQ( - "", - service_->Assess(extension_b_, - f.get(), - &args, - kStartTime + TimeDelta::FromSeconds(20 + i * 60))); - } - - EXPECT_NE("", - service_->Assess(extension_b_, - f.get(), - &args, - kStartTime + TimeDelta::FromMinutes(6))); -} - TEST_F(QuotaServiceTest, MultipleFunctionsDontInterfere) { scoped_refptr<MockFunction> f(new TimedLimitMockFunction("foo")); scoped_refptr<MockFunction> g(new TimedLimitMockFunction("bar")); |