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_get_hash_protocol_manager.h" | 5 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64url.h" | 9 #include "base/base64url.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 fetcher->Start(); | 306 fetcher->Start(); |
307 } | 307 } |
308 | 308 |
309 void V4GetHashProtocolManager::GetFullHashesWithApis( | 309 void V4GetHashProtocolManager::GetFullHashesWithApis( |
310 const GURL& url, | 310 const GURL& url, |
311 ThreatMetadataForApiCallback api_callback) { | 311 ThreatMetadataForApiCallback api_callback) { |
312 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 312 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
313 DCHECK(url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme)); | 313 DCHECK(url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme)); |
314 | 314 |
315 std::unordered_set<FullHash> full_hashes; | 315 std::unordered_set<FullHash> full_hashes; |
316 V4ProtocolManagerUtil::UrlToFullHashes(url, &full_hashes); | 316 V4ProtocolManagerUtil::UrlToFullHashes(url.GetOrigin(), &full_hashes); |
317 | 317 |
318 FullHashToStoreAndHashPrefixesMap full_hash_to_store_and_hash_prefixes; | 318 FullHashToStoreAndHashPrefixesMap full_hash_to_store_and_hash_prefixes; |
319 for (const FullHash& full_hash : full_hashes) { | 319 for (const FullHash& full_hash : full_hashes) { |
320 HashPrefix prefix; | 320 HashPrefix prefix; |
321 bool result = | 321 bool result = |
322 V4ProtocolManagerUtil::FullHashToSmallestHashPrefix(full_hash, &prefix); | 322 V4ProtocolManagerUtil::FullHashToSmallestHashPrefix(full_hash, &prefix); |
323 DCHECK(result); | 323 DCHECK(result); |
324 full_hash_to_store_and_hash_prefixes[full_hash].emplace_back( | 324 full_hash_to_store_and_hash_prefixes[full_hash].emplace_back( |
325 GetChromeUrlApiId(), prefix); | 325 GetChromeUrlApiId(), prefix); |
326 } | 326 } |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 std::ostream& operator<<(std::ostream& os, const FullHashInfo& fhi) { | 739 std::ostream& operator<<(std::ostream& os, const FullHashInfo& fhi) { |
740 os << "{full_hash: " << fhi.full_hash << "; list_id: " << fhi.list_id | 740 os << "{full_hash: " << fhi.full_hash << "; list_id: " << fhi.list_id |
741 << "; positive_expiry: " << fhi.positive_expiry | 741 << "; positive_expiry: " << fhi.positive_expiry |
742 << "; metadata.api_permissions.size(): " | 742 << "; metadata.api_permissions.size(): " |
743 << fhi.metadata.api_permissions.size() << "}"; | 743 << fhi.metadata.api_permissions.size() << "}"; |
744 return os; | 744 return os; |
745 } | 745 } |
746 #endif | 746 #endif |
747 | 747 |
748 } // namespace safe_browsing | 748 } // namespace safe_browsing |
OLD | NEW |