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

Side by Side Diff: chrome/browser/conflicts/module_inspector_win.cc

Issue 2873463002: Remove call to base::TaskTraits::WithPriority() in module_inspector_win.cc. (Closed)
Patch Set: CR-pmonette-5 Created 3 years, 7 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
« no previous file with comments | « chrome/browser/conflicts/module_inspector_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/conflicts/module_inspector_win.h" 5 #include "chrome/browser/conflicts/module_inspector_win.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/task_scheduler/post_task.h" 10 #include "base/task_scheduler/post_task.h"
11 11
12 namespace { 12 namespace {
13 13
14 StringMapping GetPathMapping() { 14 StringMapping GetPathMapping() {
15 return GetEnvironmentVariablesMapping({ 15 return GetEnvironmentVariablesMapping({
16 L"LOCALAPPDATA", L"ProgramFiles", L"ProgramData", L"USERPROFILE", 16 L"LOCALAPPDATA", L"ProgramFiles", L"ProgramData", L"USERPROFILE",
17 L"SystemRoot", L"TEMP", L"TMP", L"CommonProgramFiles", 17 L"SystemRoot", L"TEMP", L"TMP", L"CommonProgramFiles",
18 }); 18 });
19 } 19 }
20 20
21 } // namespace 21 } // namespace
22 22
23 ModuleInspector::ModuleInspector( 23 ModuleInspector::ModuleInspector(
24 const OnModuleInspectedCallback& on_module_inspected_callback) 24 const OnModuleInspectedCallback& on_module_inspected_callback)
25 : on_module_inspected_callback_(on_module_inspected_callback), 25 : on_module_inspected_callback_(on_module_inspected_callback),
26 inspection_task_traits_( 26 inspection_task_priority_(base::TaskPriority::BACKGROUND),
27 {base::MayBlock(), base::TaskPriority::BACKGROUND,
28 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}),
29 path_mapping_(GetPathMapping()), 27 path_mapping_(GetPathMapping()),
30 weak_ptr_factory_(this) {} 28 weak_ptr_factory_(this) {}
31 29
32 ModuleInspector::~ModuleInspector() = default; 30 ModuleInspector::~ModuleInspector() = default;
33 31
34 void ModuleInspector::AddModule(const ModuleInfoKey& module_key) { 32 void ModuleInspector::AddModule(const ModuleInfoKey& module_key) {
35 DCHECK(thread_checker_.CalledOnValidThread()); 33 DCHECK(thread_checker_.CalledOnValidThread());
36 queue_.push(module_key); 34 queue_.push(module_key);
37 if (queue_.size() == 1) 35 if (queue_.size() == 1)
38 StartInspectingModule(); 36 StartInspectingModule();
39 } 37 }
40 38
41 void ModuleInspector::IncreaseInspectionPriority() { 39 void ModuleInspector::IncreaseInspectionPriority() {
42 DCHECK(thread_checker_.CalledOnValidThread()); 40 DCHECK(thread_checker_.CalledOnValidThread());
43 // Modify the task traits so that future inspections are done faster. 41 // Modify the TaskPriority so that future inspections are done faster.
44 inspection_task_traits_ = 42 inspection_task_priority_ = base::TaskPriority::USER_VISIBLE;
45 inspection_task_traits_.WithPriority(base::TaskPriority::USER_VISIBLE);
46 } 43 }
47 44
48 void ModuleInspector::StartInspectingModule() { 45 void ModuleInspector::StartInspectingModule() {
49 ModuleInfoKey module_key = queue_.front(); 46 ModuleInfoKey module_key = queue_.front();
50 queue_.pop(); 47 queue_.pop();
51 48
52 base::PostTaskWithTraitsAndReplyWithResult( 49 base::PostTaskWithTraitsAndReplyWithResult(
53 FROM_HERE, inspection_task_traits_, 50 FROM_HERE,
54 base::Bind(&InspectModule, path_mapping_, module_key), 51 {base::MayBlock(), inspection_task_priority_,
55 base::Bind(&ModuleInspector::OnInspectionFinished, 52 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
56 weak_ptr_factory_.GetWeakPtr(), module_key)); 53 base::BindOnce(&InspectModule, path_mapping_, module_key),
54 base::BindOnce(&ModuleInspector::OnInspectionFinished,
55 weak_ptr_factory_.GetWeakPtr(), module_key));
57 } 56 }
58 57
59 void ModuleInspector::OnInspectionFinished( 58 void ModuleInspector::OnInspectionFinished(
60 const ModuleInfoKey& module_key, 59 const ModuleInfoKey& module_key,
61 std::unique_ptr<ModuleInspectionResult> inspection_result) { 60 std::unique_ptr<ModuleInspectionResult> inspection_result) {
62 on_module_inspected_callback_.Run(module_key, std::move(inspection_result)); 61 on_module_inspected_callback_.Run(module_key, std::move(inspection_result));
63 62
64 // Continue the work. 63 // Continue the work.
65 if (!queue_.empty()) 64 if (!queue_.empty())
66 StartInspectingModule(); 65 StartInspectingModule();
67 } 66 }
OLDNEW
« no previous file with comments | « chrome/browser/conflicts/module_inspector_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698