chromeos: bluetooth: add BluetoothInputClient
[chromium-blink-merge.git] / net / url_request / url_request_throttler_test_support.h
blob0db36c072249d4537e78dd45f0b554342e76c060
1 // Copyright (c) 2011 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.
5 #ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_TEST_SUPPORT_H_
6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_TEST_SUPPORT_H_
7 #pragma once
9 #include <string>
11 #include "base/time.h"
12 #include "net/base/backoff_entry.h"
13 #include "net/url_request/url_request_throttler_header_interface.h"
15 namespace net {
17 class MockBackoffEntry : public BackoffEntry {
18 public:
19 explicit MockBackoffEntry(const BackoffEntry::Policy* const policy);
20 virtual ~MockBackoffEntry();
22 // BackoffEntry overrides.
23 virtual base::TimeTicks ImplGetTimeNow() const OVERRIDE;
25 void set_fake_now(const base::TimeTicks& now);
27 private:
28 base::TimeTicks fake_now_;
31 // Mocks the URLRequestThrottlerHeaderInterface, allowing testing code to
32 // pass arbitrary fake headers to the throttling code.
33 class MockURLRequestThrottlerHeaderAdapter
34 : public URLRequestThrottlerHeaderInterface {
35 public:
36 // Constructs mock response headers with the given |response_code| and no
37 // custom response header fields.
38 explicit MockURLRequestThrottlerHeaderAdapter(int response_code);
40 // Constructs mock response headers with the given |response_code| and
41 // with a custom-retry header value |retry_value| if it is non-empty, and
42 // a custom opt-out header value |opt_out_value| if it is non-empty.
43 MockURLRequestThrottlerHeaderAdapter(const std::string& retry_value,
44 const std::string& opt_out_value,
45 int response_code);
46 virtual ~MockURLRequestThrottlerHeaderAdapter();
48 // URLRequestThrottlerHeaderInterface overrides.
49 virtual std::string GetNormalizedValue(const std::string& key) const OVERRIDE;
50 virtual int GetResponseCode() const OVERRIDE;
52 private:
53 std::string fake_retry_value_;
54 std::string fake_opt_out_value_;
55 int fake_response_code_;
57 DISALLOW_COPY_AND_ASSIGN(MockURLRequestThrottlerHeaderAdapter);
60 } // namespace net
62 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_TEST_SUPPORT_H_