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 5fa427ff29e086d420d0277507eeaf69d03a537a..762865f6dc50cb6e8ac2e628656129aae758a9a6 100644 |
| --- a/components/safe_browsing_db/database_manager.h |
| +++ b/components/safe_browsing_db/database_manager.h |
| @@ -14,6 +14,8 @@ |
| #include <string> |
| #include <vector> |
| +#include "base/gtest_prod_util.h" |
| +#include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| #include "components/safe_browsing_db/hit_report.h" |
| #include "components/safe_browsing_db/util.h" |
| @@ -63,6 +65,21 @@ class SafeBrowsingDatabaseManager |
| const std::string& threat_hash) {} |
| }; |
| + // Bundled client info for an API abuse hash prefix check. |
| + struct SafeBrowsingApiCheck { |
|
Nathan Parker
2016/04/11 16:28:50
This could be a class, since you've got public and
kcarattini
2016/04/12 01:27:02
Done.
|
| + public: |
| + SafeBrowsingApiCheck(const GURL& url, |
| + const std::vector<SBFullHash>& full_hashes, |
| + Client* client); |
| + ~SafeBrowsingApiCheck(); |
| + |
| + private: |
| + GURL url; |
| + std::vector<SBFullHash> full_hashes; |
| + SafeBrowsingDatabaseManager::Client* client; |
|
Nathan Parker
2016/04/11 16:28:50
// Not owned
kcarattini
2016/04/12 01:27:02
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(SafeBrowsingApiCheck); |
| + }; |
| // Returns true if URL-checking is supported on this build+device. |
| // If false, calls to CheckBrowseUrl may dcheck-fail. |
| @@ -155,8 +172,17 @@ class SafeBrowsingDatabaseManager |
| // "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. |
| - virtual void CheckApiBlacklistUrl(const GURL& url, Client* client); |
| + // 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 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(SafeBrowsingApiCheck* check, |
| + const std::vector<SBFullHashResult>& full_hash_results, |
| + const base::TimeDelta& negative_cache_duration); |
| // Called to initialize objects that are used on the io_thread, such as the |
| // v4 protocol manager. This may be called multiple times during the life of |
| @@ -175,7 +201,10 @@ class SafeBrowsingDatabaseManager |
| friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>; |
| - // Created and destroyed via StartonIOThread/StopOnIOThread. |
| + FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| + CheckApiBlacklistUrlPrefixes); |
| + |
| + // Created and destroyed via StartOnIOThread/StopOnIOThread. |
| V4GetHashProtocolManager* v4_get_hash_protocol_manager_; |
| }; // class SafeBrowsingDatabaseManager |