Chromium Code Reviews| Index: chrome/browser/safe_browsing/safe_browsing_database.cc |
| =================================================================== |
| --- chrome/browser/safe_browsing/safe_browsing_database.cc (revision 68365) |
| +++ chrome/browser/safe_browsing/safe_browsing_database.cc (working copy) |
| @@ -135,6 +135,22 @@ |
| } // namespace |
| +// The default SafeBrowsingDatabaseFactory. |
| +class SafeBrowsingDatabaseFactoryImpl : public SafeBrowsingDatabaseFactory { |
| + public: |
| + virtual SafeBrowsingDatabase* CreateSafeBrowsingDatabase() { |
| + return new SafeBrowsingDatabaseNew(new SafeBrowsingStoreFile); |
| + } |
| + |
| + SafeBrowsingDatabaseFactoryImpl() { } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseFactoryImpl); |
| +}; |
| + |
| +// static |
| +SafeBrowsingDatabaseFactory* SafeBrowsingDatabase::factory_ = NULL; |
| + |
| // Factory method. |
| // TODO(shess): Milestone-7 is converting from SQLite-based |
| // SafeBrowsingDatabaseBloom to the new file format with |
| @@ -142,7 +158,9 @@ |
| // consider reversing, circle back and lift SafeBrowsingDatabaseNew up |
| // to SafeBrowsingDatabase and get rid of the abstract class. |
| SafeBrowsingDatabase* SafeBrowsingDatabase::Create() { |
| - return new SafeBrowsingDatabaseNew(new SafeBrowsingStoreFile); |
| + if (!factory_) |
| + factory_ = new SafeBrowsingDatabaseFactoryImpl(); |
|
Scott Hess - ex-Googler
2010/12/07 21:22:57
Again, if thread-safe make assertions that it is h
lzheng
2010/12/08 01:57:32
This is not thread safe. Caller has to call this f
|
| + return factory_->CreateSafeBrowsingDatabase(); |
| } |
| SafeBrowsingDatabase::~SafeBrowsingDatabase() { |