Home | History | Annotate | Download | only in url_request
      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
      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 
      9 namespace net {
     10 
     11 MockBackoffEntry::MockBackoffEntry(const BackoffEntry::Policy* const policy)
     12     : BackoffEntry(policy) {
     13 }
     14 
     15 MockBackoffEntry::~MockBackoffEntry() {
     16 }
     17 
     18 base::TimeTicks MockBackoffEntry::ImplGetTimeNow() const {
     19   return fake_now_;
     20 }
     21 
     22 void MockBackoffEntry::set_fake_now(const base::TimeTicks& now) {
     23   fake_now_ = now;
     24 }
     25 
     26 MockURLRequestThrottlerHeaderAdapter::MockURLRequestThrottlerHeaderAdapter(
     27     int response_code)
     28     : fake_response_code_(response_code) {
     29 }
     30 
     31 MockURLRequestThrottlerHeaderAdapter::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 
     40 MockURLRequestThrottlerHeaderAdapter::~MockURLRequestThrottlerHeaderAdapter() {
     41 }
     42 
     43 std::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 
     51   return std::string();
     52 }
     53 
     54 int MockURLRequestThrottlerHeaderAdapter::GetResponseCode() const {
     55   return fake_response_code_;
     56 }
     57 
     58 }  // namespace net
     59