| 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 "net/url_request/url_request_throttler_manager.h" | 5 #include "net/url_request/url_request_throttler_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/metrics/histogram_samples.h" | 9 #include "base/metrics/histogram_samples.h" |
| 10 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 GURL url; | 166 GURL url; |
| 167 std::string result; | 167 std::string result; |
| 168 int line; | 168 int line; |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 } // namespace | 171 } // namespace |
| 172 | 172 |
| 173 class URLRequestThrottlerEntryTest : public testing::Test { | 173 class URLRequestThrottlerEntryTest : public testing::Test { |
| 174 protected: | 174 protected: |
| 175 URLRequestThrottlerEntryTest() : request_(GURL(), NULL, &context_) { | 175 URLRequestThrottlerEntryTest() : request_(GURL(), NULL, &context_, NULL) { |
| 176 } | 176 } |
| 177 | 177 |
| 178 virtual void SetUp(); | 178 virtual void SetUp(); |
| 179 virtual void TearDown(); | 179 virtual void TearDown(); |
| 180 | 180 |
| 181 // After calling this function, histogram snapshots in |samples_| contain | 181 // After calling this function, histogram snapshots in |samples_| contain |
| 182 // only the delta caused by the test case currently running. | 182 // only the delta caused by the test case currently running. |
| 183 void CalculateHistogramDeltas(); | 183 void CalculateHistogramDeltas(); |
| 184 | 184 |
| 185 TimeTicks now_; | 185 TimeTicks now_; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 ASSERT_FALSE(MockURLRequestThrottlerEntry::ExplicitUserRequest(0)); | 384 ASSERT_FALSE(MockURLRequestThrottlerEntry::ExplicitUserRequest(0)); |
| 385 ASSERT_TRUE(MockURLRequestThrottlerEntry::ExplicitUserRequest( | 385 ASSERT_TRUE(MockURLRequestThrottlerEntry::ExplicitUserRequest( |
| 386 LOAD_MAYBE_USER_GESTURE)); | 386 LOAD_MAYBE_USER_GESTURE)); |
| 387 ASSERT_FALSE(MockURLRequestThrottlerEntry::ExplicitUserRequest( | 387 ASSERT_FALSE(MockURLRequestThrottlerEntry::ExplicitUserRequest( |
| 388 ~LOAD_MAYBE_USER_GESTURE)); | 388 ~LOAD_MAYBE_USER_GESTURE)); |
| 389 } | 389 } |
| 390 | 390 |
| 391 class URLRequestThrottlerManagerTest : public testing::Test { | 391 class URLRequestThrottlerManagerTest : public testing::Test { |
| 392 protected: | 392 protected: |
| 393 URLRequestThrottlerManagerTest() | 393 URLRequestThrottlerManagerTest() |
| 394 : request_(GURL(), NULL, &context_) { | 394 : request_(GURL(), NULL, &context_, NULL) { |
| 395 } | 395 } |
| 396 | 396 |
| 397 virtual void SetUp() { | 397 virtual void SetUp() { |
| 398 request_.set_load_flags(0); | 398 request_.set_load_flags(0); |
| 399 } | 399 } |
| 400 | 400 |
| 401 // context_ must be declared before request_. | 401 // context_ must be declared before request_. |
| 402 TestURLRequestContext context_; | 402 TestURLRequestContext context_; |
| 403 TestURLRequest request_; | 403 TestURLRequest request_; |
| 404 }; | 404 }; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 FAIL(); | 555 FAIL(); |
| 556 } | 556 } |
| 557 | 557 |
| 558 scoped_refptr<net::URLRequestThrottlerEntryInterface> entry_after = | 558 scoped_refptr<net::URLRequestThrottlerEntryInterface> entry_after = |
| 559 manager.RegisterRequestUrl(GURL("http://www.example.com/")); | 559 manager.RegisterRequestUrl(GURL("http://www.example.com/")); |
| 560 EXPECT_FALSE(entry_after->ShouldRejectRequest(request_)); | 560 EXPECT_FALSE(entry_after->ShouldRejectRequest(request_)); |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 | 563 |
| 564 } // namespace net | 564 } // namespace net |
| OLD | NEW |