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

Unified Diff: base/win/scoped_handle.cc

Issue 1779333003: Add test for multithreaded ActiveVerifier behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@handlecreate
Patch Set: multiprocess Created 4 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 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 99dae66e3b2cc1610ea54c9d9e24750446b0566b..5c1ee8a3a406989dcc4e301b98a11b4c7a6aeff4 100644
--- a/base/win/scoped_handle.cc
+++ b/base/win/scoped_handle.cc
@@ -22,6 +22,9 @@ __declspec(dllexport) void* GetHandleVerifier();
typedef void* (*GetHandleVerifierFn)();
}
+// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
+extern "C" IMAGE_DOS_HEADER __ImageBase;
+
namespace {
struct HandleHash {
@@ -85,6 +88,7 @@ class ActiveVerifier {
const void* pc1, const void* pc2);
virtual void Disable();
virtual void OnHandleBeingClosed(HANDLE handle);
+ virtual void GetModule(HMODULE* module) const;
private:
~ActiveVerifier(); // Not implemented.
@@ -242,6 +246,10 @@ void ActiveVerifier::OnHandleBeingClosed(HANDLE handle) {
CHECK(false); // CloseHandle called on tracked handle.
}
+void ActiveVerifier::GetModule(HMODULE* module) const {
+ *module = reinterpret_cast<HMODULE>(&__ImageBase);
+}
+
} // namespace
void* GetHandleVerifier() {
@@ -276,5 +284,14 @@ void OnHandleBeingClosed(HANDLE handle) {
return ActiveVerifier::Get()->OnHandleBeingClosed(handle);
}
+HMODULE GetHandleVerifierModuleForTesting() {
+ HMODULE module = nullptr;
+
+ // Must pass by reference in order to avoid tail-call optimization.
scottmg 2016/03/11 22:13:09 This seems a bit hokey. Would __declspec(noinline)
Will Harris 2016/03/11 22:23:44 I needed this when using tracked_objects::GetProgr
Will Harris 2016/03/11 23:07:47 I simplified this, seems __ImageBase is less sensi
+ g_active_verifier->GetModule(&module);
+
+ return module;
+}
+
} // namespace win
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698