Chromium Code Reviews| 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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 // Update |file_size_| now because we wrote the file correctly. | 757 // Update |file_size_| now because we wrote the file correctly. |
| 758 file_size_ = static_cast<int64_t>(written); | 758 file_size_ = static_cast<int64_t>(written); |
| 759 | 759 |
| 760 return WRITE_SUCCESS; | 760 return WRITE_SUCCESS; |
| 761 } | 761 } |
| 762 | 762 |
| 763 HashPrefix V4Store::GetMatchingHashPrefix(const FullHash& full_hash) { | 763 HashPrefix V4Store::GetMatchingHashPrefix(const FullHash& full_hash) { |
| 764 // It should never be the case that more than one hash prefixes match a given | 764 // It should never be the case that more than one hash prefixes match a given |
| 765 // full hash. However, if that happens, this method returns any one of them. | 765 // full hash. However, if that happens, this method returns any one of them. |
| 766 // It does not guarantee which one of those will be returned. | 766 // It does not guarantee which one of those will be returned. |
| 767 DCHECK_EQ(32u, full_hash.size()); | |
| 768 for (const auto& pair : hash_prefix_map_) { | 767 for (const auto& pair : hash_prefix_map_) { |
|
Nathan Parker
2017/01/04 18:58:46
Why isn't this causing crashes all the time? Do we
vakh (use Gerrit instead)
2017/01/10 03:47:56
Because it is executed only for MatchMalwareIP and
| |
| 769 const PrefixSize& prefix_size = pair.first; | 768 const PrefixSize& prefix_size = pair.first; |
| 770 const HashPrefixes& hash_prefixes = pair.second; | 769 const HashPrefixes& hash_prefixes = pair.second; |
| 771 HashPrefix hash_prefix = full_hash.substr(0, prefix_size); | 770 HashPrefix hash_prefix = full_hash.substr(0, prefix_size); |
| 772 if (HashPrefixMatches(hash_prefix, hash_prefixes.begin(), | 771 if (HashPrefixMatches(hash_prefix, hash_prefixes.begin(), |
| 773 hash_prefixes.end())) { | 772 hash_prefixes.end())) { |
| 774 return hash_prefix; | 773 return hash_prefix; |
| 775 } | 774 } |
| 776 } | 775 } |
| 777 return HashPrefix(); | 776 return HashPrefix(); |
| 778 } | 777 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 base_metric + suffix, 1, 1000000, 50, | 860 base_metric + suffix, 1, 1000000, 50, |
| 862 base::HistogramBase::kUmaTargetedHistogramFlag); | 861 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 863 if (histogram) { | 862 if (histogram) { |
| 864 const int64_t file_size_kilobytes = file_size_ / 1024; | 863 const int64_t file_size_kilobytes = file_size_ / 1024; |
| 865 histogram->Add(file_size_kilobytes); | 864 histogram->Add(file_size_kilobytes); |
| 866 } | 865 } |
| 867 return file_size_; | 866 return file_size_; |
| 868 } | 867 } |
| 869 | 868 |
| 870 } // namespace safe_browsing | 869 } // namespace safe_browsing |
| OLD | NEW |