Index: chrome/browser/conflicts/module_inspector_win.h |
diff --git a/chrome/browser/conflicts/module_inspector_win.h b/chrome/browser/conflicts/module_inspector_win.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7fdac5573f4dce48a553ebd987c16d49718425a1 |
--- /dev/null |
+++ b/chrome/browser/conflicts/module_inspector_win.h |
@@ -0,0 +1,74 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_CONFLICTS_MODULE_INSPECTOR_WIN_H_ |
+#define CHROME_BROWSER_CONFLICTS_MODULE_INSPECTOR_WIN_H_ |
+ |
+#include <queue> |
+ |
+#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/task_scheduler/task_traits.h" |
+#include "chrome/browser/conflicts/module_info_win.h" |
+ |
+// This class is responsible for inspecting modules on a blocking task runner. |
+// For each ModuleInfoKey added, a populated ModuleInfoData will get posted back |
+// to the delegate. |
chrisha
2017/03/01 16:03:38
Prefer callback to delegate?
Patrick Monette
2017/03/03 22:16:30
Done.
|
+// |
+// The inspection of all modules is quite expensive in terms of resources, so it |
+// is done one by one, in a task with a background priority level. If needed, it |
+// 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.
|
+// 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.
|
+class ModuleInspector { |
+ public: |
+ class Delegate { |
+ public: |
+ // Called when a module has finished being inspectedé |
+ virtual void OnModuleInspected(const ModuleInfoKey& module_key, |
+ const ModuleInfoData& module_data) = 0; |
+ }; |
+ |
+ explicit ModuleInspector(Delegate* delegate); |
+ ~ModuleInspector(); |
+ |
+ // Adds the module to the queue of modules to inspect. Starts the inspection |
+ // process if the |queue_| is empty. |
+ void AddModule(const ModuleInfoKey& module_key); |
+ |
+ // Removes the throttling. |
+ void IncreaseInspectionPriority(); |
+ |
+ private: |
+ // Starts inspecting the module at the front of the queue. |
+ 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
|
+ |
+ // Called back on the execution context on which the ModuleInspector was |
+ // created when a module has finished being inspected. The delegate will be |
+ // notified and, if the |queue_| is not empty, the next module will be sent |
+ // for inspection. |
+ void OnInspectionFinished(const ModuleInfoKey& module_key, |
+ const ModuleInfoData& module_data); |
+ |
+ Delegate* delegate_; |
+ |
+ // The modules are put in queue until they get are sent for inspection. |
+ std::queue<ModuleInfoKey> queue_; |
+ |
+ // 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.
|
+ // at a BACKGROUND priority, but is changed to USER_VISIBLE when |
+ // IncreaseInspectionPriority() is called. |
+ 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!
|
+ |
+ // The vector of paths to %env_var%, used to account for differences in |
+ // 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.
|
+ StringMapping path_mapping_; |
+ |
+ // Weak pointers are used to safely post the inspection result back to the |
+ // ModuleInspector from the task scheduler. |
+ base::WeakPtrFactory<ModuleInspector> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ModuleInspector); |
+}; |
+ |
+#endif // CHROME_BROWSER_CONFLICTS_MODULE_INSPECTOR_WIN_H_ |