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

Unified Diff: base/win/scoped_handle.h

Issue 490043002: Improve the ScopedHandle verifier. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Common sources section Created 6 years, 4 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') | no next file with comments »
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..e1e0f5d592ad2e557b32a821b7f0b029c10d63c3 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 should be called by the embedder to enable the use of
+// VerifierTraits at runtime. It has no effect if DummyVerifierTraits is used
+// for ScopedHandle.
+void BASE_EXPORT EnableHandleVerifier();
+
+// 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698