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

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

Issue 280483003: wm: Change the DispatcherClient interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self-nit Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/wm/core/nested_accelerator_controller.h" 5 #include "ui/wm/core/nested_accelerator_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h"
8 #include "base/run_loop.h" 9 #include "base/run_loop.h"
9 #include "ui/wm/core/nested_accelerator_delegate.h" 10 #include "ui/wm/core/nested_accelerator_delegate.h"
10 #include "ui/wm/core/nested_accelerator_dispatcher.h" 11 #include "ui/wm/core/nested_accelerator_dispatcher.h"
11 12
12 namespace wm { 13 namespace wm {
13 14
14 NestedAcceleratorController::NestedAcceleratorController( 15 NestedAcceleratorController::NestedAcceleratorController(
15 NestedAcceleratorDelegate* delegate) 16 NestedAcceleratorDelegate* delegate)
16 : dispatcher_delegate_(delegate) { 17 : dispatcher_delegate_(delegate) {
17 DCHECK(delegate); 18 DCHECK(delegate);
18 } 19 }
19 20
20 NestedAcceleratorController::~NestedAcceleratorController() { 21 NestedAcceleratorController::~NestedAcceleratorController() {
21 } 22 }
22 23
23 void NestedAcceleratorController::RunWithDispatcher( 24 void NestedAcceleratorController::PrepareNestedLoopClosures(
24 base::MessagePumpDispatcher* nested_dispatcher) { 25 base::MessagePumpDispatcher* nested_dispatcher,
25 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); 26 base::Closure* run_closure,
26 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); 27 base::Closure* quit_closure) {
27
28 scoped_ptr<NestedAcceleratorDispatcher> old_accelerator_dispatcher = 28 scoped_ptr<NestedAcceleratorDispatcher> old_accelerator_dispatcher =
29 accelerator_dispatcher_.Pass(); 29 accelerator_dispatcher_.Pass();
30 accelerator_dispatcher_ = NestedAcceleratorDispatcher::Create( 30 accelerator_dispatcher_ = NestedAcceleratorDispatcher::Create(
31 dispatcher_delegate_.get(), nested_dispatcher); 31 dispatcher_delegate_.get(), nested_dispatcher);
32 32
33 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them
34 // use run_loop.QuitClosure().
35 scoped_ptr<base::RunLoop> run_loop = accelerator_dispatcher_->CreateRunLoop(); 33 scoped_ptr<base::RunLoop> run_loop = accelerator_dispatcher_->CreateRunLoop();
36 base::AutoReset<base::Closure> reset_closure(&quit_closure_, 34 *quit_closure =
37 run_loop->QuitClosure()); 35 base::Bind(&NestedAcceleratorController::QuitNestedMessageLoop,
36 base::Unretained(this),
37 run_loop->QuitClosure());
sky 2014/05/28 23:11:12 This is more of what I was thinking, but having to
sadrul 2014/05/29 00:25:39 I think that makes it possible for the wrong dispa
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) {
38 run_loop->Run(); 47 run_loop->Run();
39 accelerator_dispatcher_ = old_accelerator_dispatcher.Pass(); 48 accelerator_dispatcher_ = old_accelerator_dispatcher.Pass();
40 } 49 }
41 50
42 void NestedAcceleratorController::QuitNestedMessageLoop() { 51 void NestedAcceleratorController::QuitNestedMessageLoop(
43 CHECK(!quit_closure_.is_null()); 52 const base::Closure& quit_runloop) {
44 quit_closure_.Run(); 53 quit_runloop.Run();
45 accelerator_dispatcher_.reset(); 54 accelerator_dispatcher_.reset();
46 } 55 }
47 56
48 } // namespace wm 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