OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ | 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ |
6 #define COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ | 6 #define COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "base/tracked_objects.h" | 14 #include "base/tracked_objects.h" |
15 #include "components/domain_reliability/domain_reliability_export.h" | 15 #include "components/domain_reliability/domain_reliability_export.h" |
| 16 #include "net/base/backoff_entry.h" |
16 #include "net/http/http_response_info.h" | 17 #include "net/http/http_response_info.h" |
17 | 18 |
18 namespace domain_reliability { | 19 namespace domain_reliability { |
19 | 20 |
20 // Attempts to convert a net error and an HTTP response code into the status | 21 // Attempts to convert a net error and an HTTP response code into the status |
21 // string that should be recorded in a beacon. Returns true if it could. | 22 // string that should be recorded in a beacon. Returns true if it could. |
22 // | 23 // |
23 // N.B.: This functions as the whitelist of "safe" errors to report; network- | 24 // N.B.: This functions as the whitelist of "safe" errors to report; network- |
24 // local errors are purposefully not converted to avoid revealing | 25 // local errors are purposefully not converted to avoid revealing |
25 // information about the local network to the remote server. | 26 // information about the local network to the remote server. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 ActualTime(); | 76 ActualTime(); |
76 | 77 |
77 ~ActualTime() override; | 78 ~ActualTime() override; |
78 | 79 |
79 // MockableTime implementation: | 80 // MockableTime implementation: |
80 base::Time Now() override; | 81 base::Time Now() override; |
81 base::TimeTicks NowTicks() override; | 82 base::TimeTicks NowTicks() override; |
82 scoped_ptr<MockableTime::Timer> CreateTimer() override; | 83 scoped_ptr<MockableTime::Timer> CreateTimer() override; |
83 }; | 84 }; |
84 | 85 |
| 86 // A subclass of BackoffEntry that uses a MockableTime to keep track of time. |
| 87 class MockableTimeBackoffEntry : public net::BackoffEntry { |
| 88 public: |
| 89 MockableTimeBackoffEntry(const net::BackoffEntry::Policy* const policy, |
| 90 MockableTime* time); |
| 91 |
| 92 virtual ~MockableTimeBackoffEntry(); |
| 93 |
| 94 protected: |
| 95 virtual base::TimeTicks ImplGetTimeNow() const override; |
| 96 |
| 97 private: |
| 98 MockableTime* time_; |
| 99 }; |
| 100 |
85 } // namespace domain_reliability | 101 } // namespace domain_reliability |
86 | 102 |
87 #endif // COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ | 103 #endif // COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ |
OLD | NEW |