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

Unified Diff: ui/gfx/screen_win.cc

Issue 1092183005: Fix Up SingletonHwnd Observer Lifetime Issues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
Index: ui/gfx/screen_win.cc
diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc
index 9210971d7b45d63865c6de2dd1dc0f2a9c75d7e1..91e8d24bc42f7a16070296237e26a7d05f830258 100644
--- a/ui/gfx/screen_win.cc
+++ b/ui/gfx/screen_win.cc
@@ -6,6 +6,8 @@
#include <windows.h>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/hash.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
@@ -86,12 +88,11 @@ namespace gfx {
ScreenWin::ScreenWin()
: displays_(GetDisplays()) {
- SingletonHwnd::GetInstance()->AddObserver(this);
+ singletonHwndObserver_.SetWndProc(
+ base::Bind(&ScreenWin::OnDisplayChange, base::Unretained(this)));
}
-ScreenWin::~ScreenWin() {
- SingletonHwnd::GetInstance()->RemoveObserver(this);
-}
+ScreenWin::~ScreenWin() {}
gfx::Point ScreenWin::GetCursorScreenPoint() {
POINT pt;
@@ -176,10 +177,10 @@ void ScreenWin::RemoveObserver(DisplayObserver* observer) {
change_notifier_.RemoveObserver(observer);
}
-void ScreenWin::OnWndProc(HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam) {
+void ScreenWin::OnDisplayChange(HWND hwnd,
+ UINT message,
+ WPARAM wparam,
+ LPARAM lparam) {
if (message != WM_DISPLAYCHANGE)
return;

Powered by Google App Engine
This is Rietveld 408576698