Index: base/debug/gdi_debug_util_win.cc |
diff --git a/base/debug/gdi_debug_util_win.cc b/base/debug/gdi_debug_util_win.cc |
index ce339559eadfe57f11d7ceeeb1e2a3e95b3b73f7..7aded1c06b2cf305c2f7f89636e18c62d7951137 100644 |
--- a/base/debug/gdi_debug_util_win.cc |
+++ b/base/debug/gdi_debug_util_win.cc |
@@ -59,22 +59,12 @@ void CollectChildGDIUsageAndDie(DWORD parent_pid) { |
CHECK(false); |
} |
-} // namespace |
- |
-namespace base { |
-namespace debug { |
- |
-void GDIBitmapAllocFailure(BITMAPINFOHEADER* header, HANDLE shared_section) { |
+void CollectGDIUsageAndDieWithBitmap(BITMAPINFOHEADER* header, |
+ HANDLE shared_section) { |
// Make sure parameters are saved in the minidump. |
DWORD last_error = GetLastError(); |
- LONG width = header->biWidth; |
- LONG heigth = header->biHeight; |
- |
base::debug::Alias(&last_error); |
- base::debug::Alias(&width); |
- base::debug::Alias(&heigth); |
- base::debug::Alias(&shared_section); |
DWORD num_user_handles = GetGuiResources(GetCurrentProcess(), GR_USEROBJECTS); |
@@ -100,24 +90,45 @@ void GDIBitmapAllocFailure(BITMAPINFOHEADER* header, HANDLE shared_section) { |
CHECK_LE(pmc.PagefileUsage, kLotsOfMemory); |
CHECK_LE(pmc.PrivateUsage, kLotsOfMemory); |
- void* small_data = NULL; |
+ void* small_data = nullptr; |
base::debug::Alias(&small_data); |
- if (std::abs(heigth) * width > 100) { |
+ if (header && (std::abs(header->biHeight) * header->biWidth > 100)) { |
// Huh, that's weird. We don't have crazy handle count, we don't have |
// ridiculous memory usage. Try to allocate a small bitmap and see if that |
// fails too. |
header->biWidth = 5; |
header->biHeight = -5; |
HBITMAP small_bitmap = CreateDIBSection( |
- NULL, reinterpret_cast<BITMAPINFO*>(&header), |
+ nullptr, reinterpret_cast<BITMAPINFO*>(&header), |
0, &small_data, shared_section, 0); |
- CHECK(small_bitmap != NULL); |
+ CHECK(small_bitmap != nullptr); |
DeleteObject(small_bitmap); |
} |
+ |
// Maybe the child processes are the ones leaking GDI or USER resouces. |
CollectChildGDIUsageAndDie(GetCurrentProcessId()); |
} |
+} // namespace |
+ |
+namespace base { |
+namespace debug { |
+ |
+void CollectGDIUsageAndDie() { |
+ CollectGDIUsageAndDieWithBitmap(nullptr, nullptr); |
+} |
+ |
+void GDIBitmapAllocFailure(BITMAPINFOHEADER* header, HANDLE shared_section) { |
+ LONG width = header->biWidth; |
+ LONG height = header->biHeight; |
+ |
+ base::debug::Alias(&width); |
+ base::debug::Alias(&height); |
+ base::debug::Alias(&shared_section); |
+ |
+ CollectGDIUsageAndDieWithBitmap(header, shared_section); |
+} |
+ |
} // namespace debug |
} // namespace base |