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 "ash/accelerators/nested_dispatcher_controller.h" | 5 #include "ash/accelerators/nested_dispatcher_controller.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_dispatcher.h" | 7 #include "ash/accelerators/accelerator_dispatcher.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "base/auto_reset.h" | |
10 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
11 | 10 |
12 namespace ash { | 11 namespace ash { |
13 | 12 |
14 NestedDispatcherController::NestedDispatcherController() { | 13 NestedDispatcherController::NestedDispatcherController() { |
15 } | 14 } |
16 | 15 |
17 NestedDispatcherController::~NestedDispatcherController() { | 16 NestedDispatcherController::~NestedDispatcherController() { |
18 } | 17 } |
19 | 18 |
20 void NestedDispatcherController::RunWithDispatcher( | 19 void NestedDispatcherController::RunWithDispatcher( |
21 base::MessagePumpDispatcher* nested_dispatcher, | 20 base::MessagePumpDispatcher* nested_dispatcher, |
22 aura::Window* associated_window) { | 21 aura::Window* associated_window) { |
23 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 22 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
24 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); | 23 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); |
25 | 24 |
26 AcceleratorDispatcher dispatcher(nested_dispatcher, associated_window); | 25 AcceleratorDispatcher dispatcher(nested_dispatcher, associated_window); |
27 | 26 |
28 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 27 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
29 // use run_loop.QuitClosure(). | 28 // use run_loop.QuitClosure(). |
30 base::RunLoop run_loop(&dispatcher); | 29 base::RunLoop run_loop(&dispatcher); |
31 base::AutoReset<base::Closure> reset_closure(&quit_closure_, | |
32 run_loop.QuitClosure()); | |
33 run_loop.Run(); | 30 run_loop.Run(); |
34 } | 31 } |
35 | 32 |
36 void NestedDispatcherController::QuitNestedMessageLoop() { | |
37 CHECK(!quit_closure_.is_null()); | |
38 quit_closure_.Run(); | |
39 } | |
40 | |
41 } // namespace ash | 33 } // namespace ash |
OLD | NEW |