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

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

Issue 2721503003: Add ModuleInspector (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CONFLICTS_MODULE_INSPECTOR_WIN_H_
6 #define CHROME_BROWSER_CONFLICTS_MODULE_INSPECTOR_WIN_H_
7
8 #include <queue>
9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/task_scheduler/task_traits.h"
13 #include "chrome/browser/conflicts/module_info_win.h"
14
15 // This class is responsible for inspecting modules on a blocking task runner.
16 // For each ModuleInfoKey added, a populated ModuleInfoData will get posted back
17 // to the delegate.
chrisha 2017/03/01 16:03:38 Prefer callback to delegate?
Patrick Monette 2017/03/03 22:16:30 Done.
18 //
19 // The inspection of all modules is quite expensive in terms of resources, so it
20 // is done one by one, in a task with a background priority level. If needed, it
21 // is possible to increase the priority level of these task by calling
chrisha 2017/03/01 16:03:38 these tasks*
Patrick Monette 2017/03/03 22:16:30 Done.
22 // IncreaseInspectionPriority().
chrisha 2017/03/01 16:03:38 Can you comment on the threading model? That this
Patrick Monette 2017/03/03 22:16:29 Done.
23 class ModuleInspector {
24 public:
25 class Delegate {
26 public:
27 // Called when a module has finished being inspectedé
28 virtual void OnModuleInspected(const ModuleInfoKey& module_key,
29 const ModuleInfoData& module_data) = 0;
30 };
31
32 explicit ModuleInspector(Delegate* delegate);
33 ~ModuleInspector();
34
35 // Adds the module to the queue of modules to inspect. Starts the inspection
36 // process if the |queue_| is empty.
37 void AddModule(const ModuleInfoKey& module_key);
38
39 // Removes the throttling.
40 void IncreaseInspectionPriority();
41
42 private:
43 // Starts inspecting the module at the front of the queue.
44 void StartInspectingModule();
chrisha 2017/03/01 16:03:38 StartInspectingModules? (plural) This will kick o
Patrick Monette 2017/03/03 22:16:30 I'd leave it as-is. This gets called once per modu
45
46 // Called back on the execution context on which the ModuleInspector was
47 // created when a module has finished being inspected. The delegate will be
48 // notified and, if the |queue_| is not empty, the next module will be sent
49 // for inspection.
50 void OnInspectionFinished(const ModuleInfoKey& module_key,
51 const ModuleInfoData& module_data);
52
53 Delegate* delegate_;
54
55 // The modules are put in queue until they get are sent for inspection.
56 std::queue<ModuleInfoKey> queue_;
57
58 // The traits used on the task that inspects the modules. It originally start
chrisha 2017/03/01 16:03:38 starts*
Patrick Monette 2017/03/03 22:16:30 Done.
59 // at a BACKGROUND priority, but is changed to USER_VISIBLE when
60 // IncreaseInspectionPriority() is called.
61 base::TaskTraits inspection_task_traits_;
chrisha 2017/03/01 16:03:38 +1 to using the new task scheduler!
Patrick Monette 2017/03/03 22:16:30 Works great!
62
63 // The vector of paths to %env_var%, used to account for differences in
64 // where people keep there files, c:\windows vs. d:\windows, etc.
chrisha 2017/03/01 16:03:38 their* ... and localization
Patrick Monette 2017/03/03 22:16:30 Done.
65 StringMapping path_mapping_;
66
67 // Weak pointers are used to safely post the inspection result back to the
68 // ModuleInspector from the task scheduler.
69 base::WeakPtrFactory<ModuleInspector> weak_ptr_factory_;
70
71 DISALLOW_COPY_AND_ASSIGN(ModuleInspector);
72 };
73
74 #endif // CHROME_BROWSER_CONFLICTS_MODULE_INSPECTOR_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698