| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 // Generate a |PrefixSet| file from |shared_prefixes_|, store it in | 106 // Generate a |PrefixSet| file from |shared_prefixes_|, store it in |
| 107 // a temporary file, and return the filename in |filenamep|. | 107 // a temporary file, and return the filename in |filenamep|. |
| 108 // Returns |true| on success. | 108 // Returns |true| on success. |
| 109 bool GetPrefixSetFile(base::FilePath* filenamep) { | 109 bool GetPrefixSetFile(base::FilePath* filenamep) { |
| 110 if (!temp_dir_.IsValid() && !temp_dir_.CreateUniqueTempDir()) | 110 if (!temp_dir_.IsValid() && !temp_dir_.CreateUniqueTempDir()) |
| 111 return false; | 111 return false; |
| 112 | 112 |
| 113 base::FilePath filename = temp_dir_.path().AppendASCII("PrefixSetTest"); | 113 base::FilePath filename = temp_dir_.GetPath().AppendASCII("PrefixSetTest"); |
| 114 | 114 |
| 115 PrefixSetBuilder builder(shared_prefixes_); | 115 PrefixSetBuilder builder(shared_prefixes_); |
| 116 if (!builder.GetPrefixSetNoHashes()->WriteFile(filename)) | 116 if (!builder.GetPrefixSetNoHashes()->WriteFile(filename)) |
| 117 return false; | 117 return false; |
| 118 | 118 |
| 119 *filenamep = filename; | 119 *filenamep = filename; |
| 120 return true; | 120 return true; |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Helper function to read the uint32_t value at |offset|, increment it | 123 // Helper function to read the uint32_t value at |offset|, increment it |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 const SBFullHash kHash2 = SBFullHashForString("www.evil.com/phishing.html"); | 725 const SBFullHash kHash2 = SBFullHashForString("www.evil.com/phishing.html"); |
| 726 | 726 |
| 727 EXPECT_TRUE(prefix_set->Exists(kHash1)); | 727 EXPECT_TRUE(prefix_set->Exists(kHash1)); |
| 728 EXPECT_TRUE(prefix_set->Exists(kHash2)); | 728 EXPECT_TRUE(prefix_set->Exists(kHash2)); |
| 729 EXPECT_FALSE(prefix_set->PrefixExists(kHash1.prefix)); | 729 EXPECT_FALSE(prefix_set->PrefixExists(kHash1.prefix)); |
| 730 EXPECT_FALSE(prefix_set->PrefixExists(kHash2.prefix)); | 730 EXPECT_FALSE(prefix_set->PrefixExists(kHash2.prefix)); |
| 731 } | 731 } |
| 732 #endif | 732 #endif |
| 733 | 733 |
| 734 } // namespace safe_browsing | 734 } // namespace safe_browsing |
| OLD | NEW |