Chromium Code Reviews| Index: chrome/browser/conflicts/module_database_win.cc |
| diff --git a/chrome/browser/conflicts/module_database_win.cc b/chrome/browser/conflicts/module_database_win.cc |
| index 217b19975300d310656ff536be1e9617d348c23a..e0bcf773f36ceb147b559121ca46ec6007bba841 100644 |
| --- a/chrome/browser/conflicts/module_database_win.cc |
| +++ b/chrome/browser/conflicts/module_database_win.cc |
| @@ -8,6 +8,7 @@ |
| #include <tuple> |
| #include "base/bind.h" |
| +#include "chrome/browser/conflicts/module_database_observer_win.h" |
| namespace { |
| @@ -30,6 +31,7 @@ ModuleDatabase::ModuleDatabase( |
| // base::Unretained(). |
| module_inspector_(base::Bind(&ModuleDatabase::OnModuleInspected, |
| base::Unretained(this))), |
| + third_party_metrics_(this), |
| weak_ptr_factory_(this) {} |
| ModuleDatabase::~ModuleDatabase() { |
| @@ -152,6 +154,18 @@ void ModuleDatabase::OnProcessEnded(uint32_t process_id, |
| DeleteProcessInfo(process_id, creation_time); |
| } |
| +void ModuleDatabase::AddObserver(ModuleDatabaseObserver* observer) { |
| + observer_list_.AddObserver(observer); |
| + for (const auto& module : modules_) { |
| + if (module.second.inspection_result) |
| + observer->OnNewModuleFound(module.first, module.second); |
| + } |
| +} |
| + |
| +void ModuleDatabase::RemoveObserver(ModuleDatabaseObserver* observer) { |
| + observer_list_.RemoveObserver(observer); |
| +} |
| + |
| // static |
| uint32_t ModuleDatabase::ProcessTypeToBit(content::ProcessType process_type) { |
| uint32_t bit_index = |
| @@ -337,8 +351,13 @@ void ModuleDatabase::OnModuleInspected( |
| DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| auto it = modules_.find(module_key); |
| - if (it != modules_.end()) |
| - it->second.inspection_result = std::move(inspection_result); |
| + if (it == modules_.end()) |
| + return; |
| + |
| + it->second.inspection_result = std::move(inspection_result); |
| + |
| + for (auto& observer : observer_list_) |
| + observer.OnNewModuleFound(it->first, it->second); |
| } |
| // ModuleDatabase::ProcessInfoKey ---------------------------------------------- |
| @@ -357,8 +376,8 @@ bool ModuleDatabase::ProcessInfoKey::operator<( |
| const ProcessInfoKey& pik) const { |
| // The key consists of the pair of (process_id, creation_time). |
| // Use the std::tuple lexicographic comparison operator. |
| - return std::make_tuple(process_id, creation_time) < |
| - std::make_tuple(pik.process_id, pik.creation_time); |
| + return std::tie(process_id, creation_time) < |
|
chrisha
2017/05/02 21:28:25
I always forget about 'tie'....
|
| + std::tie(pik.process_id, pik.creation_time); |
| } |
| // ModuleDatabase::ProcessInfoData --------------------------------------------- |