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

Side by Side Diff: chrome/browser/conflicts/module_database_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
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 #ifndef CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_ 5 #ifndef CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_
6 #define CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_ 6 #define CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
17 #include "chrome/browser/conflicts/module_info_win.h" 17 #include "chrome/browser/conflicts/module_info_win.h"
18 #include "chrome/browser/conflicts/module_inspector_win.h"
18 #include "content/public/common/process_type.h" 19 #include "content/public/common/process_type.h"
19 20
20 // A class that keeps track of all modules loaded across Chrome processes. 21 // A class that keeps track of all modules loaded across Chrome processes.
21 // Drives the chrome://conflicts UI. 22 // Drives the chrome://conflicts UI.
22 // 23 //
23 // This is effectively a singleton, but doesn't use base::Singleton. The intent 24 // This is effectively a singleton, but doesn't use base::Singleton. The intent
24 // is for the object to be created when Chrome is single-threaded, and for it 25 // is for the object to be created when Chrome is single-threaded, and for it
25 // be set as the process-wide singleton via SetInstance. 26 // be set as the process-wide singleton via SetInstance.
26 class ModuleDatabase { 27 class ModuleDatabase : public ModuleInspector::Delegate {
chrisha 2017/03/01 16:03:38 Is delegate the right pattern here? A delegate doe
Patrick Monette 2017/03/03 22:16:29 Using a callback sgtm. Done.
27 public: 28 public:
28 // Structures for maintaining information about modules. 29 // Structures for maintaining information about modules.
29 using ModuleMap = std::map<ModuleInfoKey, ModuleInfoData>; 30 using ModuleMap = std::map<ModuleInfoKey, ModuleInfoData>;
30 using ModuleInfo = ModuleMap::value_type; 31 using ModuleInfo = ModuleMap::value_type;
31 32
32 // Used for maintaing a list of modules loaded in a process. Maps module IDs 33 // Used for maintaing a list of modules loaded in a process. Maps module IDs
33 // to load addresses. 34 // to load addresses.
34 using ModuleLoadAddresses = std::vector<std::pair<ModuleId, uintptr_t>>; 35 using ModuleLoadAddresses = std::vector<std::pair<ModuleId, uintptr_t>>;
35 36
36 // Structures for maintaining information about running processes. 37 // Structures for maintaining information about running processes.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 ProcessInfo* GetProcessInfo(uint32_t process_id, uint64_t creation_time); 136 ProcessInfo* GetProcessInfo(uint32_t process_id, uint64_t creation_time);
136 137
137 // Creates a process info entry. 138 // Creates a process info entry.
138 void CreateProcessInfo(uint32_t process_id, 139 void CreateProcessInfo(uint32_t process_id,
139 uint64_t creation_time, 140 uint64_t creation_time,
140 content::ProcessType process_type); 141 content::ProcessType process_type);
141 142
142 // Deletes a process info entry. 143 // Deletes a process info entry.
143 void DeleteProcessInfo(uint32_t process_id, uint64_t creation_time); 144 void DeleteProcessInfo(uint32_t process_id, uint64_t creation_time);
144 145
146 // ModuleInspector::Delegate:
147 void OnModuleInspected(const ModuleInfoKey& module_key,
148 const ModuleInfoData& module_data) override;
149
145 // The task runner to which this object is bound. 150 // The task runner to which this object is bound.
146 scoped_refptr<base::SequencedTaskRunner> task_runner_; 151 scoped_refptr<base::SequencedTaskRunner> task_runner_;
147 152
148 // A map of all known modules. 153 // A map of all known modules.
149 ModuleMap modules_; 154 ModuleMap modules_;
150 155
156 // Inspects new modules on a blocking task runner.
157 ModuleInspector module_inspector_;
158
151 // A map of all known running processes, and modules loaded/unloaded in 159 // A map of all known running processes, and modules loaded/unloaded in
152 // them. 160 // them.
153 ProcessMap processes_; 161 ProcessMap processes_;
154 162
155 // Weak pointer factory for this object. This is used when bouncing 163 // Weak pointer factory for this object. This is used when bouncing
156 // incoming events to |task_runner_|. 164 // incoming events to |task_runner_|.
157 base::WeakPtrFactory<ModuleDatabase> weak_ptr_factory_; 165 base::WeakPtrFactory<ModuleDatabase> weak_ptr_factory_;
158 166
159 DISALLOW_COPY_AND_ASSIGN(ModuleDatabase); 167 DISALLOW_COPY_AND_ASSIGN(ModuleDatabase);
160 }; 168 };
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // 206 //
199 // These are modified by the various static *LoadAddress* helper functions in 207 // These are modified by the various static *LoadAddress* helper functions in
200 // ModuleDatabase. The vector maintains the invariant the element with maximum 208 // ModuleDatabase. The vector maintains the invariant the element with maximum
201 // module ID is always last. This ensures that the usual operation of loading 209 // module ID is always last. This ensures that the usual operation of loading
202 // a module is O(1). 210 // a module is O(1).
203 ModuleLoadAddresses loaded_modules; 211 ModuleLoadAddresses loaded_modules;
204 ModuleLoadAddresses unloaded_modules; 212 ModuleLoadAddresses unloaded_modules;
205 }; 213 };
206 214
207 #endif // CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_ 215 #endif // CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698