summaryrefslogtreecommitdiff
path: root/chromium/ui/gfx/win/hwnd_util.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/ui/gfx/win/hwnd_util.cc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/gfx/win/hwnd_util.cc')
-rw-r--r--chromium/ui/gfx/win/hwnd_util.cc42
1 files changed, 30 insertions, 12 deletions
diff --git a/chromium/ui/gfx/win/hwnd_util.cc b/chromium/ui/gfx/win/hwnd_util.cc
index 069968c3b24..9730ad7cfa1 100644
--- a/chromium/ui/gfx/win/hwnd_util.cc
+++ b/chromium/ui/gfx/win/hwnd_util.cc
@@ -4,7 +4,11 @@
#include "ui/gfx/win/hwnd_util.h"
+#include <windows.h>
+
+#include "base/debug/alias.h"
#include "base/logging.h"
+#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "base/win/win_util.h"
#include "ui/gfx/geometry/rect.h"
@@ -50,17 +54,31 @@ void AdjustWindowToFit(HWND hwnd, const RECT& bounds, bool fit_to_monitor) {
// Don't inline these functions so they show up in crash reports.
-NOINLINE void CrashOutOfMemory() {
- PLOG(FATAL);
+NOINLINE void CrashOutOfMemory(DWORD last_error) {
+ // Record Graphics Device Interface (GDI) object counts so they are visible in
+ // the crash's minidump. By default, GDI and USER handles are limited to
+ // 10,000 each per process and 65,535 each globally, exceeding which typically
+ // indicates a leak of GDI resources.
+ const HANDLE process = ::GetCurrentProcess();
+ DWORD num_process_gdi_handles = ::GetGuiResources(process, GR_GDIOBJECTS);
+ DWORD num_process_user_handles = ::GetGuiResources(process, GR_USEROBJECTS);
+ DWORD num_global_gdi_handles = ::GetGuiResources(GR_GLOBAL, GR_GDIOBJECTS);
+ DWORD num_global_user_handles = ::GetGuiResources(GR_GLOBAL, GR_USEROBJECTS);
+ base::debug::Alias(&num_process_gdi_handles);
+ base::debug::Alias(&num_process_user_handles);
+ base::debug::Alias(&num_global_gdi_handles);
+ base::debug::Alias(&num_global_user_handles);
+
+ LOG(FATAL) << last_error;
}
-NOINLINE void CrashAccessDenied() {
- PLOG(FATAL);
+NOINLINE void CrashAccessDenied(DWORD last_error) {
+ LOG(FATAL) << last_error;
}
// Crash isn't one of the ones we commonly see.
-NOINLINE void CrashOther() {
- PLOG(FATAL);
+NOINLINE void CrashOther(DWORD last_error) {
+ LOG(FATAL) << last_error;
}
} // namespace
@@ -182,20 +200,20 @@ void CenterAndSizeWindow(HWND parent,
AdjustWindowToFit(window, window_bounds, !parent);
}
-void CheckWindowCreated(HWND hwnd) {
+void CheckWindowCreated(HWND hwnd, DWORD last_error) {
if (!hwnd) {
- switch (GetLastError()) {
+ switch (last_error) {
case ERROR_NOT_ENOUGH_MEMORY:
- CrashOutOfMemory();
+ CrashOutOfMemory(last_error);
break;
case ERROR_ACCESS_DENIED:
- CrashAccessDenied();
+ CrashAccessDenied(last_error);
break;
default:
- CrashOther();
+ CrashOther(last_error);
break;
}
- PLOG(FATAL);
+ LOG(FATAL) << last_error;
}
}