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_test_support.h" | 5 #include "net/url_request/url_request_throttler_test_support.h" |
6 | 6 |
7 #include "net/url_request/url_request_throttler_entry.h" | 7 #include "net/url_request/url_request_throttler_entry.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
11 TestTickClock::TestTickClock() {} | 11 TestTickClock::TestTickClock() {} |
12 | 12 |
13 TestTickClock::TestTickClock(base::TimeTicks now) : now_ticks_(now) {} | 13 TestTickClock::TestTickClock(base::TimeTicks now) : now_ticks_(now) {} |
14 | 14 |
15 TestTickClock::~TestTickClock() {} | 15 TestTickClock::~TestTickClock() {} |
16 | 16 |
17 base::TimeTicks TestTickClock::NowTicks() { | 17 base::TimeTicks TestTickClock::NowTicks() { |
18 return now_ticks_; | 18 return now_ticks_; |
19 } | 19 } |
20 | 20 |
21 MockURLRequestThrottlerHeaderAdapter::MockURLRequestThrottlerHeaderAdapter( | |
22 int response_code) | |
23 : fake_response_code_(response_code) { | |
24 } | |
25 | |
26 MockURLRequestThrottlerHeaderAdapter::MockURLRequestThrottlerHeaderAdapter( | |
27 const std::string& retry_value, | |
28 const std::string& opt_out_value, | |
29 int response_code) | |
30 : fake_retry_value_(retry_value), | |
31 fake_opt_out_value_(opt_out_value), | |
32 fake_response_code_(response_code) { | |
33 } | |
34 | |
35 MockURLRequestThrottlerHeaderAdapter::~MockURLRequestThrottlerHeaderAdapter() { | |
36 } | |
37 | |
38 std::string MockURLRequestThrottlerHeaderAdapter::GetNormalizedValue( | |
39 const std::string& key) const { | |
40 if (key == | |
41 URLRequestThrottlerEntry::kExponentialThrottlingHeader && | |
42 !fake_opt_out_value_.empty()) { | |
43 return fake_opt_out_value_; | |
44 } | |
45 | |
46 return std::string(); | |
47 } | |
48 | |
49 int MockURLRequestThrottlerHeaderAdapter::GetResponseCode() const { | |
50 return fake_response_code_; | |
51 } | |
52 | |
53 } // namespace net | 21 } // namespace net |
OLD | NEW |