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 <memory> |
| 6 |
5 #include "base/macros.h" | 7 #include "base/macros.h" |
6 #include "base/memory/scoped_ptr.h" | |
7 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
8 #include "base/pickle.h" | 9 #include "base/pickle.h" |
9 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "extensions/browser/extension_throttle_entry.h" | 14 #include "extensions/browser/extension_throttle_entry.h" |
14 #include "extensions/browser/extension_throttle_manager.h" | 15 #include "extensions/browser/extension_throttle_manager.h" |
15 #include "extensions/browser/extension_throttle_test_support.h" | 16 #include "extensions/browser/extension_throttle_test_support.h" |
16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 : request_(context_.CreateRequest(GURL(), net::DEFAULT_PRIORITY, NULL)) {} | 170 : request_(context_.CreateRequest(GURL(), net::DEFAULT_PRIORITY, NULL)) {} |
170 | 171 |
171 void SetUp() override; | 172 void SetUp() override; |
172 | 173 |
173 TimeTicks now_; | 174 TimeTicks now_; |
174 MockExtensionThrottleManager manager_; // Dummy object, not used. | 175 MockExtensionThrottleManager manager_; // Dummy object, not used. |
175 scoped_refptr<MockExtensionThrottleEntry> entry_; | 176 scoped_refptr<MockExtensionThrottleEntry> entry_; |
176 base::MessageLoopForIO message_loop_; | 177 base::MessageLoopForIO message_loop_; |
177 | 178 |
178 TestURLRequestContext context_; | 179 TestURLRequestContext context_; |
179 scoped_ptr<URLRequest> request_; | 180 std::unique_ptr<URLRequest> request_; |
180 }; | 181 }; |
181 | 182 |
182 void ExtensionThrottleEntryTest::SetUp() { | 183 void ExtensionThrottleEntryTest::SetUp() { |
183 request_->SetLoadFlags(0); | 184 request_->SetLoadFlags(0); |
184 | 185 |
185 now_ = TimeTicks::Now(); | 186 now_ = TimeTicks::Now(); |
186 entry_ = new MockExtensionThrottleEntry(&manager_); | 187 entry_ = new MockExtensionThrottleEntry(&manager_); |
187 entry_->ResetToBlank(now_); | 188 entry_->ResetToBlank(now_); |
188 } | 189 } |
189 | 190 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 } else { | 351 } else { |
351 // As above, add 100 ms. | 352 // As above, add 100 ms. |
352 EXPECT_LT(TimeTicks::Now() + TimeDelta::FromMilliseconds(100), | 353 EXPECT_LT(TimeTicks::Now() + TimeDelta::FromMilliseconds(100), |
353 entry->GetExponentialBackoffReleaseTime()); | 354 entry->GetExponentialBackoffReleaseTime()); |
354 } | 355 } |
355 } | 356 } |
356 | 357 |
357 base::MessageLoopForIO message_loop_; | 358 base::MessageLoopForIO message_loop_; |
358 // context_ must be declared before request_. | 359 // context_ must be declared before request_. |
359 TestURLRequestContext context_; | 360 TestURLRequestContext context_; |
360 scoped_ptr<URLRequest> request_; | 361 std::unique_ptr<URLRequest> request_; |
361 }; | 362 }; |
362 | 363 |
363 TEST_F(ExtensionThrottleManagerTest, IsUrlStandardised) { | 364 TEST_F(ExtensionThrottleManagerTest, IsUrlStandardised) { |
364 MockExtensionThrottleManager manager; | 365 MockExtensionThrottleManager manager; |
365 GurlAndString test_values[] = { | 366 GurlAndString test_values[] = { |
366 GurlAndString(GURL("http://www.example.com"), | 367 GurlAndString(GURL("http://www.example.com"), |
367 std::string("http://www.example.com/"), __LINE__), | 368 std::string("http://www.example.com/"), __LINE__), |
368 GurlAndString(GURL("http://www.Example.com"), | 369 GurlAndString(GURL("http://www.Example.com"), |
369 std::string("http://www.example.com/"), __LINE__), | 370 std::string("http://www.example.com/"), __LINE__), |
370 GurlAndString(GURL("http://www.ex4mple.com/Pr4c71c41"), | 371 GurlAndString(GURL("http://www.ex4mple.com/Pr4c71c41"), |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 FAIL(); | 462 FAIL(); |
462 } | 463 } |
463 | 464 |
464 scoped_refptr<ExtensionThrottleEntryInterface> entry_after = | 465 scoped_refptr<ExtensionThrottleEntryInterface> entry_after = |
465 manager.RegisterRequestUrl(GURL("http://www.example.com/")); | 466 manager.RegisterRequestUrl(GURL("http://www.example.com/")); |
466 EXPECT_FALSE(entry_after->ShouldRejectRequest(*request_)); | 467 EXPECT_FALSE(entry_after->ShouldRejectRequest(*request_)); |
467 } | 468 } |
468 } | 469 } |
469 | 470 |
470 } // namespace extensions | 471 } // namespace extensions |
OLD | NEW |