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

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

Issue 2854983002: Add the ThirdPartyModules.Uninstallable histogram. (Closed)
Patch Set: 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
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/observer_list.h"
16 #include "base/sequenced_task_runner.h" 17 #include "base/sequenced_task_runner.h"
17 #include "chrome/browser/conflicts/module_info_win.h" 18 #include "chrome/browser/conflicts/module_info_win.h"
18 #include "chrome/browser/conflicts/module_inspector_win.h" 19 #include "chrome/browser/conflicts/module_inspector_win.h"
20 #include "chrome/browser/conflicts/third_party_metrics_recorder_win.h"
19 #include "content/public/common/process_type.h" 21 #include "content/public/common/process_type.h"
20 22
23 class ModuleDatabaseObserver;
24
21 // A class that keeps track of all modules loaded across Chrome processes. 25 // A class that keeps track of all modules loaded across Chrome processes.
22 // Drives the chrome://conflicts UI. 26 // Drives the chrome://conflicts UI.
23 // 27 //
24 // This is effectively a singleton, but doesn't use base::Singleton. The intent 28 // This is effectively a singleton, but doesn't use base::Singleton. The intent
25 // is for the object to be created when Chrome is single-threaded, and for it 29 // is for the object to be created when Chrome is single-threaded, and for it
26 // be set as the process-wide singleton via SetInstance. 30 // be set as the process-wide singleton via SetInstance.
27 class ModuleDatabase { 31 class ModuleDatabase {
28 public: 32 public:
29 // Structures for maintaining information about modules. 33 // Structures for maintaining information about modules.
30 using ModuleMap = std::map<ModuleInfoKey, ModuleInfoData>; 34 using ModuleMap = std::map<ModuleInfoKey, ModuleInfoData>;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 uintptr_t module_load_address); 85 uintptr_t module_load_address);
82 86
83 // Indicates that the given process has ended. This can be called from any 87 // Indicates that the given process has ended. This can be called from any
84 // thread and will be bounced to the |task_runner_|. In practice it will be 88 // thread and will be bounced to the |task_runner_|. In practice it will be
85 // invoked from the UI thread as the Mojo channel is torn down. 89 // invoked from the UI thread as the Mojo channel is torn down.
86 void OnProcessEnded(uint32_t process_id, uint64_t creation_time); 90 void OnProcessEnded(uint32_t process_id, uint64_t creation_time);
87 91
88 // TODO(chrisha): Module analysis code, and various accessors for use by 92 // TODO(chrisha): Module analysis code, and various accessors for use by
89 // chrome://conflicts. 93 // chrome://conflicts.
90 94
95 // Adds or removes an observer.
96 void AddObserver(ModuleDatabaseObserver* observer);
97 void RemoveObserver(ModuleDatabaseObserver* observer);
98
91 private: 99 private:
92 friend class TestModuleDatabase; 100 friend class TestModuleDatabase;
93 friend class ModuleDatabaseTest; 101 friend class ModuleDatabaseTest;
94 friend class ModuleEventSinkImplTest; 102 friend class ModuleEventSinkImplTest;
95 103
96 // Used by the FindLoadAddress* functions to indicate a load address has not 104 // Used by the FindLoadAddress* functions to indicate a load address has not
97 // been found. 105 // been found.
98 static constexpr size_t kInvalidIndex = ~0u; 106 static constexpr size_t kInvalidIndex = ~0u;
99 107
100 // Converts a valid |process_type| to a bit for use in a bitmask of process 108 // Converts a valid |process_type| to a bit for use in a bitmask of process
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // A map of all known modules. 162 // A map of all known modules.
155 ModuleMap modules_; 163 ModuleMap modules_;
156 164
157 // Inspects new modules on a blocking task runner. 165 // Inspects new modules on a blocking task runner.
158 ModuleInspector module_inspector_; 166 ModuleInspector module_inspector_;
159 167
160 // A map of all known running processes, and modules loaded/unloaded in 168 // A map of all known running processes, and modules loaded/unloaded in
161 // them. 169 // them.
162 ProcessMap processes_; 170 ProcessMap processes_;
163 171
172 base::ObserverList<ModuleDatabaseObserver> observer_list_;
173
174 ThirdPartyMetricsRecorder third_party_metrics_;
175
164 // Weak pointer factory for this object. This is used when bouncing 176 // Weak pointer factory for this object. This is used when bouncing
165 // incoming events to |task_runner_|. 177 // incoming events to |task_runner_|.
166 base::WeakPtrFactory<ModuleDatabase> weak_ptr_factory_; 178 base::WeakPtrFactory<ModuleDatabase> weak_ptr_factory_;
167 179
168 DISALLOW_COPY_AND_ASSIGN(ModuleDatabase); 180 DISALLOW_COPY_AND_ASSIGN(ModuleDatabase);
169 }; 181 };
170 182
171 // Information about a running process. This ties modules in a ModuleSet to 183 // Information about a running process. This ties modules in a ModuleSet to
172 // processes in which they are (or have been) loaded. 184 // processes in which they are (or have been) loaded.
173 185
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // 219 //
208 // These are modified by the various static *LoadAddress* helper functions in 220 // These are modified by the various static *LoadAddress* helper functions in
209 // ModuleDatabase. The vector maintains the invariant the element with maximum 221 // ModuleDatabase. The vector maintains the invariant the element with maximum
210 // module ID is always last. This ensures that the usual operation of loading 222 // module ID is always last. This ensures that the usual operation of loading
211 // a module is O(1). 223 // a module is O(1).
212 ModuleLoadAddresses loaded_modules; 224 ModuleLoadAddresses loaded_modules;
213 ModuleLoadAddresses unloaded_modules; 225 ModuleLoadAddresses unloaded_modules;
214 }; 226 };
215 227
216 #endif // CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_ 228 #endif // CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698