OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/win/enumerate_modules_model.h" | 5 #include "chrome/browser/win/enumerate_modules_model.h" |
6 | 6 |
7 #include <mscat.h> // NOLINT: This must be after wincrypt and wintrust. | |
Finnur
2017/02/14 15:32:20
Umm... this looks wrong...
fdoray
2017/02/17 19:05:36
Sorry. sort-headers.py did a bad job here.
| |
7 #include <softpub.h> | 8 #include <softpub.h> |
8 #include <stddef.h> | 9 #include <stddef.h> |
9 #include <stdint.h> | 10 #include <stdint.h> |
10 #include <tlhelp32.h> | 11 #include <tlhelp32.h> |
11 #include <wincrypt.h> | 12 #include <wincrypt.h> |
12 #include <wintrust.h> | 13 #include <wintrust.h> |
13 #include <mscat.h> // NOLINT: This must be after wincrypt and wintrust. | |
14 | 14 |
15 #include <algorithm> | 15 #include <algorithm> |
16 #include <set> | 16 #include <set> |
17 | 17 |
18 #include "base/bind.h" | 18 #include "base/bind.h" |
19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
20 #include "base/debug/crash_logging.h" | 20 #include "base/debug/crash_logging.h" |
21 #include "base/debug/leak_annotations.h" | 21 #include "base/debug/leak_annotations.h" |
22 #include "base/environment.h" | 22 #include "base/environment.h" |
23 #include "base/file_version_info.h" | 23 #include "base/file_version_info.h" |
24 #include "base/i18n/case_conversion.h" | 24 #include "base/i18n/case_conversion.h" |
25 #include "base/macros.h" | 25 #include "base/macros.h" |
26 #include "base/metrics/histogram_macros.h" | 26 #include "base/metrics/histogram_macros.h" |
27 #include "base/scoped_generic.h" | 27 #include "base/scoped_generic.h" |
28 #include "base/strings/string_number_conversions.h" | 28 #include "base/strings/string_number_conversions.h" |
29 #include "base/strings/string_util.h" | 29 #include "base/strings/string_util.h" |
30 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
31 #include "base/task_scheduler/post_task.h" | |
31 #include "base/time/time.h" | 32 #include "base/time/time.h" |
32 #include "base/values.h" | 33 #include "base/values.h" |
33 #include "base/version.h" | 34 #include "base/version.h" |
34 #include "base/win/registry.h" | 35 #include "base/win/registry.h" |
35 #include "base/win/scoped_handle.h" | 36 #include "base/win/scoped_handle.h" |
36 #include "base/win/windows_version.h" | 37 #include "base/win/windows_version.h" |
37 #include "chrome/browser/net/service_providers_win.h" | 38 #include "chrome/browser/net/service_providers_win.h" |
38 #include "chrome/common/chrome_constants.h" | 39 #include "chrome/common/chrome_constants.h" |
39 #include "chrome/common/crash_keys.h" | 40 #include "chrome/common/crash_keys.h" |
40 #include "chrome/grit/generated_resources.h" | 41 #include "chrome/grit/generated_resources.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 ModuleEnumerator::~ModuleEnumerator() { | 412 ModuleEnumerator::~ModuleEnumerator() { |
412 } | 413 } |
413 | 414 |
414 void ModuleEnumerator::ScanNow(ModulesVector* list) { | 415 void ModuleEnumerator::ScanNow(ModulesVector* list) { |
415 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 416 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
416 enumerated_modules_ = list; | 417 enumerated_modules_ = list; |
417 | 418 |
418 // This object can't be reaped until it has finished scanning, so its safe | 419 // This object can't be reaped until it has finished scanning, so its safe |
419 // to post a raw pointer to another thread. It will simply be leaked if the | 420 // to post a raw pointer to another thread. It will simply be leaked if the |
420 // scanning has not been finished before shutdown. | 421 // scanning has not been finished before shutdown. |
421 BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior( | 422 base::PostTaskWithTraits( |
422 FROM_HERE, | 423 FROM_HERE, base::TaskTraits() |
423 base::Bind(&ModuleEnumerator::ScanImplStart, | 424 .MayBlock() |
424 base::Unretained(this)), | 425 .WithPriority(base::TaskPriority::BACKGROUND) |
425 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 426 .WithShutdownBehavior( |
427 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), | |
428 base::Bind(&ModuleEnumerator::ScanImplStart, base::Unretained(this))); | |
426 } | 429 } |
427 | 430 |
428 void ModuleEnumerator::SetPerModuleDelayToZero() { | 431 void ModuleEnumerator::SetPerModuleDelayToZero() { |
429 // Set the delay to zero so the modules enumerate as quickly as possible. | 432 // Set the delay to zero so the modules enumerate as quickly as possible. |
430 per_module_delay_ = base::TimeDelta::FromSeconds(0); | 433 per_module_delay_ = base::TimeDelta::FromSeconds(0); |
431 } | 434 } |
432 | 435 |
433 void ModuleEnumerator::ScanImplStart() { | 436 void ModuleEnumerator::ScanImplStart() { |
434 base::TimeTicks start_time = base::TimeTicks::Now(); | 437 base::TimeTicks start_time = base::TimeTicks::Now(); |
435 | 438 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
469 FROM_HERE, | 472 FROM_HERE, |
470 base::Bind(&ModuleEnumerator::ScanImplModule, | 473 base::Bind(&ModuleEnumerator::ScanImplModule, |
471 base::Unretained(this), | 474 base::Unretained(this), |
472 0), | 475 0), |
473 per_module_delay_); | 476 per_module_delay_); |
474 } | 477 } |
475 | 478 |
476 void ModuleEnumerator::ScanImplDelay(size_t index) { | 479 void ModuleEnumerator::ScanImplDelay(size_t index) { |
477 // Bounce this over to a CONTINUE_ON_SHUTDOWN task in the same pool. This is | 480 // Bounce this over to a CONTINUE_ON_SHUTDOWN task in the same pool. This is |
478 // necessary to prevent shutdown hangs while inspecting a module. | 481 // necessary to prevent shutdown hangs while inspecting a module. |
479 BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior( | 482 base::PostTaskWithTraits( |
480 FROM_HERE, | 483 FROM_HERE, base::TaskTraits() |
481 base::Bind(&ModuleEnumerator::ScanImplModule, | 484 .MayBlock() |
482 base::Unretained(this), | 485 .WithPriority(base::TaskPriority::BACKGROUND) |
483 index), | 486 .WithShutdownBehavior( |
484 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 487 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), |
488 base::Bind(&ModuleEnumerator::ScanImplModule, base::Unretained(this), | |
489 index)); | |
485 } | 490 } |
486 | 491 |
487 void ModuleEnumerator::ScanImplModule(size_t index) { | 492 void ModuleEnumerator::ScanImplModule(size_t index) { |
488 while (index < enumerated_modules_->size()) { | 493 while (index < enumerated_modules_->size()) { |
489 base::TimeTicks start_time = base::TimeTicks::Now(); | 494 base::TimeTicks start_time = base::TimeTicks::Now(); |
490 Module& entry = enumerated_modules_->at(index); | 495 Module& entry = enumerated_modules_->at(index); |
491 PopulateModuleInformation(&entry); | 496 PopulateModuleInformation(&entry); |
492 NormalizeModule(&entry); | 497 NormalizeModule(&entry); |
493 CollapsePath(&entry); | 498 CollapsePath(&entry); |
494 base::TimeDelta elapsed = base::TimeTicks::Now() - start_time; | 499 base::TimeDelta elapsed = base::TimeTicks::Now() - start_time; |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1011 | 1016 |
1012 UMA_HISTOGRAM_COUNTS_100("Conflicts.SuspectedBadModules", | 1017 UMA_HISTOGRAM_COUNTS_100("Conflicts.SuspectedBadModules", |
1013 suspected_bad_modules_detected_); | 1018 suspected_bad_modules_detected_); |
1014 UMA_HISTOGRAM_COUNTS_100("Conflicts.ConfirmedBadModules", | 1019 UMA_HISTOGRAM_COUNTS_100("Conflicts.ConfirmedBadModules", |
1015 confirmed_bad_modules_detected_); | 1020 confirmed_bad_modules_detected_); |
1016 | 1021 |
1017 // Forward the callback to any registered observers. | 1022 // Forward the callback to any registered observers. |
1018 for (Observer& observer : observers_) | 1023 for (Observer& observer : observers_) |
1019 observer.OnScanCompleted(); | 1024 observer.OnScanCompleted(); |
1020 } | 1025 } |
OLD | NEW |