Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_database.cc

Issue 4588001: Cleanup converting safe-browsing chunks to range list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Lei comments. Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/safe_browsing/chunk_range_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_database.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/metrics/stats_counters.h" 9 #include "base/metrics/stats_counters.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 iter != chunks.end(); ++iter) { 116 iter != chunks.end(); ++iter) {
117 if (safe_browsing_util::MALWARE == DecodeListId(*iter)) { 117 if (safe_browsing_util::MALWARE == DecodeListId(*iter)) {
118 malware_chunks.push_back(DecodeChunkId(*iter)); 118 malware_chunks.push_back(DecodeChunkId(*iter));
119 } else if (safe_browsing_util::PHISH == DecodeListId(*iter)) { 119 } else if (safe_browsing_util::PHISH == DecodeListId(*iter)) {
120 phishing_chunks.push_back(DecodeChunkId(*iter)); 120 phishing_chunks.push_back(DecodeChunkId(*iter));
121 } else { 121 } else {
122 NOTREACHED(); 122 NOTREACHED();
123 } 123 }
124 } 124 }
125 125
126 std::sort(malware_chunks.begin(), malware_chunks.end()); 126 ChunksToRangeString(malware_chunks, malware_list);
127 std::vector<ChunkRange> malware_ranges; 127 ChunksToRangeString(phishing_chunks, phishing_list);
128 ChunksToRanges(malware_chunks, &malware_ranges);
129 RangesToString(malware_ranges, malware_list);
130
131 std::sort(phishing_chunks.begin(), phishing_chunks.end());
132 std::vector<ChunkRange> phishing_ranges;
133 ChunksToRanges(phishing_chunks, &phishing_ranges);
134 RangesToString(phishing_ranges, phishing_list);
135 } 128 }
136 129
137 // Order |SBAddFullHash| on the prefix part. |SBAddPrefixLess()| from 130 // Order |SBAddFullHash| on the prefix part. |SBAddPrefixLess()| from
138 // safe_browsing_store.h orders on both chunk-id and prefix. 131 // safe_browsing_store.h orders on both chunk-id and prefix.
139 bool SBAddFullHashPrefixLess(const SBAddFullHash& a, const SBAddFullHash& b) { 132 bool SBAddFullHashPrefixLess(const SBAddFullHash& a, const SBAddFullHash& b) {
140 return a.full_hash.prefix < b.full_hash.prefix; 133 return a.full_hash.prefix < b.full_hash.prefix;
141 } 134 }
142 135
143 } // namespace 136 } // namespace
144 137
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 const base::TimeTicks before = base::TimeTicks::Now(); 687 const base::TimeTicks before = base::TimeTicks::Now();
695 const bool write_ok = bloom_filter_->WriteFile(bloom_filter_filename_); 688 const bool write_ok = bloom_filter_->WriteFile(bloom_filter_filename_);
696 VLOG(1) << "SafeBrowsingDatabaseNew wrote bloom filter in " 689 VLOG(1) << "SafeBrowsingDatabaseNew wrote bloom filter in "
697 << (base::TimeTicks::Now() - before).InMilliseconds() << " ms"; 690 << (base::TimeTicks::Now() - before).InMilliseconds() << " ms";
698 691
699 if (!write_ok) { 692 if (!write_ok) {
700 UMA_HISTOGRAM_COUNTS("SB2.FilterWriteFail", 1); 693 UMA_HISTOGRAM_COUNTS("SB2.FilterWriteFail", 1);
701 RecordFailure(FAILURE_DATABASE_FILTER_WRITE); 694 RecordFailure(FAILURE_DATABASE_FILTER_WRITE);
702 } 695 }
703 } 696 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/chunk_range_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698