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

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

Issue 5544008: Add a browser test for safebrowsing service.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rename functions Created 10 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
===================================================================
--- chrome/browser/safe_browsing/safe_browsing_database.h (revision 68365)
+++ chrome/browser/safe_browsing/safe_browsing_database.h (working copy)
@@ -24,7 +24,19 @@
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,
// as it doesn't contain user-specific data. This object is not
@@ -35,6 +47,13 @@
public:
// Factory method for obtaining a SafeBrowsingDatabase implementation.
static SafeBrowsingDatabase* Create();
+
+ // Makes the passed |factory| the factory used to instanciate
Scott Hess - ex-Googler 2010/12/07 21:22:57 "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 +131,12 @@
};
static void RecordFailure(FailureType failure_type);
+ private:
Scott Hess - ex-Googler 2010/12/07 21:22:57 Newline between RecordFailure() and private:.
+ // The factory used to instanciate a SafeBrowsingDatabase object.
Scott Hess - ex-Googler 2010/12/07 21:22:57 "instantiate".
+ // Useful for tests, so they can provide their own implementation of
+ // SafeBrowsingDatabase.
+ static SafeBrowsingDatabaseFactory* factory_;
+
};
class SafeBrowsingDatabaseNew : public SafeBrowsingDatabase {

Powered by Google App Engine
This is Rietveld 408576698