diff options
author | lzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 23:46:19 +0000 |
---|---|---|
committer | lzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 23:46:19 +0000 |
commit | bef12f40253f48b56a69e59746f52214727080de (patch) | |
tree | 224a0fcc0d6e7ec72c5b28ff2c381e0be729aed0 /chrome/browser/safe_browsing/safe_browsing_database.h | |
parent | c35a309c6faaaf6002fb8bb553a69e759c5ad1d3 (diff) | |
download | chromium_src-bef12f40253f48b56a69e59746f52214727080de.zip chromium_src-bef12f40253f48b56a69e59746f52214727080de.tar.gz chromium_src-bef12f40253f48b56a69e59746f52214727080de.tar.bz2 |
Add a browser test for safebrowsing service.
BUG=none
TEST=safe_browsing_service_browsertest
Review URL: http://codereview.chromium.org/5544008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69072 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing/safe_browsing_database.h')
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_database.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.h b/chrome/browser/safe_browsing/safe_browsing_database.h index 9ca53f7..6dbd6e7 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database.h +++ b/chrome/browser/safe_browsing/safe_browsing_database.h @@ -24,6 +24,18 @@ namespace base { class BloomFilter; class GURL; class MessageLoop; +class SafeBrowsingDatabase; + +// Factory for creating SafeBrowsingDatabase. Tests implement this factory +// to create fake Databases for testing. +class SafeBrowsingDatabaseFactory { + public: + SafeBrowsingDatabaseFactory() { } + virtual ~SafeBrowsingDatabaseFactory() { } + virtual SafeBrowsingDatabase* CreateSafeBrowsingDatabase() = 0; + private: + DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseFactory); +}; // Encapsulates the database that stores information about phishing // and malware sites. There is one on-disk database for all profiles, @@ -34,7 +46,15 @@ class MessageLoop; class SafeBrowsingDatabase { public: // Factory method for obtaining a SafeBrowsingDatabase implementation. + // It is not thread safe. static SafeBrowsingDatabase* Create(); + + // Makes the passed |factory| the factory used to instantiate + // a SafeBrowsingDatabase. This is used for tests. + static void RegisterFactory(SafeBrowsingDatabaseFactory* factory) { + factory_ = factory; + } + virtual ~SafeBrowsingDatabase(); // Initializes the database with the given filename. @@ -112,6 +132,12 @@ class SafeBrowsingDatabase { }; static void RecordFailure(FailureType failure_type); + + private: + // The factory used to instantiate a SafeBrowsingDatabase object. + // Useful for tests, so they can provide their own implementation of + // SafeBrowsingDatabase. + static SafeBrowsingDatabaseFactory* factory_; }; class SafeBrowsingDatabaseNew : public SafeBrowsingDatabase { |