Chromium Code Reviews| Index: components/safe_browsing_db/v4_database.cc |
| diff --git a/components/safe_browsing_db/v4_database.cc b/components/safe_browsing_db/v4_database.cc |
| index 334a262ccc5b7262e838a4797c879fff3148460d..f5b6929d2bd5d14134c40b74eeeb6ae71a53f38a 100644 |
| --- a/components/safe_browsing_db/v4_database.cc |
| +++ b/components/safe_browsing_db/v4_database.cc |
| @@ -23,24 +23,24 @@ V4StoreFactory* V4Database::factory_ = NULL; |
| void V4Database::Create( |
| const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
| const base::FilePath& base_path, |
| - const StoreIdAndFileNames& store_id_file_names, |
| + const ListInfos& list_infos, |
| NewDatabaseReadyCallback new_db_callback) { |
| DCHECK(base_path.IsAbsolute()); |
| - DCHECK(!store_id_file_names.empty()); |
| + DCHECK(!list_infos.empty()); |
| const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner = |
| base::MessageLoop::current()->task_runner(); |
| db_task_runner->PostTask( |
| FROM_HERE, |
| base::Bind(&V4Database::CreateOnTaskRunner, db_task_runner, base_path, |
| - store_id_file_names, callback_task_runner, new_db_callback)); |
| + list_infos, callback_task_runner, new_db_callback)); |
| } |
| // static |
| void V4Database::CreateOnTaskRunner( |
| const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
| const base::FilePath& base_path, |
| - const StoreIdAndFileNames& store_id_file_names, |
| + const ListInfos& list_infos, |
| const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner, |
| NewDatabaseReadyCallback new_db_callback) { |
| DCHECK(db_task_runner->RunsTasksOnCurrentThread()); |
| @@ -55,9 +55,14 @@ void V4Database::CreateOnTaskRunner( |
| } |
| std::unique_ptr<StoreMap> store_map = base::MakeUnique<StoreMap>(); |
| - for (const auto& it : store_id_file_names) { |
| - const base::FilePath store_path = base_path.AppendASCII(it.filename); |
| - (*store_map)[it.list_id].reset( |
| + for (const auto& it : list_infos) { |
| + if (!it.fetch_updates()) { |
| + // This list doesn't need to be fetched or stored on disk. |
| + continue; |
| + } |
| + |
| + const base::FilePath store_path = base_path.AppendASCII(it.filename()); |
| + (*store_map)[it.list_id()].reset( |
| factory_->CreateV4Store(db_task_runner, store_path)); |
| } |
| std::unique_ptr<V4Database> v4_database( |
| @@ -184,12 +189,18 @@ void V4Database::GetStoresMatchingFullHash( |
| } |
| } |
| -StoreIdAndFileName::StoreIdAndFileName(const ListIdentifier& list_id, |
| - const std::string& filename) |
| - : list_id(list_id), filename(filename) { |
| - DCHECK(!filename.empty()); |
| +ListInfo::ListInfo(const ListIdentifier& list_id, |
| + const std::string& filename, |
| + const SBThreatType sb_threat_type, |
| + const bool fetch_updates) |
| + : list_id_(list_id), |
| + filename_(filename), |
| + sb_threat_type_(sb_threat_type), |
| + fetch_updates_(fetch_updates) { |
| + DCHECK(!fetch_updates_ || !filename_.empty()); |
|
Nathan Parker
2016/09/22 18:35:13
DCHECK(fetch_update_ != filename_.empty())
vakh (use Gerrit instead)
2016/09/22 20:33:41
I find the current form easier to understand.
It i
Nathan Parker
2016/09/22 22:00:59
Sure, either way is fine. (My line has a tighter
vakh (use Gerrit instead)
2016/09/22 22:04:23
My check is intentional since that condition is a
|
| + DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_); |
| } |
| -StoreIdAndFileName::~StoreIdAndFileName() {} |
| +ListInfo::~ListInfo() {} |
| } // namespace safe_browsing |