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

Unified Diff: base/win/scoped_handle.h

Issue 10537041: Base: Add another pc to the handle verifier to get to the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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
===================================================================
--- base/win/scoped_handle.h (revision 140836)
+++ base/win/scoped_handle.h (working copy)
@@ -16,6 +16,14 @@
namespace base {
namespace win {
+// TODO(rvargas): remove this with the rest of the verifier.
+#if defined(COMPILER_MSVC)
+#define BASE_WIN_GET_CALLER _ReturnAddress()
+#elif defined(COMPILER_GCC)
+#define BASE_WIN_GET_CALLER __builtin_extract_return_addr(\\
+ __builtin_return_address(0))
+#endif
+
// Generic wrapper for raw handles that takes care of closing handles
// automatically. The class interface follows the style of
// the ScopedStdioHandle class with a few additions:
@@ -48,7 +56,7 @@
if (Traits::IsHandleValid(handle)) {
handle_ = handle;
- Verifier::StartTracking(handle, this,
+ Verifier::StartTracking(handle, this, BASE_WIN_GET_CALLER,
tracked_objects::GetProgramCounter());
}
}
@@ -66,7 +74,7 @@
DCHECK(!Traits::IsHandleValid(handle_)) << "Handle must be NULL";
// We cannot track this case :(. Just tell the verifier about it.
- Verifier::StartTracking(INVALID_HANDLE_VALUE, this,
+ Verifier::StartTracking(INVALID_HANDLE_VALUE, this, BASE_WIN_GET_CALLER,
tracked_objects::GetProgramCounter());
return &handle_;
}
@@ -75,15 +83,16 @@
Handle Take() {
Handle temp = handle_;
handle_ = Traits::NullHandle();
- Verifier::StopTracking(temp, this, tracked_objects::GetProgramCounter());
+ Verifier::StopTracking(temp, this, BASE_WIN_GET_CALLER,
+ tracked_objects::GetProgramCounter());
return temp;
}
// Explicitly closes the owned handle.
void Close() {
if (Traits::IsHandleValid(handle_)) {
- Verifier::StopTracking(handle_, this,
- tracked_objects::GetProgramCounter());
+ Verifier::StopTracking(handle_, this, BASE_WIN_GET_CALLER,
+ tracked_objects::GetProgramCounter());
if (!Traits::CloseHandle(handle_))
CHECK(false);
@@ -98,6 +107,8 @@
DISALLOW_COPY_AND_ASSIGN(GenericScopedHandle);
};
+#undef BASE_WIN_GET_CALLER
+
// The traits class for Win32 handles that can be closed via CloseHandle() API.
class HandleTraits {
public:
@@ -127,8 +138,10 @@
public:
typedef HANDLE Handle;
- static void StartTracking(HANDLE handle, const void* owner, const void* pc) {}
- static void StopTracking(HANDLE handle, const void* owner, const void* pc) {}
+ static void StartTracking(HANDLE handle, const void* owner,
+ const void* pc1, const void* pc2) {}
+ static void StopTracking(HANDLE handle, const void* owner,
+ const void* pc1, const void* pc2) {}
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(DummyVerifierTraits);
@@ -139,8 +152,10 @@
public:
typedef HANDLE Handle;
- static void StartTracking(HANDLE handle, const void* owner, const void* pc);
- static void StopTracking(HANDLE handle, const void* owner, const void* pc);
+ static void StartTracking(HANDLE handle, const void* owner,
+ const void* pc1, const void* pc2);
+ static void StopTracking(HANDLE handle, const void* owner,
+ const void* pc1, const void* pc2);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(VerifierTraits);
« 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