Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: components/safe_browsing_db/database_manager.h

Issue 1890753002: SafeBrowsing: Track and cancel API checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@osb-impl-2
Patch Set: Check callback Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/safe_browsing_db/database_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..97a82014c2a8608db413204214c92fd1d1e0c75c 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 API check with the given |client|.
+ CurrentApiChecks::iterator FindClientApiCheck(Client* client);
}; // class SafeBrowsingDatabaseManager
} // namespace safe_browsing
« no previous file with comments | « no previous file | components/safe_browsing_db/database_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698