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

Unified Diff: base/debug/close_handle_hook_win.cc

Issue 2667513003: Remove some LazyInstance use in base/ (Closed)
Patch Set: no message_window Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: base/debug/close_handle_hook_win.cc
diff --git a/base/debug/close_handle_hook_win.cc b/base/debug/close_handle_hook_win.cc
index 168de67bcc066f2f73452185296beeacb6aa4795..1f2aeab6d183153a96405181cfd3ff3eb4453e83 100644
--- a/base/debug/close_handle_hook_win.cc
+++ b/base/debug/close_handle_hook_win.cc
@@ -12,7 +12,6 @@
#include <memory>
#include <vector>
-#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/win/iat_patch_function.h"
#include "base/win/pe_image.h"
@@ -197,13 +196,11 @@ class HandleHooks {
void AddIATPatch(HMODULE module);
void AddEATPatch();
- void Unpatch();
private:
std::vector<base::win::IATPatchFunction*> hooks_;
DISALLOW_COPY_AND_ASSIGN(HandleHooks);
};
-base::LazyInstance<HandleHooks> g_hooks = LAZY_INSTANCE_INITIALIZER;
void HandleHooks::AddIATPatch(HMODULE module) {
if (!module)
@@ -232,14 +229,6 @@ void HandleHooks::AddEATPatch() {
reinterpret_cast<void**>(&g_duplicate_function));
}
-void HandleHooks::Unpatch() {
- for (std::vector<base::win::IATPatchFunction*>::iterator it = hooks_.begin();
- it != hooks_.end(); ++it) {
- (*it)->Unpatch();
- delete *it;
- }
-}
-
void PatchLoadedModules(HandleHooks* hooks) {
const DWORD kSize = 256;
DWORD returned;
@@ -259,7 +248,7 @@ void PatchLoadedModules(HandleHooks* hooks) {
} // namespace
void InstallHandleHooks() {
- HandleHooks* hooks = g_hooks.Pointer();
+ static HandleHooks* hooks = new HandleHooks();
// Performing EAT interception first is safer in the presence of other
// threads attempting to call CloseHandle.
@@ -267,10 +256,5 @@ void InstallHandleHooks() {
PatchLoadedModules(hooks);
}
-void RemoveHandleHooks() {
- // We are partching all loaded modules without forcing them to stay in memory,
- // removing patches is not safe.
-}
-
} // namespace debug
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698