Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: ui/wm/core/nested_accelerator_controller.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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 #include "ui/wm/core/nested_accelerator_controller.h"
6
7 #include "base/auto_reset.h"
8 #include "base/bind.h"
9 #include "base/run_loop.h"
10 #include "ui/wm/core/nested_accelerator_delegate.h"
11 #include "ui/wm/core/nested_accelerator_dispatcher.h"
12
13 namespace wm {
14
15 NestedAcceleratorController::NestedAcceleratorController(
16 NestedAcceleratorDelegate* delegate)
17 : dispatcher_delegate_(delegate) {
18 DCHECK(delegate);
19 }
20
21 NestedAcceleratorController::~NestedAcceleratorController() {
22 }
23
24 void NestedAcceleratorController::PrepareNestedLoopClosures(
25 base::MessagePumpDispatcher* nested_dispatcher,
26 base::Closure* run_closure,
27 base::Closure* quit_closure) {
28 scoped_ptr<NestedAcceleratorDispatcher> old_accelerator_dispatcher =
29 accelerator_dispatcher_.Pass();
30 accelerator_dispatcher_ = NestedAcceleratorDispatcher::Create(
31 dispatcher_delegate_.get(), nested_dispatcher);
32
33 scoped_ptr<base::RunLoop> run_loop = accelerator_dispatcher_->CreateRunLoop();
34 *quit_closure =
35 base::Bind(&NestedAcceleratorController::QuitNestedMessageLoop,
36 base::Unretained(this),
37 run_loop->QuitClosure());
38 *run_closure = base::Bind(&NestedAcceleratorController::RunNestedMessageLoop,
39 base::Unretained(this),
40 base::Passed(&run_loop),
41 base::Passed(&old_accelerator_dispatcher));
42 }
43
44 void NestedAcceleratorController::RunNestedMessageLoop(
45 scoped_ptr<base::RunLoop> run_loop,
46 scoped_ptr<NestedAcceleratorDispatcher> old_accelerator_dispatcher) {
47 run_loop->Run();
48 accelerator_dispatcher_ = old_accelerator_dispatcher.Pass();
49 }
50
51 void NestedAcceleratorController::QuitNestedMessageLoop(
52 const base::Closure& quit_runloop) {
53 quit_runloop.Run();
54 accelerator_dispatcher_.reset();
55 }
56
57 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/nested_accelerator_controller.h ('k') | ui/wm/core/nested_accelerator_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698