Chromium Code Reviews| 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 62809a79882deeffc0b8956e3b489f155edacdd2..14d0991e9bcc4f006cbcb5e2252ec17051d576a5 100644 |
| --- a/components/safe_browsing_db/database_manager.h |
| +++ b/components/safe_browsing_db/database_manager.h |
| @@ -154,15 +154,19 @@ class SafeBrowsingDatabaseManager |
| // are handled separately. To cancel an API check use CancelApiCheck. |
| virtual void CancelCheck(Client* client) = 0; |
| - // TODO(kcarattini): Add a CancelApiCheck method. |
| + // Called on the IO thread to cancel a pending API check if the result is no |
| + // longer needed. Returns true if the client was found and the check |
| + // successfully cancelled. |
| + virtual bool CancelApiCheck(Client* client); |
| // Called on the IO thread to check if the given url has blacklisted APIs. |
| - // "client" is called asynchronously with the result when it is ready. |
| - // This method has the same implementation for both the local and remote |
| - // database managers since it pings Safe Browsing servers directly without |
| - // accessing the database at all. Returns true if we can synchronously |
| - // determine that the url is safe. Otherwise it returns false, and "client" is |
| - // called asynchronously with the result when it is ready. |
| + // "client" is called asynchronously with the result when it is ready. Callers |
| + // should wait for results before calling this method a second time with the |
| + // same client. This method has the same implementation for both the local and |
| + // remote database managers since it pings Safe Browsing servers directly |
| + // without accessing the database at all. Returns true if we can |
| + // synchronously determine that the url is safe. Otherwise it returns false, |
| + // and "client" is called asynchronously with the result when it is ready. |
| virtual bool CheckApiBlacklistUrl(const GURL& url, Client* client); |
| // Called to initialize objects that are used on the io_thread, such as the |
| @@ -211,17 +215,29 @@ class SafeBrowsingDatabaseManager |
| HandleGetHashesWithApisResultsNoMatch); |
| FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| HandleGetHashesWithApisResultsMatches); |
| + FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| + CancelApiCheck); |
| + |
| + typedef std::set<SafeBrowsingApiCheck*> CurrentApiChecks; |
| + |
| + // In-progress checks. This set owns the SafeBrowsingApiCheck pointers and is |
| + // responsible for deleting them when removing from the set. |
| + CurrentApiChecks api_checks_; |
| // Called on the IO thread wheh the SafeBrowsingProtocolManager has received |
| // the full hash and api results for prefixes of the |url| argument in |
| // CheckApiBlacklistUrl. |
| virtual void HandleGetHashesWithApisResults( |
| - std::shared_ptr<SafeBrowsingApiCheck> check, |
| + SafeBrowsingApiCheck* check, |
| const std::vector<SBFullHashResult>& full_hash_results, |
| const base::TimeDelta& negative_cache_duration); |
| // Created and destroyed via StartOnIOThread/StopOnIOThread. |
| V4GetHashProtocolManager* v4_get_hash_protocol_manager_; |
| + |
| + private: |
| + // Returns an iterator to the pending check with the given |client|. |
| + CurrentApiChecks::iterator FindClientCheck(Client* client); |
|
Nathan Parker
2016/04/19 18:05:19
This should be FindApiClientCheck, ya?
kcarattini
2016/04/20 01:55:53
Yeah. Changed to FindClientApiCheck.
|
| }; // class SafeBrowsingDatabaseManager |
| } // namespace safe_browsing |