| 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/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 escaped_str += c; | 55 escaped_str += c; |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 return escaped_str; | 59 return escaped_str; |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace | 62 } // namespace |
| 63 | 63 |
| 64 std::ostream& operator<<(std::ostream& os, const ListIdentifier& id) { | 64 std::ostream& operator<<(std::ostream& os, const ListIdentifier& id) { |
| 65 os << "{hash: " << id.hash() << "; platform_type: " << id.platform_type | 65 os << "{hash: " << id.hash() << "; platform_type: " << id.platform_type() |
| 66 << "; threat_entry_type: " << id.threat_entry_type | 66 << "; threat_entry_type: " << id.threat_entry_type() |
| 67 << "; threat_type: " << id.threat_type << "}"; | 67 << "; threat_type: " << id.threat_type() << "}"; |
| 68 return os; | 68 return os; |
| 69 } | 69 } |
| 70 | 70 |
| 71 PlatformType GetCurrentPlatformType() { | 71 PlatformType GetCurrentPlatformType() { |
| 72 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
| 73 return WINDOWS_PLATFORM; | 73 return WINDOWS_PLATFORM; |
| 74 #elif defined(OS_LINUX) | 74 #elif defined(OS_LINUX) |
| 75 return LINUX_PLATFORM; | 75 return LINUX_PLATFORM; |
| 76 #elif defined(OS_MACOSX) | 76 #elif defined(OS_MACOSX) |
| 77 return OSX_PLATFORM; | 77 return OSX_PLATFORM; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 size_t StoreAndHashPrefix::hash() const { | 118 size_t StoreAndHashPrefix::hash() const { |
| 119 std::size_t first = list_id.hash(); | 119 std::size_t first = list_id.hash(); |
| 120 std::size_t second = std::hash<std::string>()(hash_prefix); | 120 std::size_t second = std::hash<std::string>()(hash_prefix); |
| 121 | 121 |
| 122 return base::HashInts(first, second); | 122 return base::HashInts(first, second); |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool ListIdentifier::operator==(const ListIdentifier& other) const { | 125 bool ListIdentifier::operator==(const ListIdentifier& other) const { |
| 126 return platform_type == other.platform_type && | 126 return platform_type_ == other.platform_type_ && |
| 127 threat_entry_type == other.threat_entry_type && | 127 threat_entry_type_ == other.threat_entry_type_ && |
| 128 threat_type == other.threat_type; | 128 threat_type_ == other.threat_type_; |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool ListIdentifier::operator!=(const ListIdentifier& other) const { | 131 bool ListIdentifier::operator!=(const ListIdentifier& other) const { |
| 132 return !operator==(other); | 132 return !operator==(other); |
| 133 } | 133 } |
| 134 | 134 |
| 135 size_t ListIdentifier::hash() const { | 135 size_t ListIdentifier::hash() const { |
| 136 std::size_t first = std::hash<unsigned int>()(platform_type); | 136 std::size_t first = std::hash<unsigned int>()(platform_type_); |
| 137 std::size_t second = std::hash<unsigned int>()(threat_entry_type); | 137 std::size_t second = std::hash<unsigned int>()(threat_entry_type_); |
| 138 std::size_t third = std::hash<unsigned int>()(threat_type); | 138 std::size_t third = std::hash<unsigned int>()(threat_type_); |
| 139 | 139 |
| 140 std::size_t interim = base::HashInts(first, second); | 140 std::size_t interim = base::HashInts(first, second); |
| 141 return base::HashInts(interim, third); | 141 return base::HashInts(interim, third); |
| 142 } | 142 } |
| 143 | 143 |
| 144 ListIdentifier::ListIdentifier() {} | 144 ListIdentifier::ListIdentifier() {} |
| 145 | 145 |
| 146 ListIdentifier::ListIdentifier(PlatformType platform_type, | 146 ListIdentifier::ListIdentifier(PlatformType platform_type, |
| 147 ThreatEntryType threat_entry_type, | 147 ThreatEntryType threat_entry_type, |
| 148 ThreatType threat_type) | 148 ThreatType threat_type) |
| 149 : platform_type(platform_type), | 149 : platform_type_(platform_type), |
| 150 threat_entry_type(threat_entry_type), | 150 threat_entry_type_(threat_entry_type), |
| 151 threat_type(threat_type) { | 151 threat_type_(threat_type) { |
| 152 DCHECK(PlatformType_IsValid(platform_type)); | 152 DCHECK(PlatformType_IsValid(platform_type)); |
| 153 DCHECK(ThreatEntryType_IsValid(threat_entry_type)); | 153 DCHECK(ThreatEntryType_IsValid(threat_entry_type)); |
| 154 DCHECK(ThreatType_IsValid(threat_type)); | 154 DCHECK(ThreatType_IsValid(threat_type)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 ListIdentifier::ListIdentifier(const ListUpdateResponse& response) | 157 ListIdentifier::ListIdentifier(const ListUpdateResponse& response) |
| 158 : ListIdentifier(response.platform_type(), | 158 : ListIdentifier(response.platform_type(), |
| 159 response.threat_entry_type(), | 159 response.threat_entry_type(), |
| 160 response.threat_type()) {} | 160 response.threat_type()) {} |
| 161 | 161 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // static | 499 // static |
| 500 void V4ProtocolManagerUtil::SetClientInfoFromConfig( | 500 void V4ProtocolManagerUtil::SetClientInfoFromConfig( |
| 501 ClientInfo* client_info, | 501 ClientInfo* client_info, |
| 502 const V4ProtocolConfig& config) { | 502 const V4ProtocolConfig& config) { |
| 503 DCHECK(client_info); | 503 DCHECK(client_info); |
| 504 client_info->set_client_id(config.client_name); | 504 client_info->set_client_id(config.client_name); |
| 505 client_info->set_client_version(config.version); | 505 client_info->set_client_version(config.version); |
| 506 } | 506 } |
| 507 | 507 |
| 508 } // namespace safe_browsing | 508 } // namespace safe_browsing |
| OLD | NEW |