Chromium Code Reviews| Index: components/safe_browsing_db/v4_local_database_manager.h |
| diff --git a/components/safe_browsing_db/v4_local_database_manager.h b/components/safe_browsing_db/v4_local_database_manager.h |
| index f4996474ba227c32959506c422b1162374792ab3..b32745fc80b86b69c5559a9f12342eabf846beb3 100644 |
| --- a/components/safe_browsing_db/v4_local_database_manager.h |
| +++ b/components/safe_browsing_db/v4_local_database_manager.h |
| @@ -83,6 +83,10 @@ class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { |
| // unsafe from the following perspectives: Malware, Phishing, UwS. |
| CHECK_BROWSE_URL = 0, |
| + // This represents the case when we're trying to determine if any of the |
| + // URLs in a vector of URLs is unsafe for downloading binaries. |
| + CHECK_DOWNLOAD_URLS = 1, |
| + |
| // This should always be the last value. |
| CHECK_MAX |
|
Nathan Parker
2016/10/26 00:45:45
Nit: you don't really need a max if you're going t
vakh (use Gerrit instead)
2016/10/26 19:53:22
Done.
|
| }; |
| @@ -90,12 +94,13 @@ class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { |
| // The information we need to process a URL safety reputation request and |
| // respond to the SafeBrowsing client that asked for it. |
| // TODO(vakh): In its current form, it only includes information for |
| - // |CheckBrowseUrl| method. Extend it to serve other methods on |client|. |
| + // |CheckBrowseUrl| and |CheckDownloadUrl| methods. Extend it to serve other |
| + // methods on |client|. |
| struct PendingCheck { |
| PendingCheck(Client* client, |
| ClientCallbackType client_callback_type, |
| const StoresToCheck& stores_to_check, |
| - const GURL& url); |
| + const std::vector<GURL>& urls); |
| ~PendingCheck(); |
| @@ -104,7 +109,7 @@ class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { |
| // Determines which funtion from the |client| needs to be called once we |
| // know whether the URL in |url| is safe or unsafe. |
| - ClientCallbackType client_callback_type; |
| + const ClientCallbackType client_callback_type; |
| // The threat verdict for the URL being checked. |
| SBThreatType result_threat_type; |
| @@ -115,10 +120,10 @@ class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { |
| base::TimeTicks full_hash_check_start; |
| // The SafeBrowsing lists to check hash prefixes in. |
| - StoresToCheck stores_to_check; |
| + const StoresToCheck stores_to_check; |
| // The URL that is being checked for being unsafe. |
|
Nathan Parker
2016/10/26 00:45:45
URL(s) that are...
vakh (use Gerrit instead)
2016/10/26 19:53:21
Done.
|
| - GURL url; |
| + const std::vector<GURL> urls; |
| // The metadata associated with the full hash of the severest match found |
| // for that URL. |
| @@ -138,7 +143,7 @@ class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { |
| // The set of clients awaiting a full hash response. It is used for tracking |
| // which clients have cancelled their outstanding request. |
| - typedef std::unordered_set<Client*> PendingClients; |
| + typedef std::unordered_set<const Client*> PendingClients; |
| // Called when all the stores managed by the database have been read from |
| // disk after startup and the database is ready for checking resource |
| @@ -170,6 +175,12 @@ class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { |
| // Returns the SBThreatType for a given ListIdentifier. |
| SBThreatType GetSBThreatTypeForList(const ListIdentifier& list_id); |
| + // Queues the check for async response if the database isn't ready yet. |
| + // If the database is ready, checks the database for prefix matches and |
| + // returns true immediately if there's no match. If a match is found, it |
| + // schedules a task to perform full hash check and returns false. |
| + bool HandleCheck(std::unique_ptr<PendingCheck> check); |
| + |
| // Called when the |v4_get_hash_protocol_manager_| has the full hash response |
| // available for the URL that we requested. It determines the severest |
| // threat type and responds to the |client| with that information. |