Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: chrome/browser/enumerate_modules_model_win.h

Issue 6098004: Integrate about:conflicts with --diagnostics... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 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_ENUMERATE_MODULES_MODEL_WIN_H_ 5 #ifndef CHROME_BROWSER_ENUMERATE_MODULES_MODEL_WIN_H_
6 #define CHROME_BROWSER_ENUMERATE_MODULES_MODEL_WIN_H_ 6 #define CHROME_BROWSER_ENUMERATE_MODULES_MODEL_WIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 static void NormalizeModule(Module* module); 112 static void NormalizeModule(Module* module);
113 113
114 // A static function that checks whether |module| has been |blacklisted|. 114 // A static function that checks whether |module| has been |blacklisted|.
115 static ModuleStatus Match(const Module& module, 115 static ModuleStatus Match(const Module& module,
116 const BlacklistEntry& blacklisted); 116 const BlacklistEntry& blacklisted);
117 117
118 explicit ModuleEnumerator(EnumerateModulesModel* observer); 118 explicit ModuleEnumerator(EnumerateModulesModel* observer);
119 ~ModuleEnumerator(); 119 ~ModuleEnumerator();
120 120
121 // Start scanning the loaded module list (if a scan is not already in 121 // Start scanning the loaded module list (if a scan is not already in
122 // progress). This function does not block while reading the module list, but 122 // progress). This function does not block while reading the module list
123 // will notify when done through the MODULE_LIST_ENUMERATED notification. 123 // (unless we are in limited_mode, see below), and will notify when done
124 // through the MODULE_LIST_ENUMERATED notification.
124 // The process will also send MODULE_INCOMPATIBILITY_DETECTED if an 125 // The process will also send MODULE_INCOMPATIBILITY_DETECTED if an
125 // incompatible module was detected. 126 // incompatible module was detected.
126 void ScanNow(ModulesVector* list); 127 // When in |limited_mode|, this function will not leverage the File thread
128 // to run asynchronously and will therefore block until scanning is done
129 // (and will also not send out any notifications).
130 void ScanNow(ModulesVector* list, bool limited_mode);
127 131
128 private: 132 private:
129 FRIEND_TEST_ALL_PREFIXES(EnumerateModulesTest, CollapsePath); 133 FRIEND_TEST_ALL_PREFIXES(EnumerateModulesTest, CollapsePath);
130 134
131 // The (currently) hard coded blacklist of known bad modules. 135 // The (currently) hard coded blacklist of known bad modules.
132 static const BlacklistEntry kModuleBlacklist[]; 136 static const BlacklistEntry kModuleBlacklist[];
133 137
134 // This function does the actual file scanning work on the FILE thread. It 138 // This function does the actual file scanning work on the FILE thread (or
135 // enumerates all loaded modules in the process and other modules of 139 // block the main thread when in limited_mode). It enumerates all loaded
136 // interest, such as the registered Winsock LSP modules and stores them in 140 // modules in the process and other modules of interest, such as the
137 // |enumerated_modules_|. It then normalizes the module info and matches 141 // registered Winsock LSP modules and stores them in |enumerated_modules_|.
138 // them against a blacklist of known bad modules. Finally, it calls 142 // It then normalizes the module info and matches them against a blacklist
139 // ReportBack to let the observer know we are done. 143 // of known bad modules. Finally, it calls ReportBack to let the observer
140 void ScanOnFileThread(); 144 // know we are done.
145 void ScanImpl();
141 146
142 // Enumerate all modules loaded into the Chrome process. 147 // Enumerate all modules loaded into the Chrome process.
143 void EnumerateLoadedModules(); 148 void EnumerateLoadedModules();
144 149
145 // Enumerate all registered Windows shell extensions. 150 // Enumerate all registered Windows shell extensions.
146 void EnumerateShellExtensions(); 151 void EnumerateShellExtensions();
147 152
148 // Enumerate all registered Winsock LSP modules. 153 // Enumerate all registered Winsock LSP modules.
149 void EnumerateWinsockModules(); 154 void EnumerateWinsockModules();
150 155
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // where people keep there files, c:\windows vs. d:\windows, etc. 198 // where people keep there files, c:\windows vs. d:\windows, etc.
194 PathMapping path_mapping_; 199 PathMapping path_mapping_;
195 200
196 // The vector containing all the enumerated modules (loaded and modules of 201 // The vector containing all the enumerated modules (loaded and modules of
197 // interest). 202 // interest).
198 ModulesVector* enumerated_modules_; 203 ModulesVector* enumerated_modules_;
199 204
200 // The observer, who needs to be notified when we are done. 205 // The observer, who needs to be notified when we are done.
201 EnumerateModulesModel* observer_; 206 EnumerateModulesModel* observer_;
202 207
208 // See limited_mode below.
209 bool limited_mode_;
210
203 // The thread that we need to call back on to report that we are done. 211 // The thread that we need to call back on to report that we are done.
204 BrowserThread::ID callback_thread_id_; 212 BrowserThread::ID callback_thread_id_;
205 213
206 DISALLOW_COPY_AND_ASSIGN(ModuleEnumerator); 214 DISALLOW_COPY_AND_ASSIGN(ModuleEnumerator);
207 }; 215 };
208 216
209 // This is a singleton class that enumerates all modules loaded into Chrome, 217 // This is a singleton class that enumerates all modules loaded into Chrome,
210 // both currently loaded modules (called DLLs on Windows) and modules 'of 218 // both currently loaded modules (called DLLs on Windows) and modules 'of
211 // interest', such as WinSock LSP modules. This class also marks each module 219 // interest', such as WinSock LSP modules. This class also marks each module
212 // as benign or suspected bad or outright bad, using a supplied blacklist that 220 // as benign or suspected bad or outright bad, using a supplied blacklist that
(...skipping 15 matching lines...) Expand all
228 int suspected_bad_modules_detected() { 236 int suspected_bad_modules_detected() {
229 return suspected_bad_modules_detected_; 237 return suspected_bad_modules_detected_;
230 } 238 }
231 239
232 // Returns the number of confirmed bad modules found in the last scan. 240 // Returns the number of confirmed bad modules found in the last scan.
233 // Returns 0 if no scan has taken place yet. 241 // Returns 0 if no scan has taken place yet.
234 int confirmed_bad_modules_detected() { 242 int confirmed_bad_modules_detected() {
235 return confirmed_bad_modules_detected_; 243 return confirmed_bad_modules_detected_;
236 } 244 }
237 245
238 // Asynchronously start the scan for the loaded module list. 246 // Set to true when we the scanning process can not rely on certain Chrome
239 // When the list is ready. 247 // services to exists.
248 void set_limited_mode(bool limited_mode) {
249 limited_mode_ = limited_mode;
250 }
251
252 // Asynchronously start the scan for the loaded module list, except when in
253 // limited_mode (in which case it blocks).
240 void ScanNow(); 254 void ScanNow();
241 255
242 // Gets the whole module list as a ListValue. 256 // Gets the whole module list as a ListValue.
243 ListValue* GetModuleList(); 257 ListValue* GetModuleList();
244 258
245 private: 259 private:
246 friend struct DefaultSingletonTraits<EnumerateModulesModel>; 260 friend struct DefaultSingletonTraits<EnumerateModulesModel>;
247 friend class ModuleEnumerator; 261 friend class ModuleEnumerator;
248 262
249 EnumerateModulesModel(); 263 EnumerateModulesModel();
(...skipping 11 matching lines...) Expand all
261 // any bad modules will be marked. 275 // any bad modules will be marked.
262 ModuleEnumerator::ModulesVector enumerated_modules_; 276 ModuleEnumerator::ModulesVector enumerated_modules_;
263 277
264 // The object responsible for enumerating the modules on the File thread. 278 // The object responsible for enumerating the modules on the File thread.
265 scoped_refptr<ModuleEnumerator> module_enumerator_; 279 scoped_refptr<ModuleEnumerator> module_enumerator_;
266 280
267 // When this singleton object is constructed we go and fire off this timer to 281 // When this singleton object is constructed we go and fire off this timer to
268 // start scanning for modules after a certain amount of time has passed. 282 // start scanning for modules after a certain amount of time has passed.
269 base::OneShotTimer<EnumerateModulesModel> check_modules_timer_; 283 base::OneShotTimer<EnumerateModulesModel> check_modules_timer_;
270 284
285 // While normally |false|, this mode can be set to indicate that the scanning
286 // process should not rely on certain services normally available to Chrome,
287 // such as the resource bundle and the notification system, not to mention
288 // having multiple threads. This mode is useful during diagnostics, which
289 // runs without firing up all necessary Chrome services first.
290 bool limited_mode_;
291
271 // True if we are currently scanning for modules. 292 // True if we are currently scanning for modules.
272 bool scanning_; 293 bool scanning_;
273 294
274 // The number of confirmed bad modules (not including suspected bad ones) 295 // The number of confirmed bad modules (not including suspected bad ones)
275 // found during last scan. 296 // found during last scan.
276 int confirmed_bad_modules_detected_; 297 int confirmed_bad_modules_detected_;
277 298
278 // The number of suspected bad modules (not including confirmed bad ones) 299 // The number of suspected bad modules (not including confirmed bad ones)
279 // found during last scan. 300 // found during last scan.
280 int suspected_bad_modules_detected_; 301 int suspected_bad_modules_detected_;
281 302
282 DISALLOW_COPY_AND_ASSIGN(EnumerateModulesModel); 303 DISALLOW_COPY_AND_ASSIGN(EnumerateModulesModel);
283 }; 304 };
284 305
285 #endif // CHROME_BROWSER_ENUMERATE_MODULES_MODEL_WIN_H_ 306 #endif // CHROME_BROWSER_ENUMERATE_MODULES_MODEL_WIN_H_
OLDNEW
« no previous file with comments | « chrome/browser/enumerate_modules_model_unittest_win.cc ('k') | chrome/browser/enumerate_modules_model_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698