summaryrefslogtreecommitdiff
path: root/chromium/ui/gfx/win
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
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')
-rw-r--r--chromium/ui/gfx/win/hwnd_util.cc42
-rw-r--r--chromium/ui/gfx/win/hwnd_util.h6
-rw-r--r--chromium/ui/gfx/win/rendering_window_manager.cc1
-rw-r--r--chromium/ui/gfx/win/scoped_set_map_mode.h2
-rw-r--r--chromium/ui/gfx/win/window_impl.cc6
-rw-r--r--chromium/ui/gfx/win/window_impl.h2
6 files changed, 40 insertions, 19 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;
}
}
diff --git a/chromium/ui/gfx/win/hwnd_util.h b/chromium/ui/gfx/win/hwnd_util.h
index 5351d9467f0..18b386208a0 100644
--- a/chromium/ui/gfx/win/hwnd_util.h
+++ b/chromium/ui/gfx/win/hwnd_util.h
@@ -35,9 +35,9 @@ GFX_EXPORT void CenterAndSizeWindow(HWND parent,
HWND window,
const gfx::Size& pref);
-// If |hwnd| is NULL logs various thing and CHECKs. Invoke right after calling
-// CreateWindow.
-GFX_EXPORT void CheckWindowCreated(HWND hwnd);
+// If |hwnd| is nullptr logs various thing and CHECKs. |last_error| must contain
+// the result of ::GetLastError(), called immediately after CreateWindow().
+GFX_EXPORT void CheckWindowCreated(HWND hwnd, DWORD last_error);
// Returns the window you can use to parent a top level window.
// Note that in some cases we create child windows not parented to its final
diff --git a/chromium/ui/gfx/win/rendering_window_manager.cc b/chromium/ui/gfx/win/rendering_window_manager.cc
index 1483e9883c3..85368828682 100644
--- a/chromium/ui/gfx/win/rendering_window_manager.cc
+++ b/chromium/ui/gfx/win/rendering_window_manager.cc
@@ -5,6 +5,7 @@
#include "ui/gfx/win/rendering_window_manager.h"
#include "base/bind.h"
+#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
diff --git a/chromium/ui/gfx/win/scoped_set_map_mode.h b/chromium/ui/gfx/win/scoped_set_map_mode.h
index 253eca8a072..5ab40bc60c8 100644
--- a/chromium/ui/gfx/win/scoped_set_map_mode.h
+++ b/chromium/ui/gfx/win/scoped_set_map_mode.h
@@ -7,7 +7,7 @@
#include <windows.h>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/macros.h"
namespace gfx {
diff --git a/chromium/ui/gfx/win/window_impl.cc b/chromium/ui/gfx/win/window_impl.cc
index 8df35cdc651..9c4de6c604d 100644
--- a/chromium/ui/gfx/win/window_impl.cc
+++ b/chromium/ui/gfx/win/window_impl.cc
@@ -217,6 +217,8 @@ void WindowImpl::Init(HWND parent, const Rect& bounds) {
reinterpret_cast<wchar_t*>(atom), NULL,
window_style_, x, y, width, height,
parent, NULL, NULL, this);
+ const DWORD create_window_error = ::GetLastError();
+
// First nccalcszie (during CreateWindow) for captioned windows is
// deliberately ignored so force a second one here to get the right
// non-client set up.
@@ -226,7 +228,7 @@ void WindowImpl::Init(HWND parent, const Rect& bounds) {
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
}
- if (!hwnd_ && GetLastError() == 0) {
+ if (!hwnd_ && create_window_error == 0) {
base::debug::Alias(&destroyed);
base::debug::Alias(&hwnd);
bool got_create = got_create_;
@@ -248,7 +250,7 @@ void WindowImpl::Init(HWND parent, const Rect& bounds) {
if (!destroyed)
destroyed_ = NULL;
- CheckWindowCreated(hwnd_);
+ CheckWindowCreated(hwnd_, create_window_error);
// The window procedure should have set the data for us.
CHECK_EQ(this, GetWindowUserData(hwnd));
diff --git a/chromium/ui/gfx/win/window_impl.h b/chromium/ui/gfx/win/window_impl.h
index 268ca081016..d34c649708a 100644
--- a/chromium/ui/gfx/win/window_impl.h
+++ b/chromium/ui/gfx/win/window_impl.h
@@ -7,7 +7,7 @@
#include <string>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/macros.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/gfx_export.h"