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/views/widget/desktop_aura/desktop_dispatcher_client.h" | 5 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
11 | 11 |
12 DesktopDispatcherClient::DesktopDispatcherClient() | 12 DesktopDispatcherClient::DesktopDispatcherClient() |
13 : weak_ptr_factory_(this) {} | 13 : weak_ptr_factory_(this) {} |
14 | 14 |
15 DesktopDispatcherClient::~DesktopDispatcherClient() { | 15 DesktopDispatcherClient::~DesktopDispatcherClient() { |
16 } | 16 } |
17 | 17 |
18 void DesktopDispatcherClient::RunWithDispatcher( | 18 void DesktopDispatcherClient::RunWithDispatcher( |
19 base::MessagePumpDispatcher* nested_dispatcher) { | 19 base::MessagePumpDispatcher* nested_dispatcher) { |
20 // TODO(erg): This class has been copypastad from | 20 // TODO(erg): This class has been copypastad from |
21 // ash/accelerators/nested_dispatcher_controller.cc. I have left my changes | 21 // ash/accelerators/nested_dispatcher_controller.cc. I have left my changes |
22 // commented out because I don't entirely understand the implications of the | 22 // commented out because I don't entirely understand the implications of the |
23 // change. | 23 // change. |
24 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 24 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
25 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); | 25 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); |
26 | 26 |
27 base::Closure old_quit_closure = quit_closure_; | 27 base::Closure old_quit_closure = quit_closure_; |
| 28 #if defined(OS_WIN) |
28 base::RunLoop run_loop(nested_dispatcher); | 29 base::RunLoop run_loop(nested_dispatcher); |
| 30 #else |
| 31 base::RunLoop run_loop; |
| 32 #endif |
| 33 |
29 quit_closure_ = run_loop.QuitClosure(); | 34 quit_closure_ = run_loop.QuitClosure(); |
30 base::WeakPtr<DesktopDispatcherClient> alive(weak_ptr_factory_.GetWeakPtr()); | 35 base::WeakPtr<DesktopDispatcherClient> alive(weak_ptr_factory_.GetWeakPtr()); |
31 run_loop.Run(); | 36 run_loop.Run(); |
32 if (alive) { | 37 if (alive) { |
33 weak_ptr_factory_.InvalidateWeakPtrs(); | 38 weak_ptr_factory_.InvalidateWeakPtrs(); |
34 quit_closure_ = old_quit_closure; | 39 quit_closure_ = old_quit_closure; |
35 } | 40 } |
36 } | 41 } |
37 | 42 |
38 void DesktopDispatcherClient::QuitNestedMessageLoop() { | 43 void DesktopDispatcherClient::QuitNestedMessageLoop() { |
39 CHECK(!quit_closure_.is_null()); | 44 CHECK(!quit_closure_.is_null()); |
40 quit_closure_.Run(); | 45 quit_closure_.Run(); |
41 } | 46 } |
42 | 47 |
43 } // namespace views | 48 } // namespace views |
OLD | NEW |