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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_database.h

Issue 744183002: More explicit thread checking in SafeBrowsingDatabase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a3_deadcode
Patch Set: crbug.com/338486 forces thread-checks to be disabled in ~SafeBrowsingStoreFile() Created 6 years 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: chrome/browser/safe_browsing/safe_browsing_database.h
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.h b/chrome/browser/safe_browsing/safe_browsing_database.h
index 27112712071b7d447efb899c27d28297065fdb3b..37dcf8f06f9ce0f8ce197e6512c2e64dad285981 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database.h
+++ b/chrome/browser/safe_browsing/safe_browsing_database.h
@@ -16,13 +16,10 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
+#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "chrome/browser/safe_browsing/safe_browsing_store.h"
-namespace base {
-class MessageLoop;
-}
-
namespace safe_browsing {
class PrefixSet;
}
@@ -126,17 +123,17 @@ class SafeBrowsingDatabase {
// Returns false if |url| is not on the client-side phishing detection
// whitelist. Otherwise, this function returns true. Note: the whitelist
- // only contains full-length hashes so we don't return any prefix hit.
- // This function should only be called from the IO thread.
+ // only contains full-length hashes so we don't return any prefix hit. This
+ // function is safe to call from any thread.
virtual bool ContainsCsdWhitelistedUrl(const GURL& url) = 0;
// The download whitelist is used for two purposes: a white-domain list of
// sites that are considered to host only harmless binaries as well as a
// whitelist of arbitrary strings such as hashed certificate authorities that
- // are considered to be trusted. The two methods below let you lookup
- // the whitelist either for a URL or an arbitrary string. These methods will
- // return false if no match is found and true otherwise.
- // This function could ONLY be accessed from the IO thread.
+ // are considered to be trusted. The two methods below let you lookup the
+ // whitelist either for a URL or an arbitrary string. These methods will
+ // return false if no match is found and true otherwise. This function is safe
+ // to call from any thread.
virtual bool ContainsDownloadWhitelistedUrl(const GURL& url) = 0;
virtual bool ContainsDownloadWhitelistedString(const std::string& str) = 0;
@@ -149,10 +146,11 @@ class SafeBrowsingDatabase {
std::vector<SBPrefix>* prefix_hits) = 0;
// Returns false unless the hash of |url| is on the side-effect free
- // whitelist.
+ // whitelist. This function is safe to call from any thread.
virtual bool ContainsSideEffectFreeWhitelistUrl(const GURL& url) = 0;
// Returns true iff the given IP is currently on the csd malware IP blacklist.
+ // This function is safe to call from any thread.
virtual bool ContainsMalwareIP(const std::string& ip_address) = 0;
// A database transaction should look like:
@@ -185,18 +183,19 @@ class SafeBrowsingDatabase {
// Store the results of a GetHash response. In the case of empty results, we
// cache the prefixes until the next update so that we don't have to issue
- // further GetHash requests we know will be empty.
+ // further GetHash requests we know will be empty. This function is safe to
+ // call from any thread.
virtual void CacheHashResults(
const std::vector<SBPrefix>& prefixes,
const std::vector<SBFullHashResult>& full_hits,
const base::TimeDelta& cache_lifetime) = 0;
// Returns true if the malware IP blacklisting killswitch URL is present
- // in the csd whitelist.
+ // in the csd whitelist. This function is safe to call from any thread.
virtual bool IsMalwareIPMatchKillSwitchOn() = 0;
// Returns true if the whitelist killswitch URL is present in the csd
- // whitelist.
+ // whitelist. This function is safe to call from any thread.
virtual bool IsCsdWhitelistKillSwitchOn() = 0;
// The name of the bloom-filter file for the given database file.
@@ -472,8 +471,8 @@ class SafeBrowsingDatabaseNew : public SafeBrowsingDatabase {
void UpdateIpBlacklistStore();
// Used to verify that various calls are made from the thread the
- // object was created on.
- base::MessageLoop* creation_loop_;
+ // object was created on (i.e., the safe_browsing_thread).
+ base::ThreadChecker thread_checker_;
// The base filename passed to Init(), used to generate the store and prefix
// set filenames used to store data on disk.
@@ -506,9 +505,8 @@ class SafeBrowsingDatabaseNew : public SafeBrowsingDatabase {
// For unwanted software list.
scoped_ptr<SafeBrowsingStore> unwanted_software_store_;
- // Lock for protecting access to variables that may be used on the IO thread.
- // This includes |(browse|unwanted_software)_prefix_set_|,
- // |prefix_gethash_cache_|, |csd_whitelist_|.
+ // Lock for protecting access to variables that may be used on any threads.
+ // This includes all SBWhitelist's, PrefixSet's, and caches.
base::Lock lookup_lock_;
SBWhitelist csd_whitelist_;

Powered by Google App Engine
This is Rietveld 408576698