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

Unified Diff: base/win/scoped_handle.h

Issue 510633002: Improve the ScopedHandle verifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment to the lock Created 6 years, 3 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
« no previous file with comments | « no previous file | base/win/scoped_handle.cc » ('j') | chrome/chrome_dll.gypi » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/scoped_handle.h
diff --git a/base/win/scoped_handle.h b/base/win/scoped_handle.h
index 00063afe3526f9df94d3ca6dbc0da5bb93ca5753..c8d0f39de24a91c36386f9f132fe3d7b910d4b6f 100644
--- a/base/win/scoped_handle.h
+++ b/base/win/scoped_handle.h
@@ -101,9 +101,7 @@ class GenericScopedHandle {
Verifier::StopTracking(handle_, this, BASE_WIN_GET_CALLER,
tracked_objects::GetProgramCounter());
- if (!Traits::CloseHandle(handle_))
- CHECK(false);
-
+ Traits::CloseHandle(handle_);
handle_ = Traits::NullHandle();
}
}
@@ -120,9 +118,7 @@ class HandleTraits {
typedef HANDLE Handle;
// Closes the handle.
- static bool CloseHandle(HANDLE handle) {
- return ::CloseHandle(handle) != FALSE;
- }
+ static bool BASE_EXPORT CloseHandle(HANDLE handle);
// Returns true if the handle value is valid.
static bool IsHandleValid(HANDLE handle) {
@@ -168,6 +164,17 @@ class BASE_EXPORT VerifierTraits {
typedef GenericScopedHandle<HandleTraits, VerifierTraits> ScopedHandle;
+// This function may be called by the embedder to disable the use of
+// VerifierTraits at runtime. It has no effect if DummyVerifierTraits is used
+// for ScopedHandle.
+void BASE_EXPORT DisableHandleVerifier();
+
+// This should be called whenever the OS is closing a handle, if extended
+// verification of improper handle closing is desired. If |handle| is being
+// tracked by the handle verifier and ScopedHandle is not the one closing it,
+// a CHECK is generated.
+void BASE_EXPORT OnHandleBeingClosed(HANDLE handle);
+
} // namespace win
} // namespace base
« no previous file with comments | « no previous file | base/win/scoped_handle.cc » ('j') | chrome/chrome_dll.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698