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