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 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_vector.h" | |
15 #include "base/time/clock.h" | 14 #include "base/time/clock.h" |
16 #include "base/time/tick_clock.h" | 15 #include "base/time/tick_clock.h" |
17 #include "base/time/time.h" | 16 #include "base/time/time.h" |
18 #include "base/tracked_objects.h" | 17 #include "base/tracked_objects.h" |
19 #include "components/domain_reliability/domain_reliability_export.h" | 18 #include "components/domain_reliability/domain_reliability_export.h" |
20 #include "components/domain_reliability/uploader.h" | 19 #include "components/domain_reliability/uploader.h" |
21 #include "net/http/http_response_info.h" | 20 #include "net/http/http_response_info.h" |
22 #include "net/url_request/url_request_status.h" | 21 #include "net/url_request/url_request_status.h" |
23 | 22 |
24 namespace domain_reliability { | 23 namespace domain_reliability { |
(...skipping 19 matching lines...) Expand all Loading... |
44 int GetNetErrorFromURLRequestStatus(const net::URLRequestStatus& status); | 43 int GetNetErrorFromURLRequestStatus(const net::URLRequestStatus& status); |
45 | 44 |
46 // Based on the network error code, HTTP response code, and Retry-After value, | 45 // Based on the network error code, HTTP response code, and Retry-After value, |
47 // fills |status| with the result of a report upload. | 46 // fills |status| with the result of a report upload. |
48 void GetUploadResultFromResponseDetails( | 47 void GetUploadResultFromResponseDetails( |
49 int net_error, | 48 int net_error, |
50 int http_response_code, | 49 int http_response_code, |
51 base::TimeDelta retry_after, | 50 base::TimeDelta retry_after, |
52 DomainReliabilityUploader::UploadResult* result); | 51 DomainReliabilityUploader::UploadResult* result); |
53 | 52 |
54 GURL SanitizeURLForReport(const GURL& beacon_url, | 53 GURL SanitizeURLForReport( |
55 const GURL& collector_url, | 54 const GURL& beacon_url, |
56 const ScopedVector<std::string>& path_prefixes); | 55 const GURL& collector_url, |
| 56 const std::vector<std::unique_ptr<std::string>>& path_prefixes); |
57 | 57 |
58 // Mockable wrapper around TimeTicks::Now and Timer. Mock version is in | 58 // Mockable wrapper around TimeTicks::Now and Timer. Mock version is in |
59 // test_util.h. | 59 // test_util.h. |
60 // TODO(juliatuttle): Rename to Time{Provider,Source,?}. | 60 // TODO(juliatuttle): Rename to Time{Provider,Source,?}. |
61 class DOMAIN_RELIABILITY_EXPORT MockableTime : public base::Clock, | 61 class DOMAIN_RELIABILITY_EXPORT MockableTime : public base::Clock, |
62 public base::TickClock { | 62 public base::TickClock { |
63 public: | 63 public: |
64 // Mockable wrapper around (a subset of) base::Timer. | 64 // Mockable wrapper around (a subset of) base::Timer. |
65 class DOMAIN_RELIABILITY_EXPORT Timer { | 65 class DOMAIN_RELIABILITY_EXPORT Timer { |
66 public: | 66 public: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 // MockableTime implementation: | 104 // MockableTime implementation: |
105 base::Time Now() override; | 105 base::Time Now() override; |
106 base::TimeTicks NowTicks() override; | 106 base::TimeTicks NowTicks() override; |
107 std::unique_ptr<MockableTime::Timer> CreateTimer() override; | 107 std::unique_ptr<MockableTime::Timer> CreateTimer() override; |
108 }; | 108 }; |
109 | 109 |
110 } // namespace domain_reliability | 110 } // namespace domain_reliability |
111 | 111 |
112 #endif // COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ | 112 #endif // COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ |
OLD | NEW |