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

Unified Diff: base/win/scoped_handle.cc

Issue 1977833003: Add a buildflag to use the handle verifier in a per module mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GN. Created 4 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 side-by-side diff with in-line comments
Download patch
Index: base/win/scoped_handle.cc
diff --git a/base/win/scoped_handle.cc b/base/win/scoped_handle.cc
index cce16281ae41200776cafa73efbf8a59c2cb8f84..649f2ea0a6f249a4abc243b6492ff912c26d46a6 100644
--- a/base/win/scoped_handle.cc
+++ b/base/win/scoped_handle.cc
@@ -18,6 +18,7 @@
#include "base/threading/thread_local.h"
#include "base/win/current_module.h"
+#if BUILDFLAG(ENABLE_HANDLE_VERIFIER)
extern "C" {
__declspec(dllexport) void* GetHandleVerifier();
typedef void* (*GetHandleVerifierFn)();
@@ -254,14 +255,29 @@ void* GetHandleVerifier() {
return ActiveVerifier::Get();
}
+#endif // BUILDFLAG(ENABLE_HANDLE_VERIFIER)
+
namespace base {
namespace win {
// Static.
bool HandleTraits::CloseHandle(HANDLE handle) {
+#if BUILDFLAG(ENABLE_HANDLE_VERIFIER)
return ActiveVerifier::Get()->CloseHandle(handle);
+#else // BUILDFLAG(ENABLE_HANDLE_VERIFIER)
+ if (!::CloseHandle(handle))
+ CHECK(false);
+ return true;
+#endif
}
+void OnHandleBeingClosed(HANDLE handle) {
+#if BUILDFLAG(ENABLE_HANDLE_VERIFIER)
+ return ActiveVerifier::Get()->OnHandleBeingClosed(handle);
+#endif
+}
+
+#if BUILDFLAG(ENABLE_HANDLE_VERIFIER)
// Static.
void VerifierTraits::StartTracking(HANDLE handle, const void* owner,
const void* pc1, const void* pc2) {
@@ -274,17 +290,16 @@ void VerifierTraits::StopTracking(HANDLE handle, const void* owner,
return ActiveVerifier::Get()->StopTracking(handle, owner, pc1, pc2);
}
-void DisableHandleVerifier() {
- return ActiveVerifier::Get()->Disable();
-}
-
-void OnHandleBeingClosed(HANDLE handle) {
- return ActiveVerifier::Get()->OnHandleBeingClosed(handle);
-}
-
HMODULE GetHandleVerifierModuleForTesting() {
return g_active_verifier->GetModule();
}
+#endif // BUILDFLAG(ENABLE_HANDLE_VERIFIER)
+
+void DisableHandleVerifier() {
+#if BUILDFLAG(ENABLE_HANDLE_VERIFIER)
+ return ActiveVerifier::Get()->Disable();
+#endif
+}
} // namespace win
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698