| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/process.h" | 6 #include "base/process.h" |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 #include "chrome/browser/extensions/extensions_quota_service.h" | 10 #include "chrome/browser/extensions/extensions_quota_service.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 virtual void TearDown() { | 134 virtual void TearDown() { |
| 135 loop_.RunUntilIdle(); | 135 loop_.RunUntilIdle(); |
| 136 service_.reset(); | 136 service_.reset(); |
| 137 } | 137 } |
| 138 protected: | 138 protected: |
| 139 std::string extension_a_; | 139 std::string extension_a_; |
| 140 std::string extension_b_; | 140 std::string extension_b_; |
| 141 std::string extension_c_; | 141 std::string extension_c_; |
| 142 scoped_ptr<ExtensionsQuotaService> service_; | 142 scoped_ptr<ExtensionsQuotaService> service_; |
| 143 MessageLoop loop_; | 143 base::MessageLoop loop_; |
| 144 content::TestBrowserThread ui_thread_; | 144 content::TestBrowserThread ui_thread_; |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 class QuotaLimitHeuristicTest : public testing::Test { | 147 class QuotaLimitHeuristicTest : public testing::Test { |
| 148 public: | 148 public: |
| 149 static void DoMoreThan2PerMinuteFor5Minutes(const TimeTicks& start_time, | 149 static void DoMoreThan2PerMinuteFor5Minutes(const TimeTicks& start_time, |
| 150 QuotaLimitHeuristic* lim, | 150 QuotaLimitHeuristic* lim, |
| 151 Bucket* b, | 151 Bucket* b, |
| 152 int an_unexhausted_minute) { | 152 int an_unexhausted_minute) { |
| 153 for (int i = 0; i < 5; i++) { | 153 for (int i = 0; i < 5; i++) { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 EXPECT_NE("", service_->Assess(extension_a_, f, &arg, | 336 EXPECT_NE("", service_->Assess(extension_a_, f, &arg, |
| 337 kStartTime + TimeDelta::FromSeconds(15))); | 337 kStartTime + TimeDelta::FromSeconds(15))); |
| 338 | 338 |
| 339 // We don't allow this extension to use quota limited functions even if they | 339 // We don't allow this extension to use quota limited functions even if they |
| 340 // wait a while. | 340 // wait a while. |
| 341 EXPECT_NE("", service_->Assess(extension_a_, f, &arg, | 341 EXPECT_NE("", service_->Assess(extension_a_, f, &arg, |
| 342 kStartTime + TimeDelta::FromDays(1))); | 342 kStartTime + TimeDelta::FromDays(1))); |
| 343 EXPECT_NE("", service_->Assess(extension_a_, g, &arg, | 343 EXPECT_NE("", service_->Assess(extension_a_, g, &arg, |
| 344 kStartTime + TimeDelta::FromDays(1))); | 344 kStartTime + TimeDelta::FromDays(1))); |
| 345 } | 345 } |
| OLD | NEW |