Chromium Code Reviews| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 SBThreatType* result_threat_type, | 191 SBThreatType* result_threat_type, |
| 188 ThreatMetadata* metadata, | 192 ThreatMetadata* metadata, |
| 189 const std::vector<FullHashInfo>& full_hash_infos); | 193 const std::vector<FullHashInfo>& full_hash_infos); |
| 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. If |
| 198 bool HandleCheck(std::unique_ptr<PendingCheck> check); | 202 // |synchronous_response| is false, an asynchronous full hash request to |
| 203 // fetch full hashes for the matching hash prefixes is sent to the | |
| 204 // SafeBrowsing service. | |
| 205 bool HandleCheck(std::unique_ptr<PendingCheck> check, | |
| 206 const bool synchronous_response = false); | |
|
Nathan Parker
2016/11/14 21:09:37
I think this arg is confusing... I've commented in
vakh (use Gerrit instead)
2016/11/15 00:36:21
Done.
| |
| 207 | |
| 208 static bool IPAddressToEncodedIPV6(const std::string& ip_address, | |
| 209 std::string* encoded_ip); | |
| 199 | 210 |
| 200 // Called when the |v4_get_hash_protocol_manager_| has the full hash response | 211 // 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 | 212 // available for the URL that we requested. It determines the severest |
| 202 // threat type and responds to the |client| with that information. | 213 // threat type and responds to the |client| with that information. |
| 203 void OnFullHashResponse(std::unique_ptr<PendingCheck> pending_check, | 214 void OnFullHashResponse(std::unique_ptr<PendingCheck> pending_check, |
| 204 const std::vector<FullHashInfo>& full_hash_infos); | 215 const std::vector<FullHashInfo>& full_hash_infos); |
| 205 | 216 |
| 206 // Performs the full hash checking of the URL in |check|. | 217 // Performs the full hash checking of the URL in |check|. |
| 207 virtual void PerformFullHashCheck(std::unique_ptr<PendingCheck> check, | 218 virtual void PerformFullHashCheck(std::unique_ptr<PendingCheck> check, |
| 208 const FullHashToStoreAndHashPrefixesMap& | 219 const FullHashToStoreAndHashPrefixesMap& |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 | 281 |
| 271 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; | 282 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; |
| 272 | 283 |
| 273 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; | 284 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; |
| 274 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); | 285 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); |
| 275 }; // class V4LocalDatabaseManager | 286 }; // class V4LocalDatabaseManager |
| 276 | 287 |
| 277 } // namespace safe_browsing | 288 } // namespace safe_browsing |
| 278 | 289 |
| 279 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ | 290 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
| OLD | NEW |