blob: 9d3f4e253bc3c5c3d8e0bd32c64b940224342043 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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
3// found in the LICENSE file.
4
5#include "net/url_request/url_request_throttler_test_support.h"
6
7#include "net/url_request/url_request_throttler_entry.h"
8
9namespace net {
10
11MockBackoffEntry::MockBackoffEntry(const BackoffEntry::Policy* const policy)
12 : BackoffEntry(policy) {
13}
14
15MockBackoffEntry::~MockBackoffEntry() {
16}
17
18base::TimeTicks MockBackoffEntry::ImplGetTimeNow() const {
19 return fake_now_;
20}
21
22void MockBackoffEntry::set_fake_now(const base::TimeTicks& now) {
23 fake_now_ = now;
24}
25
26MockURLRequestThrottlerHeaderAdapter::MockURLRequestThrottlerHeaderAdapter(
27 int response_code)
28 : fake_response_code_(response_code) {
29}
30
31MockURLRequestThrottlerHeaderAdapter::MockURLRequestThrottlerHeaderAdapter(
32 const std::string& retry_value,
33 const std::string& opt_out_value,
34 int response_code)
35 : fake_retry_value_(retry_value),
36 fake_opt_out_value_(opt_out_value),
37 fake_response_code_(response_code) {
38}
39
40MockURLRequestThrottlerHeaderAdapter::~MockURLRequestThrottlerHeaderAdapter() {
41}
42
43std::string MockURLRequestThrottlerHeaderAdapter::GetNormalizedValue(
44 const std::string& key) const {
45 if (key ==
46 URLRequestThrottlerEntry::kExponentialThrottlingHeader &&
47 !fake_opt_out_value_.empty()) {
48 return fake_opt_out_value_;
49 }
50
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010051 return std::string();
Torne (Richard Coles)58218062012-11-14 11:43:16 +000052}
53
54int MockURLRequestThrottlerHeaderAdapter::GetResponseCode() const {
55 return fake_response_code_;
56}
57
58} // namespace net