Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/safe_browsing/safe_browsing_store.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_store.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace safe_browsing { |
| 12 | 12 |
| 13 // Return |true| if the range is sorted by the given comparator. | 13 // Return |true| if the range is sorted by the given comparator. |
|
Nathan Parker
2015/11/05 22:00:53
anon namespace
vakh (old account. dont use)
2015/11/07 01:22:56
Done.
| |
| 14 template <typename CTI, typename LESS> | 14 template <typename CTI, typename LESS> |
| 15 bool sorted(CTI beg, CTI end, LESS less) { | 15 bool sorted(CTI beg, CTI end, LESS less) { |
| 16 while ((end - beg) > 2) { | 16 while ((end - beg) > 2) { |
| 17 CTI n = beg++; | 17 CTI n = beg++; |
| 18 if (less(*beg, *n)) | 18 if (less(*beg, *n)) |
| 19 return false; | 19 return false; |
| 20 } | 20 } |
| 21 return true; | 21 return true; |
| 22 } | 22 } |
| 23 | 23 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 for (typename ItemsT::iterator iter = end_iter; | 81 for (typename ItemsT::iterator iter = end_iter; |
| 82 iter != items->end(); ++iter) { | 82 iter != items->end(); ++iter) { |
| 83 if (del_set.count(iter->chunk_id) == 0) { | 83 if (del_set.count(iter->chunk_id) == 0) { |
| 84 *end_iter = *iter; | 84 *end_iter = *iter; |
| 85 ++end_iter; | 85 ++end_iter; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 items->erase(end_iter, items->end()); | 88 items->erase(end_iter, items->end()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace | |
| 92 | |
| 93 void SBProcessSubs(SBAddPrefixes* add_prefixes, | 91 void SBProcessSubs(SBAddPrefixes* add_prefixes, |
| 94 SBSubPrefixes* sub_prefixes, | 92 SBSubPrefixes* sub_prefixes, |
| 95 std::vector<SBAddFullHash>* add_full_hashes, | 93 std::vector<SBAddFullHash>* add_full_hashes, |
| 96 std::vector<SBSubFullHash>* sub_full_hashes, | 94 std::vector<SBSubFullHash>* sub_full_hashes, |
| 97 const base::hash_set<int32>& add_chunks_deleted, | 95 const base::hash_set<int32>& add_chunks_deleted, |
| 98 const base::hash_set<int32>& sub_chunks_deleted) { | 96 const base::hash_set<int32>& sub_chunks_deleted) { |
| 99 // It is possible to structure templates and template | 97 // It is possible to structure templates and template |
| 100 // specializations such that the following calls work without having | 98 // specializations such that the following calls work without having |
| 101 // to qualify things. It becomes very arbitrary, though, and less | 99 // to qualify things. It becomes very arbitrary, though, and less |
| 102 // clear how things are working. | 100 // clear how things are working. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 122 SBAddPrefixHashLess<SBSubFullHash,SBAddFullHash>); | 120 SBAddPrefixHashLess<SBSubFullHash,SBAddFullHash>); |
| 123 | 121 |
| 124 // Remove items from the deleted chunks. This is done after other | 122 // Remove items from the deleted chunks. This is done after other |
| 125 // processing to allow subs to knock out adds (and be removed) even | 123 // processing to allow subs to knock out adds (and be removed) even |
| 126 // if the add's chunk is deleted. | 124 // if the add's chunk is deleted. |
| 127 RemoveDeleted(add_prefixes, add_chunks_deleted); | 125 RemoveDeleted(add_prefixes, add_chunks_deleted); |
| 128 RemoveDeleted(sub_prefixes, sub_chunks_deleted); | 126 RemoveDeleted(sub_prefixes, sub_chunks_deleted); |
| 129 RemoveDeleted(add_full_hashes, add_chunks_deleted); | 127 RemoveDeleted(add_full_hashes, add_chunks_deleted); |
| 130 RemoveDeleted(sub_full_hashes, sub_chunks_deleted); | 128 RemoveDeleted(sub_full_hashes, sub_chunks_deleted); |
| 131 } | 129 } |
| 130 | |
| 131 } // namespace safe_browsing | |
| OLD | NEW |