OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "components/safe_browsing_db/v4_protocol_manager_util.h" | 5 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 std::size_t first = std::hash<unsigned int>()(platform_type); | 32 std::size_t first = std::hash<unsigned int>()(platform_type); |
33 std::size_t second = std::hash<unsigned int>()(threat_entry_type); | 33 std::size_t second = std::hash<unsigned int>()(threat_entry_type); |
34 std::size_t third = std::hash<unsigned int>()(threat_type); | 34 std::size_t third = std::hash<unsigned int>()(threat_type); |
35 | 35 |
36 std::size_t interim = base::HashInts(first, second); | 36 std::size_t interim = base::HashInts(first, second); |
37 return base::HashInts(interim, third); | 37 return base::HashInts(interim, third); |
38 } | 38 } |
39 | 39 |
40 V4ProtocolConfig::V4ProtocolConfig() : disable_auto_update(false) {} | 40 V4ProtocolConfig::V4ProtocolConfig() : disable_auto_update(false) {} |
41 | 41 |
| 42 V4ProtocolConfig::V4ProtocolConfig(const V4ProtocolConfig& other) = default; |
| 43 |
42 V4ProtocolConfig::~V4ProtocolConfig() {} | 44 V4ProtocolConfig::~V4ProtocolConfig() {} |
43 | 45 |
44 // static | 46 // static |
45 // Backoff interval is MIN(((2^(n-1))*15 minutes) * (RAND + 1), 24 hours) where | 47 // Backoff interval is MIN(((2^(n-1))*15 minutes) * (RAND + 1), 24 hours) where |
46 // n is the number of consecutive errors. | 48 // n is the number of consecutive errors. |
47 base::TimeDelta V4ProtocolManagerUtil::GetNextBackOffInterval( | 49 base::TimeDelta V4ProtocolManagerUtil::GetNextBackOffInterval( |
48 size_t* error_count, | 50 size_t* error_count, |
49 size_t* multiplier) { | 51 size_t* multiplier) { |
50 DCHECK(multiplier && error_count); | 52 DCHECK(multiplier && error_count); |
51 (*error_count)++; | 53 (*error_count)++; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 prefix.c_str(), method.c_str(), request_base64.c_str(), | 101 prefix.c_str(), method.c_str(), request_base64.c_str(), |
100 client_id.c_str(), version.c_str()); | 102 client_id.c_str(), version.c_str()); |
101 if (!key_param.empty()) { | 103 if (!key_param.empty()) { |
102 base::StringAppendF(&url, "&key=%s", | 104 base::StringAppendF(&url, "&key=%s", |
103 net::EscapeQueryParamValue(key_param, true).c_str()); | 105 net::EscapeQueryParamValue(key_param, true).c_str()); |
104 } | 106 } |
105 return url; | 107 return url; |
106 } | 108 } |
107 | 109 |
108 } // namespace safe_browsing | 110 } // namespace safe_browsing |
OLD | NEW |