| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/stl_util.h" | 5 #include "base/stl_util.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "chrome/browser/extensions/extension_function.h" | 7 #include "chrome/browser/extensions/extension_function.h" |
| 8 #include "chrome/browser/extensions/extensions_quota_service.h" | 8 #include "chrome/browser/extensions/extensions_quota_service.h" |
| 9 #include "content/test/test_browser_thread.h" | 9 #include "content/test/test_browser_thread.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 using base::TimeDelta; | 12 using base::TimeDelta; |
| 13 using base::TimeTicks; | 13 using base::TimeTicks; |
| 14 using content::BrowserThread; |
| 14 | 15 |
| 15 typedef QuotaLimitHeuristic::Bucket Bucket; | 16 typedef QuotaLimitHeuristic::Bucket Bucket; |
| 16 typedef QuotaLimitHeuristic::Config Config; | 17 typedef QuotaLimitHeuristic::Config Config; |
| 17 typedef QuotaLimitHeuristic::BucketList BucketList; | 18 typedef QuotaLimitHeuristic::BucketList BucketList; |
| 18 typedef ExtensionsQuotaService::TimedLimit TimedLimit; | 19 typedef ExtensionsQuotaService::TimedLimit TimedLimit; |
| 19 typedef ExtensionsQuotaService::SustainedLimit SustainedLimit; | 20 typedef ExtensionsQuotaService::SustainedLimit SustainedLimit; |
| 20 | 21 |
| 21 static const Config kFrozenConfig = { 0, TimeDelta::FromDays(0) }; | 22 static const Config kFrozenConfig = { 0, TimeDelta::FromDays(0) }; |
| 22 static const Config k2PerMinute = { 2, TimeDelta::FromMinutes(1) }; | 23 static const Config k2PerMinute = { 2, TimeDelta::FromMinutes(1) }; |
| 23 static const Config k20PerHour = { 20, TimeDelta::FromHours(1) }; | 24 static const Config k20PerHour = { 20, TimeDelta::FromHours(1) }; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 EXPECT_FALSE(service_->Assess(extension_a_, f, &arg, | 310 EXPECT_FALSE(service_->Assess(extension_a_, f, &arg, |
| 310 kStartTime + TimeDelta::FromSeconds(15))); | 311 kStartTime + TimeDelta::FromSeconds(15))); |
| 311 | 312 |
| 312 // We don't allow this extension to use quota limited functions even if they | 313 // We don't allow this extension to use quota limited functions even if they |
| 313 // wait a while. | 314 // wait a while. |
| 314 EXPECT_FALSE(service_->Assess(extension_a_, f, &arg, | 315 EXPECT_FALSE(service_->Assess(extension_a_, f, &arg, |
| 315 kStartTime + TimeDelta::FromDays(1))); | 316 kStartTime + TimeDelta::FromDays(1))); |
| 316 EXPECT_FALSE(service_->Assess(extension_a_, g, &arg, | 317 EXPECT_FALSE(service_->Assess(extension_a_, g, &arg, |
| 317 kStartTime + TimeDelta::FromDays(1))); | 318 kStartTime + TimeDelta::FromDays(1))); |
| 318 } | 319 } |
| OLD | NEW |