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.
5 #ifndef UI_GFX_WIN_SINGLETON_HWND_OBSERVER_H_
6 #define UI_GFX_WIN_SINGLETON_HWND_OBSERVER_H_
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "ui/gfx/gfx_export.h"
18 // Singleton lifetime management is tricky. This observer handles the correct
19 // cleanup if either the SingletonHwnd or forwarded object is destroyed first.
20 class GFX_EXPORT SingletonHwndObserver
{
22 typedef base::Callback
<void(HWND
, UINT
, WPARAM
, LPARAM
)> WndProc
;
24 explicit SingletonHwndObserver(const WndProc
& wnd_proc
);
25 ~SingletonHwndObserver();
28 friend class SingletonHwnd
;
31 void OnWndProc(HWND hwnd
, UINT message
, WPARAM wparam
, LPARAM lparam
);
35 DISALLOW_COPY_AND_ASSIGN(SingletonHwndObserver
);
40 #endif // UI_GFX_WIN_SINGLETON_HWND_OBSERVER_H_