| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 CHECK_BROWSE_URL = 0, | 88 CHECK_BROWSE_URL = 0, |
| 89 | 89 |
| 90 // This represents the case when we're trying to determine if any of the | 90 // This represents the case when we're trying to determine if any of the |
| 91 // URLs in a vector of URLs is unsafe for downloading binaries. | 91 // URLs in a vector of URLs is unsafe for downloading binaries. |
| 92 CHECK_DOWNLOAD_URLS = 1, | 92 CHECK_DOWNLOAD_URLS = 1, |
| 93 | 93 |
| 94 // This represents the case when we're trying to determine if a URL is an | 94 // This represents the case when we're trying to determine if a URL is an |
| 95 // unsafe resource. | 95 // unsafe resource. |
| 96 CHECK_RESOURCE_URL = 2, | 96 CHECK_RESOURCE_URL = 2, |
| 97 | 97 |
| 98 // This represents the case where we're trying to determine if a Chrome | 98 // This represents the case when we're trying to determine if a Chrome |
| 99 // extension is a unsafe. | 99 // extension is a unsafe. |
| 100 CHECK_EXTENSION_IDS = 3 | 100 CHECK_EXTENSION_IDS = 3, |
| 101 |
| 102 // This represents the case when we're trying to determing if an IP address |
| 103 // is unsafe due to hosting Malware. |
| 104 CHECK_MALWARE_IP = 4, |
| 101 }; | 105 }; |
| 102 | 106 |
| 103 // The information we need to process a URL safety reputation request and | 107 // The information we need to process a URL safety reputation request and |
| 104 // respond to the SafeBrowsing client that asked for it. | 108 // respond to the SafeBrowsing client that asked for it. |
| 105 struct PendingCheck { | 109 struct PendingCheck { |
| 106 PendingCheck(Client* client, | 110 PendingCheck(Client* client, |
| 107 ClientCallbackType client_callback_type, | 111 ClientCallbackType client_callback_type, |
| 108 const StoresToCheck& stores_to_check, | 112 const StoresToCheck& stores_to_check, |
| 109 const std::vector<GURL>& urls); | 113 const std::vector<GURL>& urls); |
| 110 | 114 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 194 |
| 191 // Returns the SBThreatType for a given ListIdentifier. | 195 // Returns the SBThreatType for a given ListIdentifier. |
| 192 SBThreatType GetSBThreatTypeForList(const ListIdentifier& list_id); | 196 SBThreatType GetSBThreatTypeForList(const ListIdentifier& list_id); |
| 193 | 197 |
| 194 // Queues the check for async response if the database isn't ready yet. | 198 // Queues the check for async response if the database isn't ready yet. |
| 195 // If the database is ready, checks the database for prefix matches and | 199 // If the database is ready, checks the database for prefix matches and |
| 196 // returns true immediately if there's no match. If a match is found, it | 200 // returns true immediately if there's no match. If a match is found, it |
| 197 // schedules a task to perform full hash check and returns false. | 201 // schedules a task to perform full hash check and returns false. |
| 198 bool HandleCheck(std::unique_ptr<PendingCheck> check); | 202 bool HandleCheck(std::unique_ptr<PendingCheck> check); |
| 199 | 203 |
| 204 // Checks the database for prefix matches. Returns true if the database isn't |
| 205 // ready or if there's no match; false otherwise. This is used for lists that |
| 206 // have full hash information in the database. |
| 207 bool HandleCheckSynchronously(std::unique_ptr<PendingCheck> check); |
| 208 |
| 200 // Called when the |v4_get_hash_protocol_manager_| has the full hash response | 209 // Called when the |v4_get_hash_protocol_manager_| has the full hash response |
| 201 // available for the URL that we requested. It determines the severest | 210 // available for the URL that we requested. It determines the severest |
| 202 // threat type and responds to the |client| with that information. | 211 // threat type and responds to the |client| with that information. |
| 203 void OnFullHashResponse(std::unique_ptr<PendingCheck> pending_check, | 212 void OnFullHashResponse(std::unique_ptr<PendingCheck> pending_check, |
| 204 const std::vector<FullHashInfo>& full_hash_infos); | 213 const std::vector<FullHashInfo>& full_hash_infos); |
| 205 | 214 |
| 206 // Performs the full hash checking of the URL in |check|. | 215 // Performs the full hash checking of the URL in |check|. |
| 207 virtual void PerformFullHashCheck(std::unique_ptr<PendingCheck> check, | 216 virtual void PerformFullHashCheck(std::unique_ptr<PendingCheck> check, |
| 208 const FullHashToStoreAndHashPrefixesMap& | 217 const FullHashToStoreAndHashPrefixesMap& |
| 209 full_hash_to_store_and_hash_prefixes); | 218 full_hash_to_store_and_hash_prefixes); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 279 |
| 271 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; | 280 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; |
| 272 | 281 |
| 273 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; | 282 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; |
| 274 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); | 283 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); |
| 275 }; // class V4LocalDatabaseManager | 284 }; // class V4LocalDatabaseManager |
| 276 | 285 |
| 277 } // namespace safe_browsing | 286 } // namespace safe_browsing |
| 278 | 287 |
| 279 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ | 288 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
| OLD | NEW |