OLD | NEW |
(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 #ifndef UI_GFX_WIN_SINGLETON_HWND_OBSERVER_H_ |
| 6 #define UI_GFX_WIN_SINGLETON_HWND_OBSERVER_H_ |
| 7 |
| 8 #include <windows.h> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/macros.h" |
| 12 #include "ui/gfx/gfx_export.h" |
| 13 |
| 14 namespace gfx { |
| 15 |
| 16 class SingletonHwnd; |
| 17 |
| 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 { |
| 21 public: |
| 22 typedef base::Callback<void(HWND, UINT, WPARAM, LPARAM)> WndProc; |
| 23 |
| 24 explicit SingletonHwndObserver(const WndProc& wnd_proc); |
| 25 ~SingletonHwndObserver(); |
| 26 |
| 27 private: |
| 28 friend class SingletonHwnd; |
| 29 |
| 30 void ClearWndProc(); |
| 31 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); |
| 32 |
| 33 WndProc wnd_proc_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(SingletonHwndObserver); |
| 36 }; |
| 37 |
| 38 } // namespace gfx |
| 39 |
| 40 #endif // UI_GFX_WIN_SINGLETON_HWND_OBSERVER_H_ |
OLD | NEW |