Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
| 15 #include "content/public/common/process_type.h" | 15 #include "content/public/common/process_type.h" |
| 16 | 16 |
| 17 // A class that keeps track of all modules loaded across Chrome processes. | 17 // A class that keeps track of all modules loaded across Chrome processes. |
| 18 // Drives the chrome://conflicts UI. | 18 // Drives the chrome://conflicts UI. |
| 19 // | |
| 20 // This is effectively a singleton, but doesn't use base::Singleton. The intent | |
| 21 // is for the object to be created when Chrome is single-threaded, and for it | |
| 22 // be set as the process-wide singleton via SetInstance. | |
| 19 class ModuleDatabase { | 23 class ModuleDatabase { |
| 20 public: | 24 public: |
| 21 // A ModuleDatabase is by default bound to a provided sequenced task runner. | 25 // A ModuleDatabase is by default bound to a provided sequenced task runner. |
| 22 // All calls must be made in the context of this task runner, unless | 26 // All calls must be made in the context of this task runner, unless |
| 23 // otherwise noted. For calls from other contexts this task runner is used to | 27 // otherwise noted. For calls from other contexts this task runner is used to |
| 24 // bounce the call when appropriate. | 28 // bounce the call when appropriate. |
| 25 explicit ModuleDatabase(scoped_refptr<base::SequencedTaskRunner> task_runner); | 29 explicit ModuleDatabase(scoped_refptr<base::SequencedTaskRunner> task_runner); |
| 26 ~ModuleDatabase(); | 30 ~ModuleDatabase(); |
| 27 | 31 |
| 32 // Retrieves the singleton global instance of the ModuleDatabase. | |
| 33 static ModuleDatabase* GetInstance(); | |
| 34 // Sets the global instance of the ModuleDatabase. | |
|
grt (UTC plus 2)
2017/01/06 09:44:58
nit: blank line before comment
chrisha
2017/01/10 21:01:46
Done.
| |
| 35 static void SetInstance(std::unique_ptr<ModuleDatabase> module_database); | |
| 36 | |
| 28 // Indicates that process with the given type has started. This must be called | 37 // Indicates that process with the given type has started. This must be called |
| 29 // before any calls to OnModuleEvent or OnModuleUnload. Must be called in the | 38 // before any calls to OnModuleEvent or OnModuleUnload. Must be called in the |
| 30 // same sequence as |task_runner_|. | 39 // same sequence as |task_runner_|. |
| 31 void OnProcessStarted(uint32_t process_id, | 40 void OnProcessStarted(uint32_t process_id, |
| 32 uint64_t creation_time, | 41 uint64_t creation_time, |
| 33 content::ProcessType process_type); | 42 content::ProcessType process_type); |
| 34 | 43 |
| 35 // Indicates that a module has been loaded. The data passed to this function | 44 // Indicates that a module has been loaded. The data passed to this function |
| 36 // is taken as gospel, so if it originates from a remote process it should be | 45 // is taken as gospel, so if it originates from a remote process it should be |
| 37 // independently validated first. (In practice, see ModuleEventSinkImpl for | 46 // independently validated first. (In practice, see ModuleEventSinkImpl for |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 // | 214 // |
| 206 // These are modified by the various static *LoadAddress* helper functions in | 215 // These are modified by the various static *LoadAddress* helper functions in |
| 207 // ModuleDatabase. The vector maintains the invariant the element with maximum | 216 // ModuleDatabase. The vector maintains the invariant the element with maximum |
| 208 // module ID is always last. This ensures that the usual operation of loading | 217 // module ID is always last. This ensures that the usual operation of loading |
| 209 // a module is O(1). | 218 // a module is O(1). |
| 210 ModuleLoadAddresses loaded_modules; | 219 ModuleLoadAddresses loaded_modules; |
| 211 ModuleLoadAddresses unloaded_modules; | 220 ModuleLoadAddresses unloaded_modules; |
| 212 }; | 221 }; |
| 213 | 222 |
| 214 #endif // CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_ | 223 #endif // CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_ |
| OLD | NEW |