| Index: components/safe_browsing_db/database_manager.h
|
| diff --git a/components/safe_browsing_db/database_manager.h b/components/safe_browsing_db/database_manager.h
|
| index 2b55d3dc5a25679307fa65d2b2d9ec00c036fc34..fa3ea88a3448d2e99203d00b91905a2968caa80b 100644
|
| --- a/components/safe_browsing_db/database_manager.h
|
| +++ b/components/safe_browsing_db/database_manager.h
|
| @@ -180,12 +180,16 @@ class SafeBrowsingDatabaseManager
|
| SafeBrowsingApiCheck(const GURL& url,
|
| const std::vector<SBPrefix>& prefixes,
|
| const std::vector<SBFullHash>& full_hashes,
|
| + const std::vector<SBFullHashResult>& cached_results,
|
| Client* client);
|
| ~SafeBrowsingApiCheck();
|
|
|
| const GURL& url() {return url_;}
|
| const std::vector<SBPrefix>& prefixes() {return prefixes_;}
|
| const std::vector<SBFullHash>& full_hashes() {return full_hashes_;}
|
| + const std::vector<SBFullHashResult>& cached_results() {
|
| + return cached_results_;
|
| + }
|
| SafeBrowsingDatabaseManager::Client* client() {return client_;}
|
|
|
| private:
|
| @@ -197,6 +201,9 @@ class SafeBrowsingDatabaseManager
|
| // Full hashes for this check.
|
| std::vector<SBFullHash> full_hashes_;
|
|
|
| + // Cached results for this check.
|
| + std::vector<SBFullHashResult> cached_results_;
|
| +
|
| // Not owned.
|
| SafeBrowsingDatabaseManager::Client* client_;
|
|
|
| @@ -223,9 +230,15 @@ class SafeBrowsingDatabaseManager
|
| ResultsAreCached);
|
| FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest,
|
| ResultsAreNotCachedOnNull);
|
| + FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest,
|
| + GetCachedResults);
|
| + FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest,
|
| + CachedResultsMerged);
|
|
|
| typedef std::set<SafeBrowsingApiCheck*> ApiCheckSet;
|
| typedef std::map<SBPrefix, SBCachedFullHashResult> PrefixToFullHashResultsMap;
|
| + typedef std::map<SBThreatType, PrefixToFullHashResultsMap>
|
| + ThreatTypeToResultsMap;
|
|
|
| // Called on the IO thread wheh the SafeBrowsingProtocolManager has received
|
| // the full hash and api results for prefixes of the |url| argument in
|
| @@ -235,12 +248,29 @@ class SafeBrowsingDatabaseManager
|
| const std::vector<SBFullHashResult>& full_hash_results,
|
| const base::Time& negative_cache_expire);
|
|
|
| + // Looks up the cached results for |threat_type|. Fills |prefixes| with the
|
| + // prefixes that need a request. Fills |cached_results| with the cached
|
| + // results.
|
| + void GetFullHashCachedResults(const SBThreatType& threat_type,
|
| + const std::vector<SBFullHash>& full_hashes,
|
| + base::Time now,
|
| + std::vector<SBPrefix>* prefixes,
|
| + std::vector<SBFullHashResult>* cached_results);
|
| +
|
| + // Populates |md| with permission api metadata from all results that have a
|
| + // match in |full_hashes|.
|
| + void PopulateApiMetadataResult(const std::vector<SBFullHashResult>& results,
|
| + const std::vector<SBFullHash>& full_hashes,
|
| + ThreatMetadata* md);
|
| +
|
| // In-progress checks. This set owns the SafeBrowsingApiCheck pointers and is
|
| // responsible for deleting them when removing from the set.
|
| ApiCheckSet api_checks_;
|
|
|
| // A cache of V4 full hash results for api checks.
|
| - PrefixToFullHashResultsMap api_cache_;
|
| + // TODO(kcarattini): Look into moving all caching logic to
|
| + // V4GetHashProtocolManager.
|
| + ThreatTypeToResultsMap v4_full_hash_cache_;
|
|
|
| // Created and destroyed via StartOnIOThread/StopOnIOThread.
|
| V4GetHashProtocolManager* v4_get_hash_protocol_manager_;
|
|
|