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" | |
17 #include "net/http/http_response_info.h" | 16 #include "net/http/http_response_info.h" |
18 | 17 |
19 namespace domain_reliability { | 18 namespace domain_reliability { |
20 | 19 |
21 // Attempts to convert a net error and an HTTP response code into the status | 20 // Attempts to convert a net error and an HTTP response code into the status |
22 // string that should be recorded in a beacon. Returns true if it could. | 21 // string that should be recorded in a beacon. Returns true if it could. |
23 // | 22 // |
24 // N.B.: This functions as the whitelist of "safe" errors to report; network- | 23 // N.B.: This functions as the whitelist of "safe" errors to report; network- |
25 // local errors are purposefully not converted to avoid revealing | 24 // local errors are purposefully not converted to avoid revealing |
26 // information about the local network to the remote server. | 25 // information about the local network to the remote server. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 ActualTime(); | 75 ActualTime(); |
77 | 76 |
78 ~ActualTime() override; | 77 ~ActualTime() override; |
79 | 78 |
80 // MockableTime implementation: | 79 // MockableTime implementation: |
81 base::Time Now() override; | 80 base::Time Now() override; |
82 base::TimeTicks NowTicks() override; | 81 base::TimeTicks NowTicks() override; |
83 scoped_ptr<MockableTime::Timer> CreateTimer() override; | 82 scoped_ptr<MockableTime::Timer> CreateTimer() override; |
84 }; | 83 }; |
85 | 84 |
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 | |
101 } // namespace domain_reliability | 85 } // namespace domain_reliability |
102 | 86 |
103 #endif // COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ | 87 #endif // COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ |
OLD | NEW |