Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/gfx/win/singleton_hwnd_observer.h" | |
| 6 | |
| 7 #include "ui/gfx/win/singleton_hwnd.h" | |
| 8 | |
| 9 namespace gfx { | |
| 10 | |
| 11 SingletonHwndObserver::SingletonHwndObserver(const WndProc& wnd_proc) : | |
| 12 wnd_proc_(wnd_proc) { | |
| 13 DCHECK(!wnd_proc.is_null()); | |
| 14 SingletonHwnd::GetInstance()->AddObserver(this); | |
| 15 } | |
| 16 | |
| 17 SingletonHwndObserver::~SingletonHwndObserver() { | |
| 18 ClearWndProc(); | |
|
sky
2015/04/28 13:20:34
Why do you need the ClearWndProc? Won't evertyhing
robliao
2015/04/28 14:11:55
We need to unregister from the SingletonHwnd in tw
sky
2015/04/28 16:45:46
I see it. You're taking is_null() to know when you
| |
| 19 } | |
| 20 | |
| 21 void SingletonHwndObserver::ClearWndProc() { | |
| 22 if (!wnd_proc_.is_null()) | |
| 23 SingletonHwnd::GetInstance()->RemoveObserver(this); | |
| 24 | |
| 25 wnd_proc_.Reset(); | |
| 26 } | |
| 27 | |
| 28 void SingletonHwndObserver::OnWndProc(HWND hwnd, | |
| 29 UINT message, | |
| 30 WPARAM wparam, | |
| 31 LPARAM lparam) { | |
| 32 if (wnd_proc_.is_null()) | |
|
sky
2015/04/28 16:45:46
Shouldn't this be a DCHECK?
robliao
2015/04/28 22:14:10
Actually, even a DCHECK isn't necessary, as it wou
| |
| 33 return; | |
| 34 | |
| 35 wnd_proc_.Run(hwnd, message, wparam, lparam); | |
| 36 | |
| 37 if (message == WM_NCDESTROY) { | |
|
sky
2015/04/28 13:20:34
nit: no {}
robliao
2015/04/28 14:11:55
Done.
| |
| 38 ClearWndProc(); | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 } // namespace gfx | |
| OLD | NEW |