OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WIN_ENUMERATE_MODULES_MODEL_H_ | 5 #ifndef CHROME_BROWSER_WIN_ENUMERATE_MODULES_MODEL_H_ |
6 #define CHROME_BROWSER_WIN_ENUMERATE_MODULES_MODEL_H_ | 6 #define CHROME_BROWSER_WIN_ENUMERATE_MODULES_MODEL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 ~ModuleEnumerator(); | 132 ~ModuleEnumerator(); |
133 | 133 |
134 // Start scanning the loaded module list (if a scan is not already in | 134 // Start scanning the loaded module list (if a scan is not already in |
135 // progress). This function does not block while reading the module list and | 135 // progress). This function does not block while reading the module list and |
136 // will notify when done by calling the DoneScanning method of |observer_|. | 136 // will notify when done by calling the DoneScanning method of |observer_|. |
137 void ScanNow(ModulesVector* list); | 137 void ScanNow(ModulesVector* list); |
138 | 138 |
139 private: | 139 private: |
140 FRIEND_TEST_ALL_PREFIXES(EnumerateModulesTest, CollapsePath); | 140 FRIEND_TEST_ALL_PREFIXES(EnumerateModulesTest, CollapsePath); |
141 | 141 |
142 // This function does the actual file scanning work on the FILE thread. It | 142 // This function does the actual file scanning work in the blocking pool. It |
143 // enumerates all loaded modules in the process and other modules of interest, | 143 // enumerates all loaded modules in the process and other modules of interest, |
144 // such as the registered Winsock LSP modules and stores them in | 144 // such as the registered Winsock LSP modules and stores them in |
145 // |enumerated_modules_|. It then normalizes the module info and matches them | 145 // |enumerated_modules_|. It then normalizes the module info and matches them |
146 // against a blacklist of known bad modules. Finally, notifies the observer | 146 // against a blacklist of known bad modules. Finally, notifies the observer |
147 // that the enumeration is complete by invoking DoneScanning. | 147 // that the enumeration is complete by invoking DoneScanning. |
148 void ScanImpl(); | 148 void ScanImpl(); |
149 | 149 |
150 // Enumerate all modules loaded into the Chrome process. | 150 // Enumerate all modules loaded into the Chrome process. |
151 void EnumerateLoadedModules(); | 151 void EnumerateLoadedModules(); |
152 | 152 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // both currently loaded modules (called DLLs on Windows) and modules 'of | 213 // both currently loaded modules (called DLLs on Windows) and modules 'of |
214 // interest', such as WinSock LSP modules. This class also marks each module | 214 // interest', such as WinSock LSP modules. This class also marks each module |
215 // as benign or suspected bad or outright bad, using a supplied blacklist that | 215 // as benign or suspected bad or outright bad, using a supplied blacklist that |
216 // is currently hard-coded. | 216 // is currently hard-coded. |
217 // | 217 // |
218 // To use this class, grab the singleton pointer and call ScanNow(). | 218 // To use this class, grab the singleton pointer and call ScanNow(). |
219 // Then wait to get notified through MODULE_LIST_ENUMERATED when the list is | 219 // Then wait to get notified through MODULE_LIST_ENUMERATED when the list is |
220 // ready. | 220 // ready. |
221 // | 221 // |
222 // The member functions of this class may only be used from the UI thread. The | 222 // The member functions of this class may only be used from the UI thread. The |
223 // bulk of the work is actually performed on the FILE thread. | 223 // bulk of the work is actually performed in the blocking pool with |
| 224 // CONTINUE_ON_SHUTDOWN semantics, as the WinCrypt functions can effectively |
| 225 // block arbitrarily during shutdown. |
224 // | 226 // |
225 // TODO(chrisha): If this logic is ever extended to other platforms, then make | 227 // TODO(chrisha): If this logic is ever extended to other platforms, then make |
226 // this file generic for all platforms, and remove the precompiler logic in | 228 // this file generic for all platforms, and remove the precompiler logic in |
227 // app_menu_icon_controller.*. | 229 // app_menu_icon_controller.*. |
228 class EnumerateModulesModel { | 230 class EnumerateModulesModel { |
229 public: | 231 public: |
230 // UMA histogram constants. | 232 // UMA histogram constants. |
231 enum UmaModuleConflictHistogramOptions { | 233 enum UmaModuleConflictHistogramOptions { |
232 ACTION_BUBBLE_SHOWN = 0, | 234 ACTION_BUBBLE_SHOWN = 0, |
233 ACTION_BUBBLE_LEARN_MORE, | 235 ACTION_BUBBLE_LEARN_MORE, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 EnumerateModulesModel(); | 302 EnumerateModulesModel(); |
301 ~EnumerateModulesModel(); | 303 ~EnumerateModulesModel(); |
302 | 304 |
303 // Called on the UI thread when the helper class is done scanning. The | 305 // Called on the UI thread when the helper class is done scanning. The |
304 // ModuleEnumerator that calls this must not do any work after causing this | 306 // ModuleEnumerator that calls this must not do any work after causing this |
305 // function to be called, as the EnumerateModulesModel may delete the | 307 // function to be called, as the EnumerateModulesModel may delete the |
306 // ModuleEnumerator. | 308 // ModuleEnumerator. |
307 void DoneScanning(); | 309 void DoneScanning(); |
308 | 310 |
309 // The vector containing all the modules enumerated. Will be normalized and | 311 // The vector containing all the modules enumerated. Will be normalized and |
310 // any bad modules will be marked. Written to on the FILE thread by the | 312 // any bad modules will be marked. Written to from the blocking pool by the |
311 // |module_enumerator_|, read from on the UI thread by this class. | 313 // |module_enumerator_|, read from on the UI thread by this class. |
312 ModuleEnumerator::ModulesVector enumerated_modules_; | 314 ModuleEnumerator::ModulesVector enumerated_modules_; |
313 | 315 |
314 // The object responsible for enumerating the modules on the FILE thread. | 316 // The object responsible for enumerating the modules in the blocking pool. |
315 // Only used from the UI thread. This ends up internally doing its work on the | 317 // Only used from the UI thread. This ends up internally doing its work in the |
316 // FILE thread. | 318 // blocking pool. |
317 std::unique_ptr<ModuleEnumerator> module_enumerator_; | 319 std::unique_ptr<ModuleEnumerator> module_enumerator_; |
318 | 320 |
319 // Whether the conflict notification has been acknowledged by the user. Only | 321 // Whether the conflict notification has been acknowledged by the user. Only |
320 // modified on the UI thread. | 322 // modified on the UI thread. |
321 bool conflict_notification_acknowledged_; | 323 bool conflict_notification_acknowledged_; |
322 | 324 |
323 // The number of confirmed bad modules (not including suspected bad ones) | 325 // The number of confirmed bad modules (not including suspected bad ones) |
324 // found during last scan. Only modified on the UI thread. | 326 // found during last scan. Only modified on the UI thread. |
325 int confirmed_bad_modules_detected_; | 327 int confirmed_bad_modules_detected_; |
326 | 328 |
327 // The number of bad modules the user needs to be aggressively notified about. | 329 // The number of bad modules the user needs to be aggressively notified about. |
328 // Only modified on the UI thread. | 330 // Only modified on the UI thread. |
329 int modules_to_notify_about_; | 331 int modules_to_notify_about_; |
330 | 332 |
331 // The number of suspected bad modules (not including confirmed bad ones) | 333 // The number of suspected bad modules (not including confirmed bad ones) |
332 // found during last scan. Only modified on the UI thread. | 334 // found during last scan. Only modified on the UI thread. |
333 int suspected_bad_modules_detected_; | 335 int suspected_bad_modules_detected_; |
334 | 336 |
335 base::ObserverList<Observer> observers_; | 337 base::ObserverList<Observer> observers_; |
336 | 338 |
337 DISALLOW_COPY_AND_ASSIGN(EnumerateModulesModel); | 339 DISALLOW_COPY_AND_ASSIGN(EnumerateModulesModel); |
338 }; | 340 }; |
339 | 341 |
340 #endif // CHROME_BROWSER_WIN_ENUMERATE_MODULES_MODEL_H_ | 342 #endif // CHROME_BROWSER_WIN_ENUMERATE_MODULES_MODEL_H_ |
OLD | NEW |