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_LOCAL_DATABASE_MANAGER_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
7 | 7 |
8 // A class that provides the interface between the SafeBrowsing protocol manager | 8 // A class that provides the interface between the SafeBrowsing protocol manager |
9 // and database that holds the downloaded updates. | 9 // and database that holds the downloaded updates. |
10 | 10 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // one of |full_hashes| and |urls| should be greater than 0. | 141 // one of |full_hashes| and |urls| should be greater than 0. |
142 const std::vector<GURL> urls; | 142 const std::vector<GURL> urls; |
143 | 143 |
144 // The full hashes that are being checked for being safe. The size of | 144 // The full hashes that are being checked for being safe. The size of |
145 // exactly one of |full_hashes| and |urls| should be greater than 0. | 145 // exactly one of |full_hashes| and |urls| should be greater than 0. |
146 std::vector<FullHash> full_hashes; | 146 std::vector<FullHash> full_hashes; |
147 | 147 |
148 // The metadata associated with the full hash of the severest match found | 148 // The metadata associated with the full hash of the severest match found |
149 // for that URL. | 149 // for that URL. |
150 ThreatMetadata url_metadata; | 150 ThreatMetadata url_metadata; |
| 151 |
| 152 // The full hash that matched for a blacklisted resource URL. Used only for |
| 153 // |CheckResourceUrl| case. |
| 154 FullHash matching_full_hash; |
151 }; | 155 }; |
152 | 156 |
153 typedef std::vector<std::unique_ptr<PendingCheck>> QueuedChecks; | 157 typedef std::vector<std::unique_ptr<PendingCheck>> QueuedChecks; |
154 | 158 |
155 // The stores/lists to always get full hashes for, regardless of which store | 159 // The stores/lists to always get full hashes for, regardless of which store |
156 // the hash prefix matched. | 160 // the hash prefix matched. |
157 StoresToCheck GetStoresForFullHashRequests() override; | 161 StoresToCheck GetStoresForFullHashRequests() override; |
158 | 162 |
159 private: | 163 private: |
160 friend class V4LocalDatabaseManagerTest; | 164 friend class V4LocalDatabaseManagerTest; |
(...skipping 16 matching lines...) Expand all Loading... |
177 | 181 |
178 // Called when the database has been updated and schedules the next update. | 182 // Called when the database has been updated and schedules the next update. |
179 void DatabaseUpdated(); | 183 void DatabaseUpdated(); |
180 | 184 |
181 // Identifies the prefixes and the store they matched in, for a given |check|. | 185 // Identifies the prefixes and the store they matched in, for a given |check|. |
182 // Returns true if one or more hash prefix matches are found; false otherwise. | 186 // Returns true if one or more hash prefix matches are found; false otherwise. |
183 bool GetPrefixMatches( | 187 bool GetPrefixMatches( |
184 const std::unique_ptr<PendingCheck>& check, | 188 const std::unique_ptr<PendingCheck>& check, |
185 FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes); | 189 FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes); |
186 | 190 |
187 // Finds the most severe |SBThreatType| and the corresponding |metadata| from | 191 // Finds the most severe |SBThreatType| and the corresponding |metadata|, and |
188 // |full_hash_infos|. | 192 // |matching_full_hash| from |full_hash_infos|. |
189 void GetSeverestThreatTypeAndMetadata( | 193 void GetSeverestThreatTypeAndMetadata( |
190 SBThreatType* result_threat_type, | 194 SBThreatType* result_threat_type, |
191 ThreatMetadata* metadata, | 195 ThreatMetadata* metadata, |
| 196 FullHash* matching_full_hash, |
192 const std::vector<FullHashInfo>& full_hash_infos); | 197 const std::vector<FullHashInfo>& full_hash_infos); |
193 | 198 |
194 // Returns the SBThreatType for a given ListIdentifier. | 199 // Returns the SBThreatType for a given ListIdentifier. |
195 SBThreatType GetSBThreatTypeForList(const ListIdentifier& list_id); | 200 SBThreatType GetSBThreatTypeForList(const ListIdentifier& list_id); |
196 | 201 |
197 // Queues the check for async response if the database isn't ready yet. | 202 // Queues the check for async response if the database isn't ready yet. |
198 // If the database is ready, checks the database for prefix matches and | 203 // If the database is ready, checks the database for prefix matches and |
199 // returns true immediately if there's no match. If a match is found, it | 204 // returns true immediately if there's no match. If a match is found, it |
200 // schedules a task to perform full hash check and returns false. | 205 // schedules a task to perform full hash check and returns false. |
201 bool HandleCheck(std::unique_ptr<PendingCheck> check); | 206 bool HandleCheck(std::unique_ptr<PendingCheck> check); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 293 |
289 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; | 294 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; |
290 | 295 |
291 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; | 296 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; |
292 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); | 297 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); |
293 }; // class V4LocalDatabaseManager | 298 }; // class V4LocalDatabaseManager |
294 | 299 |
295 } // namespace safe_browsing | 300 } // namespace safe_browsing |
296 | 301 |
297 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ | 302 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
OLD | NEW |