OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/safe_browsing_db/prefix_set.h" | 5 #include "components/safe_browsing_db/prefix_set.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 base::FilePath ref_path = TestFilePath(); | 192 base::FilePath ref_path = TestFilePath(); |
193 ref_path = ref_path.AppendASCII(kRefname); | 193 ref_path = ref_path.AppendASCII(kRefname); |
194 | 194 |
195 base::ScopedFILE file(base::OpenFile(ref_path, "r")); | 195 base::ScopedFILE file(base::OpenFile(ref_path, "r")); |
196 if (!file.get()) | 196 if (!file.get()) |
197 return false; | 197 return false; |
198 char buf[1024]; | 198 char buf[1024]; |
199 while (fgets(buf, sizeof(buf), file.get())) { | 199 while (fgets(buf, sizeof(buf), file.get())) { |
200 std::string trimmed; | 200 std::string trimmed; |
201 if (base::TRIM_TRAILING != | 201 if (base::TRIM_TRAILING != |
202 base::TrimWhitespace(buf, base::TRIM_ALL, &trimmed)) | 202 base::TrimWhitespaceASCII(buf, base::TRIM_ALL, &trimmed)) |
203 return false; | 203 return false; |
204 unsigned prefix; | 204 unsigned prefix; |
205 if (!base::StringToUint(trimmed, &prefix)) | 205 if (!base::StringToUint(trimmed, &prefix)) |
206 return false; | 206 return false; |
207 prefixes->push_back(prefix); | 207 prefixes->push_back(prefix); |
208 } | 208 } |
209 return true; | 209 return true; |
210 } | 210 } |
211 | 211 |
212 // Tests should not modify this shared resource. | 212 // Tests should not modify this shared resource. |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 const SBFullHash kHash2 = SBFullHashForString("www.evil.com/phishing.html"); | 719 const SBFullHash kHash2 = SBFullHashForString("www.evil.com/phishing.html"); |
720 | 720 |
721 EXPECT_TRUE(prefix_set->Exists(kHash1)); | 721 EXPECT_TRUE(prefix_set->Exists(kHash1)); |
722 EXPECT_TRUE(prefix_set->Exists(kHash2)); | 722 EXPECT_TRUE(prefix_set->Exists(kHash2)); |
723 EXPECT_FALSE(prefix_set->PrefixExists(kHash1.prefix)); | 723 EXPECT_FALSE(prefix_set->PrefixExists(kHash1.prefix)); |
724 EXPECT_FALSE(prefix_set->PrefixExists(kHash2.prefix)); | 724 EXPECT_FALSE(prefix_set->PrefixExists(kHash2.prefix)); |
725 } | 725 } |
726 #endif | 726 #endif |
727 | 727 |
728 } // namespace safe_browsing | 728 } // namespace safe_browsing |
OLD | NEW |