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

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: 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
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 c2359f67b4b8c865d1a40f0af8930c3022ebfd4b..e21297a1b5d8b0dbe067a3870f16cecf33025a45 100644
--- a/components/safe_browsing_db/database_manager.h
+++ b/components/safe_browsing_db/database_manager.h
@@ -174,10 +174,14 @@ 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.
+ // "client" is called asynchronously with the result when it is ready. Clients
+ // should wait for results before calling this method a second time.
Nathan Parker 2016/04/15 23:27:35 We probably want a dcheck to enforce that.
kcarattini 2016/04/18 03:00:09 Done.
// 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
@@ -218,6 +222,13 @@ class SafeBrowsingDatabaseManager
HandleGetHashesWithApisResultsNoMatch);
FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest,
HandleGetHashesWithApisResultsMatches);
+ FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest,
+ CancelApiCheck);
+
+ typedef std::set<std::shared_ptr<SafeBrowsingApiCheck> > CurrentApiChecks;
+
+ // In-progress checks.
+ CurrentApiChecks api_checks_;
// Created and destroyed via StartOnIOThread/StopOnIOThread.
V4GetHashProtocolManager* v4_get_hash_protocol_manager_;
« no previous file with comments | « no previous file | components/safe_browsing_db/database_manager.cc » ('j') | components/safe_browsing_db/database_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698