| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_INSTALL_VERIFICATION_WIN_MODULE_LIST_H_ | 5 #ifndef CHROME_BROWSER_INSTALL_VERIFICATION_WIN_MODULE_LIST_H_ |
| 6 #define CHROME_BROWSER_INSTALL_VERIFICATION_WIN_MODULE_LIST_H_ | 6 #define CHROME_BROWSER_INSTALL_VERIFICATION_WIN_MODULE_LIST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <Windows.h> | 9 #include <Windows.h> |
| 10 | 10 |
| 11 #include <set> | 11 #include <set> |
| 12 #include <tuple> |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 16 | 17 |
| 17 struct ModuleInfo; | 18 struct ModuleInfo; |
| 18 | 19 |
| 19 // Manages a list of HMODULEs, releasing them upon destruction. | 20 // Manages a list of HMODULEs, releasing them upon destruction. |
| 20 class ModuleList { | 21 class ModuleList { |
| 21 public: | 22 public: |
| 22 ~ModuleList(); | 23 ~ModuleList(); |
| 23 | 24 |
| 24 // Attempts to AddRef each HMODULE in |snapshot|. If a module was unloaded | 25 // Attempts to AddRef each HMODULE in |snapshot|. If a module was unloaded |
| 25 // since |snapshot| was taken it will be silently dropped. Successfully | 26 // since |snapshot| was taken it will be silently dropped. Successfully |
| 26 // AddRef'd HMODULEs will be inserted in the returned ModuleList. | 27 // AddRef'd HMODULEs will be inserted in the returned ModuleList. |
| 27 // | 28 // |
| 28 // This method _always_ returns a valid ModuleList instance. | 29 // This method _always_ returns a valid ModuleList instance. |
| 29 static scoped_ptr<ModuleList> FromLoadedModuleSnapshot( | 30 static scoped_ptr<ModuleList> FromLoadedModuleSnapshot( |
| 30 const std::vector<HMODULE>& snapshot); | 31 const std::vector<HMODULE>& snapshot); |
| 31 | 32 |
| 32 // Retrieves name and address information for the module list. | 33 // Retrieves name and address information for the module list. |
| 33 void GetModuleInfoSet(std::set<ModuleInfo>* module_info_set); | 34 void GetModuleInfoSet(std::set<ModuleInfo>* module_info_set); |
| 34 | 35 |
| 35 size_t size() const { | 36 size_t size() const { |
| 36 return modules_.size(); | 37 return modules_.size(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 HMODULE operator[](size_t index) const { | 40 HMODULE operator[](size_t index) const { |
| 40 return modules_[index]; | 41 return std::get<HMODULE>(modules_[index]); |
| 41 } | 42 } |
| 42 | 43 |
| 43 private: | 44 private: |
| 44 ModuleList(); | 45 ModuleList(); |
| 45 | 46 |
| 46 std::vector<HMODULE> modules_; | 47 std::vector<std::tuple<HMODULE, std::wstring>> modules_; |
| 47 | 48 |
| 48 DISALLOW_COPY_AND_ASSIGN(ModuleList); | 49 DISALLOW_COPY_AND_ASSIGN(ModuleList); |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 #endif // CHROME_BROWSER_INSTALL_VERIFICATION_WIN_MODULE_LIST_H_ | 52 #endif // CHROME_BROWSER_INSTALL_VERIFICATION_WIN_MODULE_LIST_H_ |
| OLD | NEW |