| 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 "base/base64.h" | 5 #include "base/base64.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 // Update |file_size_| now because we wrote the file correctly. | 754 // Update |file_size_| now because we wrote the file correctly. |
| 755 file_size_ = static_cast<int64_t>(written); | 755 file_size_ = static_cast<int64_t>(written); |
| 756 | 756 |
| 757 return WRITE_SUCCESS; | 757 return WRITE_SUCCESS; |
| 758 } | 758 } |
| 759 | 759 |
| 760 HashPrefix V4Store::GetMatchingHashPrefix(const FullHash& full_hash) { | 760 HashPrefix V4Store::GetMatchingHashPrefix(const FullHash& full_hash) { |
| 761 // It should never be the case that more than one hash prefixes match a given | 761 // It should never be the case that more than one hash prefixes match a given |
| 762 // full hash. However, if that happens, this method returns any one of them. | 762 // full hash. However, if that happens, this method returns any one of them. |
| 763 // It does not guarantee which one of those will be returned. | 763 // It does not guarantee which one of those will be returned. |
| 764 DCHECK_EQ(32u, full_hash.size()); | 764 DCHECK(full_hash.size() == 32u || full_hash.size() == 21u); |
| 765 for (const auto& pair : hash_prefix_map_) { | 765 for (const auto& pair : hash_prefix_map_) { |
| 766 const PrefixSize& prefix_size = pair.first; | 766 const PrefixSize& prefix_size = pair.first; |
| 767 const HashPrefixes& hash_prefixes = pair.second; | 767 const HashPrefixes& hash_prefixes = pair.second; |
| 768 HashPrefix hash_prefix = full_hash.substr(0, prefix_size); | 768 HashPrefix hash_prefix = full_hash.substr(0, prefix_size); |
| 769 if (HashPrefixMatches(hash_prefix, hash_prefixes.begin(), | 769 if (HashPrefixMatches(hash_prefix, hash_prefixes.begin(), |
| 770 hash_prefixes.end())) { | 770 hash_prefixes.end())) { |
| 771 return hash_prefix; | 771 return hash_prefix; |
| 772 } | 772 } |
| 773 } | 773 } |
| 774 return HashPrefix(); | 774 return HashPrefix(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 base_metric + suffix, 1, 1000000, 50, | 858 base_metric + suffix, 1, 1000000, 50, |
| 859 base::HistogramBase::kUmaTargetedHistogramFlag); | 859 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 860 if (histogram) { | 860 if (histogram) { |
| 861 const int64_t file_size_kilobytes = file_size_ / 1024; | 861 const int64_t file_size_kilobytes = file_size_ / 1024; |
| 862 histogram->Add(file_size_kilobytes); | 862 histogram->Add(file_size_kilobytes); |
| 863 } | 863 } |
| 864 return file_size_; | 864 return file_size_; |
| 865 } | 865 } |
| 866 | 866 |
| 867 } // namespace safe_browsing | 867 } // namespace safe_browsing |
| OLD | NEW |