| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/privacy_blacklist/blacklist_io.h" | 5 #include "chrome/browser/privacy_blacklist/blacklist_io.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 return cur + size <= end && std::equal(tag, tag + size - 1, cur); | 40 return cur + size <= end && std::equal(tag, tag + size - 1, cur); |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 // static | 45 // static |
| 46 bool BlacklistIO::ReadText(Blacklist* blacklist, | 46 bool BlacklistIO::ReadText(Blacklist* blacklist, |
| 47 const FilePath& path, | 47 const FilePath& path, |
| 48 std::string* error_string) { | 48 std::string* error_string) { |
| 49 DCHECK(blacklist); | 49 DCHECK(blacklist); |
| 50 DCHECK(error_string); |
| 50 | 51 |
| 51 // Memory map for efficient parsing. If the file cannot fit in available | 52 // Memory map for efficient parsing. If the file cannot fit in available |
| 52 // memory it would be the least of our worries. Typical blacklist files | 53 // memory it would be the least of our worries. Typical blacklist files |
| 53 // are less than 200K. | 54 // are less than 200K. |
| 54 file_util::MemoryMappedFile input; | 55 file_util::MemoryMappedFile input; |
| 55 if (!input.Initialize(path) || !input.data()) { | 56 if (!input.Initialize(path) || !input.data()) { |
| 56 *error_string = "File I/O error. Check path and permissions."; | 57 *error_string = "File I/O error. Check path and permissions."; |
| 57 return false; | 58 return false; |
| 58 } | 59 } |
| 59 | 60 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 i != entries.end(); ++i) { | 268 i != entries.end(); ++i) { |
| 268 if (!output.StoreEntry((*i)->pattern_, | 269 if (!output.StoreEntry((*i)->pattern_, |
| 269 (*i)->attributes_, | 270 (*i)->attributes_, |
| 270 (*i)->types_, | 271 (*i)->types_, |
| 271 index[(*i)->provider_])) { | 272 index[(*i)->provider_])) { |
| 272 return false; | 273 return false; |
| 273 } | 274 } |
| 274 } | 275 } |
| 275 return true; | 276 return true; |
| 276 } | 277 } |
| OLD | NEW |