Source code
Revision control
Copy as Markdown
Other Tools
Neuter debug-only CheckedScopedHandle in scoped_handle.{cc,h}
This removes a dependency on scoped_handle_verifier.{cc,h}.
---
base/win/scoped_handle.cc | 18 ++++++++++++++++++
base/win/scoped_handle.h | 9 +++++++++
2 files changed, 27 insertions(+)
diff --git a/base/win/scoped_handle.cc b/base/win/scoped_handle.cc
index 8c98416de9ab..2c244256c52c 100644
--- a/base/win/scoped_handle.cc
+++ b/base/win/scoped_handle.cc
@@ -3,13 +3,22 @@
// found in the LICENSE file.
#include "base/win/scoped_handle.h"
+
+#if defined(MOZ_ZUCCHINI)
+#include <windows.h>
+
+#include "base/check.h"
+#else
#include "base/win/scoped_handle_verifier.h"
#include "base/win/windows_types.h"
+#endif // defined(MOZ_ZUCCHINI)
namespace base {
namespace win {
+#if !defined(MOZ_ZUCCHINI)
using base::win::internal::ScopedHandleVerifier;
+#endif // !defined(MOZ_ZUCCHINI)
std::ostream& operator<<(std::ostream& os, HandleOperation operation) {
switch (operation) {
@@ -28,9 +37,17 @@ std::ostream& operator<<(std::ostream& os, HandleOperation operation) {
// Static.
bool HandleTraits::CloseHandle(HANDLE handle) {
+#if defined(MOZ_ZUCCHINI)
+ // Taken from scoped_handle_verifier.cc
+ if (!::CloseHandle(handle))
+ CHECK(false) << "CloseHandle failed";
+ return true;
+#else
return ScopedHandleVerifier::Get()->CloseHandle(handle);
+#endif // defined(MOZ_ZUCCHINI)
}
+#if !defined(MOZ_ZUCCHINI)
// Static.
void VerifierTraits::StartTracking(HANDLE handle,
const void* owner,
@@ -54,6 +71,7 @@ void DisableHandleVerifier() {
void OnHandleBeingClosed(HANDLE handle, HandleOperation operation) {
return ScopedHandleVerifier::Get()->OnHandleBeingClosed(handle, operation);
}
+#endif // !defined(MOZ_ZUCCHINI)
} // namespace win
} // namespace base
diff --git a/base/win/scoped_handle.h b/base/win/scoped_handle.h
index dd426874b96e..b419c70402b4 100644
--- a/base/win/scoped_handle.h
+++ b/base/win/scoped_handle.h
@@ -172,6 +172,7 @@ class DummyVerifierTraits {
const void* pc2) {}
};
+#if !defined(MOZ_ZUCCHINI)
// Performs actual run-time tracking.
class BASE_EXPORT VerifierTraits {
public:
@@ -190,9 +191,14 @@ class BASE_EXPORT VerifierTraits {
const void* pc1,
const void* pc2);
};
+#endif // !defined(MOZ_ZUCCHINI)
using UncheckedScopedHandle =
GenericScopedHandle<HandleTraits, DummyVerifierTraits>;
+
+#if defined(MOZ_ZUCCHINI)
+using ScopedHandle = UncheckedScopedHandle;
+#else
using CheckedScopedHandle = GenericScopedHandle<HandleTraits, VerifierTraits>;
#if DCHECK_IS_ON()
@@ -200,7 +206,9 @@ using ScopedHandle = CheckedScopedHandle;
#else
using ScopedHandle = UncheckedScopedHandle;
#endif
+#endif // defined(MOZ_ZUCCHINI)
+#if !defined(MOZ_ZUCCHINI)
// 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.
@@ -211,6 +219,7 @@ BASE_EXPORT void DisableHandleVerifier();
// tracked by the handle verifier and ScopedHandle is not the one closing it,
// a CHECK is generated.
BASE_EXPORT void OnHandleBeingClosed(HANDLE handle, HandleOperation operation);
+#endif // !defined(MOZ_ZUCCHINI)
} // namespace win
} // namespace base
--
2.42.0.windows.2