OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/win/singleton_hwnd.h" | 5 #include "ui/gfx/win/singleton_hwnd.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "ui/gfx/win/singleton_hwnd_observer.h" | 9 #include "ui/gfx/win/singleton_hwnd_observer.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... | |
24 FOR_EACH_OBSERVER(SingletonHwndObserver, | 24 FOR_EACH_OBSERVER(SingletonHwndObserver, |
25 observer_list_, | 25 observer_list_, |
26 OnWndProc(window, message, wparam, lparam)); | 26 OnWndProc(window, message, wparam, lparam)); |
27 return false; | 27 return false; |
28 } | 28 } |
29 | 29 |
30 SingletonHwnd::SingletonHwnd() { | 30 SingletonHwnd::SingletonHwnd() { |
31 if (!base::MessageLoopForUI::IsCurrent()) { | 31 if (!base::MessageLoopForUI::IsCurrent()) { |
32 // Creating this window in (e.g.) a renderer inhibits shutdown on | 32 // Creating this window in (e.g.) a renderer inhibits shutdown on |
33 // Windows. See http://crbug.com/230122 and http://crbug.com/236039. | 33 // Windows. See http://crbug.com/230122 and http://crbug.com/236039. |
34 LOG(FATAL) << "Cannot create windows on non-UI thread!"; | |
Nico
2016/08/29 20:52:41
\o/
| |
34 return; | 35 return; |
35 } | 36 } |
36 WindowImpl::Init(NULL, Rect()); | 37 WindowImpl::Init(NULL, Rect()); |
37 } | 38 } |
38 | 39 |
39 SingletonHwnd::~SingletonHwnd() { | 40 SingletonHwnd::~SingletonHwnd() { |
40 // WindowImpl will clean up the hwnd value on WM_NCDESTROY. | 41 // WindowImpl will clean up the hwnd value on WM_NCDESTROY. |
41 if (hwnd()) | 42 if (hwnd()) |
42 DestroyWindow(hwnd()); | 43 DestroyWindow(hwnd()); |
43 | 44 |
44 // Tell all of our current observers to clean themselves up. | 45 // Tell all of our current observers to clean themselves up. |
45 FOR_EACH_OBSERVER(SingletonHwndObserver, observer_list_, ClearWndProc()); | 46 FOR_EACH_OBSERVER(SingletonHwndObserver, observer_list_, ClearWndProc()); |
46 } | 47 } |
47 | 48 |
48 void SingletonHwnd::AddObserver(SingletonHwndObserver* observer) { | 49 void SingletonHwnd::AddObserver(SingletonHwndObserver* observer) { |
49 observer_list_.AddObserver(observer); | 50 observer_list_.AddObserver(observer); |
50 } | 51 } |
51 | 52 |
52 void SingletonHwnd::RemoveObserver(SingletonHwndObserver* observer) { | 53 void SingletonHwnd::RemoveObserver(SingletonHwndObserver* observer) { |
53 observer_list_.RemoveObserver(observer); | 54 observer_list_.RemoveObserver(observer); |
54 } | 55 } |
55 | 56 |
56 } // namespace gfx | 57 } // namespace gfx |
OLD | NEW |