OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ |
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <unordered_map> | 10 #include <unordered_map> |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 DatabaseUpdatedCallback db_updated_callback); | 124 DatabaseUpdatedCallback db_updated_callback); |
125 | 125 |
126 // Returns the current state of each of the stores being managed. | 126 // Returns the current state of each of the stores being managed. |
127 std::unique_ptr<StoreStateMap> GetStoreStateMap(); | 127 std::unique_ptr<StoreStateMap> GetStoreStateMap(); |
128 | 128 |
129 // Check if all the selected stores are available and populated. | 129 // Check if all the selected stores are available and populated. |
130 // Returns false if any of |stores_to_check| don't have valid data. | 130 // Returns false if any of |stores_to_check| don't have valid data. |
131 // A store may be unavailble if either it hasn't yet gotten a proper | 131 // A store may be unavailble if either it hasn't yet gotten a proper |
132 // full-update (just after install, or corrupted/missing file), or if it's | 132 // full-update (just after install, or corrupted/missing file), or if it's |
133 // not supported in this build (i.e. Chromium). | 133 // not supported in this build (i.e. Chromium). |
134 virtual bool AreStoresAvailable(const StoresToCheck& stores_to_check) const; | 134 virtual bool AreAllStoresAvailable( |
| 135 const StoresToCheck& stores_to_check) const; |
| 136 |
| 137 // Check if any of the stores are available and populated. |
| 138 // Returns false if all of |stores_to_check| don't have valid data. |
| 139 virtual bool AreAnyStoresAvailable( |
| 140 const StoresToCheck& stores_to_check) const; |
135 | 141 |
136 // Searches for a hash prefix matching the |full_hash| in stores in the | 142 // Searches for a hash prefix matching the |full_hash| in stores in the |
137 // database, filtered by |stores_to_check|, and returns the identifier of the | 143 // database, filtered by |stores_to_check|, and returns the identifier of the |
138 // store along with the matching hash prefix in |matched_hash_prefix_map|. | 144 // store along with the matching hash prefix in |matched_hash_prefix_map|. |
139 virtual void GetStoresMatchingFullHash( | 145 virtual void GetStoresMatchingFullHash( |
140 const FullHash& full_hash, | 146 const FullHash& full_hash, |
141 const StoresToCheck& stores_to_check, | 147 const StoresToCheck& stores_to_check, |
142 StoreAndHashPrefixes* matched_store_and_full_hashes); | 148 StoreAndHashPrefixes* matched_store_and_full_hashes); |
143 | 149 |
144 // Resets the stores in |stores_to_reset| to an empty state. This is done if | 150 // Resets the stores in |stores_to_reset| to an empty state. This is done if |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // This method updates the store_map_ to point to the new store, which causes | 208 // This method updates the store_map_ to point to the new store, which causes |
203 // the old store to get deleted. | 209 // the old store to get deleted. |
204 void UpdatedStoreReady(ListIdentifier identifier, | 210 void UpdatedStoreReady(ListIdentifier identifier, |
205 std::unique_ptr<V4Store> store); | 211 std::unique_ptr<V4Store> store); |
206 | 212 |
207 // See |VerifyChecksum|. | 213 // See |VerifyChecksum|. |
208 void VerifyChecksumOnTaskRunner( | 214 void VerifyChecksumOnTaskRunner( |
209 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner, | 215 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner, |
210 DatabaseReadyForUpdatesCallback db_ready_for_updates_callback); | 216 DatabaseReadyForUpdatesCallback db_ready_for_updates_callback); |
211 | 217 |
| 218 bool IsStoreAvailable(const ListIdentifier& identifier) const; |
| 219 |
212 const scoped_refptr<base::SequencedTaskRunner> db_task_runner_; | 220 const scoped_refptr<base::SequencedTaskRunner> db_task_runner_; |
213 | 221 |
214 DatabaseUpdatedCallback db_updated_callback_; | 222 DatabaseUpdatedCallback db_updated_callback_; |
215 | 223 |
216 // The number of stores for which the update request is pending. When this | 224 // The number of stores for which the update request is pending. When this |
217 // goes down to 0, that indicates that the database has updated all the stores | 225 // goes down to 0, that indicates that the database has updated all the stores |
218 // that needed updating and is ready for the next update. It should only be | 226 // that needed updating and is ready for the next update. It should only be |
219 // accessed on the IO thread. | 227 // accessed on the IO thread. |
220 int pending_store_updates_; | 228 int pending_store_updates_; |
221 | 229 |
222 // Only meant to be dereferenced and invalidated on the IO thread and hence | 230 // Only meant to be dereferenced and invalidated on the IO thread and hence |
223 // named. For details, see the comment at the top of weak_ptr.h | 231 // named. For details, see the comment at the top of weak_ptr.h |
224 base::WeakPtrFactory<V4Database> weak_factory_on_io_; | 232 base::WeakPtrFactory<V4Database> weak_factory_on_io_; |
225 | 233 |
226 DISALLOW_COPY_AND_ASSIGN(V4Database); | 234 DISALLOW_COPY_AND_ASSIGN(V4Database); |
227 }; | 235 }; |
228 | 236 |
229 } // namespace safe_browsing | 237 } // namespace safe_browsing |
230 | 238 |
231 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ | 239 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ |
OLD | NEW |