| 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_store.h" | 5 #include "chrome/browser/privacy_blacklist/blacklist_store.h" |
| 6 | 6 |
| 7 #include <cstdio> | 7 #include <cstdio> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 const char cookie[] = "GCPBL100"; | 16 const char cookie[] = "GCPBL100"; |
| 17 | 17 |
| 18 const size_t kMaxBlockedTypes = 256; | 18 const size_t kMaxBlockedTypes = 256; |
| 19 const size_t kMaxStringSize = 8192; | 19 const size_t kMaxStringSize = 8192; |
| 20 | 20 |
| 21 } | 21 } // namespace |
| 22 | 22 |
| 23 bool BlacklistStoreOutput::WriteUInt(uint32 i) { | 23 bool BlacklistStoreOutput::WriteUInt(uint32 i) { |
| 24 return fwrite(reinterpret_cast<char*>(&i), 1, sizeof(uint32), file_) == | 24 return fwrite(reinterpret_cast<char*>(&i), 1, sizeof(uint32), file_) == |
| 25 sizeof(uint32); | 25 sizeof(uint32); |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool BlacklistStoreOutput::WriteString(const std::string& s) { | 28 bool BlacklistStoreOutput::WriteString(const std::string& s) { |
| 29 uint32 n = s.size(); | 29 uint32 n = s.size(); |
| 30 return WriteUInt(n) && fwrite(s.c_str(), 1, n, file_) == n; | 30 return WriteUInt(n) && fwrite(s.c_str(), 1, n, file_) == n; |
| 31 } | 31 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 while (n--) { | 132 while (n--) { |
| 133 std::string type = ReadString(); | 133 std::string type = ReadString(); |
| 134 if (type.empty()) | 134 if (type.empty()) |
| 135 return false; | 135 return false; |
| 136 types->push_back(type); | 136 types->push_back(type); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 *provider = ReadUInt(); | 139 *provider = ReadUInt(); |
| 140 return *provider != std::numeric_limits<uint32>::max(); | 140 return *provider != std::numeric_limits<uint32>::max(); |
| 141 } | 141 } |
| OLD | NEW |