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

Side by Side Diff: ui/gfx/win/singleton_hwnd_observer.cc

Issue 1092183005: Fix Up SingletonHwnd Observer Lifetime Issues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow null SingletonHwnd Hwnd Created 5 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 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();
19 }
20
21 void SingletonHwndObserver::ClearWndProc() {
22 if (!wnd_proc_.is_null()) {
23 SingletonHwnd::GetInstance()->RemoveObserver(this);
24 wnd_proc_.Reset();
25 }
26 }
27
28 void SingletonHwndObserver::OnWndProc(HWND hwnd,
29 UINT message,
30 WPARAM wparam,
31 LPARAM lparam) {
32 wnd_proc_.Run(hwnd, message, wparam, lparam);
33 }
34
35 } // namespace gfx
OLDNEW
« ui/gfx/sys_color_change_listener.cc ('K') | « ui/gfx/win/singleton_hwnd_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698