OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // GetAddChunkId(), GetAddPrefix() and GetFullHash() are exposed so | 37 // GetAddChunkId(), GetAddPrefix() and GetFullHash() are exposed so |
38 // that these items can be generically compared with each other by | 38 // that these items can be generically compared with each other by |
39 // SBAddPrefixLess() and SBAddPrefixHashLess(). | 39 // SBAddPrefixLess() and SBAddPrefixHashLess(). |
40 | 40 |
41 struct SBAddPrefix { | 41 struct SBAddPrefix { |
42 int32 chunk_id; | 42 int32 chunk_id; |
43 SBPrefix prefix; | 43 SBPrefix prefix; |
44 | 44 |
45 SBAddPrefix(int32 id, SBPrefix p) : chunk_id(id), prefix(p) {} | 45 SBAddPrefix(int32 id, SBPrefix p) : chunk_id(id), prefix(p) {} |
| 46 SBAddPrefix() : chunk_id(), prefix() {} |
46 | 47 |
47 int32 GetAddChunkId() const { return chunk_id; } | 48 int32 GetAddChunkId() const { return chunk_id; } |
48 SBPrefix GetAddPrefix() const { return prefix; } | 49 SBPrefix GetAddPrefix() const { return prefix; } |
49 }; | 50 }; |
50 | 51 |
51 struct SBSubPrefix { | 52 struct SBSubPrefix { |
52 int32 chunk_id; | 53 int32 chunk_id; |
53 int32 add_chunk_id; | 54 int32 add_chunk_id; |
54 SBPrefix add_prefix; | 55 SBPrefix add_prefix; |
55 | 56 |
56 SBSubPrefix(int32 id, int32 add_id, int prefix) | 57 SBSubPrefix(int32 id, int32 add_id, int prefix) |
57 : chunk_id(id), add_chunk_id(add_id), add_prefix(prefix) {} | 58 : chunk_id(id), add_chunk_id(add_id), add_prefix(prefix) {} |
| 59 SBSubPrefix() : chunk_id(), add_chunk_id(), add_prefix() {} |
58 | 60 |
59 int32 GetAddChunkId() const { return add_chunk_id; } | 61 int32 GetAddChunkId() const { return add_chunk_id; } |
60 SBPrefix GetAddPrefix() const { return add_prefix; } | 62 SBPrefix GetAddPrefix() const { return add_prefix; } |
61 }; | 63 }; |
62 | 64 |
63 struct SBAddFullHash { | 65 struct SBAddFullHash { |
64 int32 chunk_id; | 66 int32 chunk_id; |
65 int32 received; | 67 int32 received; |
66 SBFullHash full_hash; | 68 SBFullHash full_hash; |
67 | 69 |
68 SBAddFullHash(int32 id, base::Time r, SBFullHash h) | 70 SBAddFullHash(int32 id, base::Time r, SBFullHash h) |
69 : chunk_id(id), | 71 : chunk_id(id), |
70 received(static_cast<int32>(r.ToTimeT())), | 72 received(static_cast<int32>(r.ToTimeT())), |
71 full_hash(h) { | 73 full_hash(h) { |
72 } | 74 } |
73 | 75 |
74 // Provided for ReadAddHashes() implementations, which already have | 76 // Provided for ReadAddHashes() implementations, which already have |
75 // an int32 for the time. | 77 // an int32 for the time. |
76 SBAddFullHash(int32 id, int32 r, SBFullHash h) | 78 SBAddFullHash(int32 id, int32 r, SBFullHash h) |
77 : chunk_id(id), received(r), full_hash(h) {} | 79 : chunk_id(id), received(r), full_hash(h) {} |
78 | 80 |
| 81 SBAddFullHash() : chunk_id(), received(), full_hash() {} |
| 82 |
79 int32 GetAddChunkId() const { return chunk_id; } | 83 int32 GetAddChunkId() const { return chunk_id; } |
80 SBPrefix GetAddPrefix() const { return full_hash.prefix; } | 84 SBPrefix GetAddPrefix() const { return full_hash.prefix; } |
81 }; | 85 }; |
82 | 86 |
83 struct SBSubFullHash { | 87 struct SBSubFullHash { |
84 int32 chunk_id; | 88 int32 chunk_id; |
85 int32 add_chunk_id; | 89 int32 add_chunk_id; |
86 SBFullHash full_hash; | 90 SBFullHash full_hash; |
87 | 91 |
88 SBSubFullHash(int32 id, int32 add_id, SBFullHash h) | 92 SBSubFullHash(int32 id, int32 add_id, SBFullHash h) |
89 : chunk_id(id), add_chunk_id(add_id), full_hash(h) {} | 93 : chunk_id(id), add_chunk_id(add_id), full_hash(h) {} |
| 94 SBSubFullHash() : chunk_id(), add_chunk_id(), full_hash() {} |
90 | 95 |
91 int32 GetAddChunkId() const { return add_chunk_id; } | 96 int32 GetAddChunkId() const { return add_chunk_id; } |
92 SBPrefix GetAddPrefix() const { return full_hash.prefix; } | 97 SBPrefix GetAddPrefix() const { return full_hash.prefix; } |
93 }; | 98 }; |
94 | 99 |
95 // Determine less-than based on add chunk and prefix. | 100 // Determine less-than based on add chunk and prefix. |
96 template <class T, class U> | 101 template <class T, class U> |
97 bool SBAddPrefixLess(const T& a, const U& b) { | 102 bool SBAddPrefixLess(const T& a, const U& b) { |
98 if (a.GetAddChunkId() != b.GetAddChunkId()) | 103 if (a.GetAddChunkId() != b.GetAddChunkId()) |
99 return a.GetAddChunkId() < b.GetAddChunkId(); | 104 return a.GetAddChunkId() < b.GetAddChunkId(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 214 |
210 // Cancel the update in process and remove any temporary disk | 215 // Cancel the update in process and remove any temporary disk |
211 // storage, leaving the original data unmodified. | 216 // storage, leaving the original data unmodified. |
212 virtual bool CancelUpdate() = 0; | 217 virtual bool CancelUpdate() = 0; |
213 | 218 |
214 private: | 219 private: |
215 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStore); | 220 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStore); |
216 }; | 221 }; |
217 | 222 |
218 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ | 223 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ |
OLD | NEW |