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

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

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixes comments by eroman Created 9 years, 8 months 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
OLDNEW
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 // This test performs a series false positive checks using a list of URLs 5 // This test performs a series false positive checks using a list of URLs
6 // against a known set of SafeBrowsing data. 6 // against a known set of SafeBrowsing data.
7 // 7 //
8 // It uses a normal SafeBrowsing database to create a bloom filter where it 8 // It uses a normal SafeBrowsing database to create a bloom filter where it
9 // looks up all the URLs in the url file. A URL that has a prefix found in the 9 // looks up all the URLs in the url file. A URL that has a prefix found in the
10 // bloom filter and found in the database is considered a hit: a valid lookup 10 // bloom filter and found in the database is considered a hit: a valid lookup
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include <vector> 57 #include <vector>
58 58
59 #include "app/sql/statement.h" 59 #include "app/sql/statement.h"
60 #include "base/command_line.h" 60 #include "base/command_line.h"
61 #include "base/file_path.h" 61 #include "base/file_path.h"
62 #include "base/file_util.h" 62 #include "base/file_util.h"
63 #include "base/logging.h" 63 #include "base/logging.h"
64 #include "base/memory/scoped_ptr.h" 64 #include "base/memory/scoped_ptr.h"
65 #include "base/path_service.h" 65 #include "base/path_service.h"
66 #include "base/rand_util.h" 66 #include "base/rand_util.h"
67 #include "base/sha2.h"
68 #include "base/string_number_conversions.h" 67 #include "base/string_number_conversions.h"
69 #include "base/string_util.h" 68 #include "base/string_util.h"
70 #include "base/time.h" 69 #include "base/time.h"
70 #include "crypto/sha2.h"
71 #include "chrome/browser/safe_browsing/bloom_filter.h" 71 #include "chrome/browser/safe_browsing/bloom_filter.h"
72 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 72 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
73 #include "chrome/common/chrome_paths.h" 73 #include "chrome/common/chrome_paths.h"
74 #include "googleurl/src/gurl.h" 74 #include "googleurl/src/gurl.h"
75 #include "testing/gtest/include/gtest/gtest.h" 75 #include "testing/gtest/include/gtest/gtest.h"
76 76
77 using base::Time; 77 using base::Time;
78 using base::TimeDelta; 78 using base::TimeDelta;
79 79
80 namespace { 80 namespace {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } else { 169 } else {
170 safe_browsing_util::GenerateHostsToCheck(url_check, &hosts); 170 safe_browsing_util::GenerateHostsToCheck(url_check, &hosts);
171 } 171 }
172 172
173 std::vector<std::string> paths; 173 std::vector<std::string> paths;
174 safe_browsing_util::GeneratePathsToCheck(url_check, &paths); 174 safe_browsing_util::GeneratePathsToCheck(url_check, &paths);
175 175
176 for (size_t i = 0; i < hosts.size(); ++i) { 176 for (size_t i = 0; i < hosts.size(); ++i) {
177 for (size_t j = 0; j < paths.size(); ++j) { 177 for (size_t j = 0; j < paths.size(); ++j) {
178 SBPrefix prefix; 178 SBPrefix prefix;
179 base::SHA256HashString(hosts[i] + paths[j], &prefix, sizeof(prefix)); 179 crypto::SHA256HashString(hosts[i] + paths[j], &prefix, sizeof(prefix));
180 if (bloom_filter->Exists(prefix)) 180 if (bloom_filter->Exists(prefix))
181 prefixes->push_back(prefix); 181 prefixes->push_back(prefix);
182 } 182 }
183 } 183 }
184 184
185 return hosts.size() * paths.size(); 185 return hosts.size() * paths.size();
186 } 186 }
187 187
188 // Binary search of sorted prefixes. 188 // Binary search of sorted prefixes.
189 bool IsPrefixInDatabase(SBPrefix prefix, 189 bool IsPrefixInDatabase(SBPrefix prefix,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 354
355 std::cout << "Time results for checks: " << num_checks 355 std::cout << "Time results for checks: " << num_checks
356 << ", prefixes: " << prefix_list.size() 356 << ", prefixes: " << prefix_list.size()
357 << ", populate time (ms): " << populate.InMilliseconds() 357 << ", populate time (ms): " << populate.InMilliseconds()
358 << ", check time (ms): " << check.InMilliseconds() 358 << ", check time (ms): " << check.InMilliseconds()
359 << ", hits: " << hits 359 << ", hits: " << hits
360 << ", per-populate (us): " << time_per_insert 360 << ", per-populate (us): " << time_per_insert
361 << ", per-check (us): " << time_per_check 361 << ", per-check (us): " << time_per_check
362 << std::endl; 362 << std::endl;
363 } 363 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/encryptor_mac.mm ('k') | chrome/browser/safe_browsing/safe_browsing_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698